You are on page 1of 76

The Minimum You Need to Know

AboutServiceOrientedArchitecture

ByRolandHughes

LogikalSolutions

Copyright2007byRolandHughes
Allrightsreserved

ISBN
ISBN13

0977086666
9780977086665

ThisbookwaspublishedbyLogikalSolutionsfortheauthor.NeitherLogikalSolutionsnorthe
authorshallbeheldresponsibleforanydamage,claimorexpenseincurredbyauserofthisbook
asaresultofitsuseorrelianceupon.
Thesetrademarksbelongtothefollowingcompanies:
ACMS
HewlettPackardCorporation
Ask.com
IAC(InterActiveCorp)
Attunity
AttunityLtd.
Borland
BorlandSoftwareCorporation
DEC
DigitalEquipmentCorporation/HewlettPackardCorporation
DECdtm
DigitalEquipmentCorporation/HewlettPackardCorporation
DECForms
DigitalEquipmentCorporation/HewlettPackardCorporation
DRDOS
DRDOS,Inc.
MSDOS
MicrosoftCorporation
JBuilder
Borland
JSP
SunMicrosystems
Linux
LinusTorvalds
MQSeries
IBM(InternationalBusinessMachinesCorporation)
MySQL
MySQLAB
OnPlatform
HewlettPackardCorporation/AttunityLtd.
Oracle
PostgreSQL
RDB
Reactivity
RMS
Tru64
Ubuntu
Unix
Windows

OracleCorporation
PostgreSQLGlobalDevelopmentGroup
OracleCorporation
IBM
HewlettPackardCorporation
HewlettPackardCorporation
CanonicalLtd.
TheOpenGroup
MicrosoftCorporation

Allothertrademarksinadvertentlymissingfromthislistaretrademarksoftheirrespectiveowners. Abesteffortwas
madetoappropriatelycapitalizealltrademarksthatwereknownatthetimeofthiswriting.Neitherthepublishernorthe
authorcanattesttotheaccuracyofthisinformation.Useofaterminthisbookshouldnotberegardedasaffectingthe
validityofanytrademarkorservicemark.

Acknowledgments
Books likethis, the planned closing of a series segment, come about because dedicated
readerslikeyourselfpurchased,readandwroteaboutthepriorbooksintheseries.Whenthat
doesn'thappen,aseriessegmentsimplygetsleftundone. ToparaphrasetheBartles&James
commercials:Ithankyouforyoursupport.

SourceCodeLicense
Any person owning a copy of this book may use the source code from this book and
accompanying CDROM freely when developing software for their personal use, their
company'suseortheirclient'suse.Suchpersonsmayincludethesourcecodeeithermodifiedor
unmodifiedprovidedthatthesourcedeliveredmakesreferencetotheoriginalauthorandispart
ofafullyfunctionalapplication.Itisexpresslyforbiddenforanyonetopostthissourcecodeon
anybulletinboardsystem,InternetWebsite,orotherelectronicdistributionmediumwithoutthe
expresswrittenpermissionoftheauthor.Itisalsoexpresslyforbiddentosellthissourceaspart
ofalibraryorsharewaredistributionofsource.
UsersofthesourcecodecontainedwithinthisbookandontheaccompanyingCDROM
agreetoholdharmlessbothheauthorandthepublisherforanyerrors,omissions,losses,orother
financialconsequencesresultingfromtheuseofsaidsource.Thesourcecodeissuppliedas
iswithnowarrantyofanykindexpressedorimplied.

TableofContents
1. Introduction...............................................................................................................................1
1.1SOAWhereWeCameFrom............................................................................................1
1.2TheDisasterWeAreHeadedToward................................................................................4
1.3WhyWeAreHeadedThere................................................................................................6
1.4TheRootsofSOA...............................................................................................................8
1.5AdditionalReading..............................................................................................................8
2. Clustering..................................................................................................................................9
2.1WhatisClustering...............................................................................................................9
2.2DistributedTransactionManagement...............................................................................14
2.3TwophaseCommit...........................................................................................................15
2.4SharedResources..............................................................................................................16
3. WhatisWrongToday.............................................................................................................19
3.1WeSoldModules..............................................................................................................19
3.2WeAreStillSellingModules...........................................................................................20
3.3TheEndofModules..........................................................................................................21
3.4HowDoWeFixThis?.......................................................................................................22
3.5Today'sSOACamps.........................................................................................................24
3.6StartSmall.........................................................................................................................28
4. GreenScreensontheWeb......................................................................................................31
4.1ObtainingaWebServer....................................................................................................31
4.2ObtainingaWebTerminal................................................................................................32
4.3IsThisSOA?.....................................................................................................................35
5. ACMSFundamentals..............................................................................................................37
5.1WhyAreYouOnlyHearingAboutACMSNow?............................................................37
5.2FlowDescription...............................................................................................................39
5.3GeneralPrincipals.............................................................................................................40
5.4IORoutines........................................................................................................................43
5.5TheMajorPieces...............................................................................................................44
5.6WhichTypeofACMSApplication?.................................................................................49
5.7Security..............................................................................................................................50
5.8TheMarchForward...........................................................................................................51

6. OurFirstSteps.........................................................................................................................55
6.1DecidingontheMethod....................................................................................................55
6.2DirectDatabaseAccessviaRemoteJava..........................................................................56
6.3SomeThoughtsonEditors................................................................................................62
Illustration6.1..................................................................................................................64
Illustration6.2..................................................................................................................65
Illustration6.3..................................................................................................................66
Illustration6.4..................................................................................................................68
Illustration6.5..................................................................................................................70
6.4DatabaseAccessviaJavaApplet......................................................................................72
Illustration6.6..................................................................................................................73
Illustration6.7..................................................................................................................81
6.5ABitMoreonShellScripts..............................................................................................83
6.6WhatAboutMySQL?.......................................................................................................84
Illustration6.8..................................................................................................................90
6.7WhatHaveWeLearned?..................................................................................................94
7. ADirectPort............................................................................................................................95
7.1WhyThisMethod?............................................................................................................95
7.2HowWillWeProceed?.....................................................................................................96
7.3TheLoginDialog..............................................................................................................98
Illustration7.1..................................................................................................................98
Illustration7.2................................................................................................................103
Illustration7.3................................................................................................................104
Illustration7.4................................................................................................................105
Illustration7.5................................................................................................................113
Illustration7.6................................................................................................................114
Illustration7.7................................................................................................................130
Illustration7.8................................................................................................................131
Illustration7.9................................................................................................................132
7.4Assignments....................................................................................................................143
7.5Experts.............................................................................................................................143
7.6TooMuchTimeOnYourHands....................................................................................144
7.7IsthisSOA?.....................................................................................................................144

8. ServiceTypes........................................................................................................................149
8.1DifferentTypesofService..............................................................................................149
Illustration8.1................................................................................................................152
8.2ExposingRMSFilesviaServices...................................................................................154
8.3AssignmentsPart1..........................................................................................................174
8.4UsingThoseServices......................................................................................................174
Illustration8.2................................................................................................................175
Illustration8.3................................................................................................................186
8.5AssignmentsPartTwo.....................................................................................................189
8.6IsThisSOA?...................................................................................................................192
8.7WhatAboutSecurity?.....................................................................................................193
8.8Summary.........................................................................................................................195
9. LoadBalancingandFaultTolerance.....................................................................................197
9.1BruteForce......................................................................................................................197
9.2BackEndBalancing........................................................................................................198
9.3WarehousingPolicyEffectonLoadBalancing..............................................................205
9.4HowDoYouBalancetheLoad?.....................................................................................208
9.5HowDoYouProtecttheTransaction?............................................................................208
9.6CanIUseDECdtmWithoutACMS?..............................................................................213
9.7HowMuchFaultToleranceDoesDECdtmBuyYou?...................................................214
Illustration9.1................................................................................................................216
Illustration9.2................................................................................................................217
9.8CanIUseMQSeriesWithoutACMS?...........................................................................221
9.9QueueTrigger.................................................................................................................221
9.10Summary.......................................................................................................................222
10.AnACMSExample..............................................................................................................223
10.1ScopeofOurExample..................................................................................................223
10.2OurDTD........................................................................................................................226
10.3OurFiles.......................................................................................................................231
10.4ACMSQueues...............................................................................................................240
10.5TheInterimRecordFormats.........................................................................................249
10.6ParsingXMLonOpenVMSWithXerces.....................................................................251
10.7ParsingXMLonOpenVMSWithlibXML2.................................................................256
10.8OurStandaloneXMLParser.........................................................................................262
10.9OneLastBitAboutACMSQueues..............................................................................278
10.10StandalonetoServer....................................................................................................283
10.11Authorizing,Installing,Starting,StoppingandTesting..............................................316
10.12MonitoringYourACMSApplicaiton.........................................................................336

10.13ControllingYourACMSApplication.........................................................................338
10.14OurPortService..........................................................................................................339
10.15OurOrderGenerator...................................................................................................342
10.16Assignments................................................................................................................346
11.WhineandSnivel..................................................................................................................347
11.1But,but,but...................................................................................................................347
11.2TheItemService...........................................................................................................347
11.3OurNewApplet............................................................................................................350
Illustration11.1..............................................................................................................350
11.4Summary.......................................................................................................................360
12.ObservationsandIncantations..............................................................................................363
12.1Overview.......................................................................................................................363
12.2TheFutureofSOA........................................................................................................363
12.3Java,WriteOnce,RunaFewPlaces.............................................................................367
12.4Grade8BoltSyndrome.................................................................................................368
12.5InClosing......................................................................................................................370

Chapter1
Introduction
1.1

SOAWhereWeCameFrom

Forquitesometimenow,marketingshillshavebeenpreachingandsellingSOA(Service
OrientedArchitecture).VastquantitiesofmoneyhavebeenpouredintoTheNextBigThing.
Well,itistimetoaskafewquestionsandrainontheirparade.
WhatistheServiceOrientedArchitecture?Thisisarehashofanoldbusinessmodelthat
playeditselfoutfromthe1970sintothe1980s.Backthencomputersweremultimilliondollar
investments. Smalltomidsizedcompaniessimplycouldn'taffordthem. Programmerswere
scarceandqualifiedprogrammersevenscarcer. Smalltomidsizedcompaniescouldafforda
fewthousanddollarsforterminalsandspecialmodems.Thentheyspentseveralmorethousand
dollarspermonthleasingtimeoncomputersystems. Therewereactuallybusinessesthatdid
littlemorethanleasetime.Theywouldalsosellconsultingservicesandleaseaccesstosomeof
theirapplications.
Those of you who grew up with $20/month Internet access probably have a hard time
imaginingsomeonepayingthousandsofdollarspermonthforaccesstoacomputersystem,but
it happened. Commercialclass operating systems provided system and application runtime
accounting.Amongotherthingstheywouldmeasuretheamountofcomputertime,connection
time, and IO that each user ID performed on the system. Every month the subscribing
companieswouldbebilledbytheCPUsecond,connectionminuteandblockofIO.Itshouldn't
takearocketscientisttodothemathhere.Onethousandcustomerspaying$10K+/monthtouse
yourcomputersystempaidoffa$2millionpricetagprettyquickly.Even100customerscould
makeitviableifyouwereusingthecomputersystemtorunyourownbusiness.Youboughtthe
machineontimeandtheymadethepaymentsforyou.
Ofcourse,thecompanieslookingtoleasetimedidn'thaveprogrammers(initially)anddidn't
haveapplications,sothosetimesharebusinessesgotintothecustomsoftwarebusiness.They
hadproprietarydatalayoutsthatlockedtheirclientsintoeverescalatingsupportcosts. Itwas
likeadrugaddictionyoucouldn'tkick.(Soundfamiliartothoseofyouusingstoredprocedures
inacommercialdatabase?)

Chapter1Introduction

Midrangecomputerscameontothescene.Manyofthecustomersofmainframetimeshare
systemsoptedtobuyamidrangecomputerforabout612monthsworthoftheirtimesharecost.
Eventually,theytoogotintothecustomapplicationandtimesharebusiness,butnotonaswide
ascale.
ThencamethePC.Promisingtoputcomputingpowerinthehandsofthepeoplewithout
anyregardforwherethatwouldlead.Vendorsofhardwareandsoftwarefortheselittleboxes
(forthetimeanyway)mademoneyhandoverfist. Competitionbecamecutthroat,andsoon
carcassesofonceproudvendorcorporationslitteredthelandscape. Companieshadarashof
deskdrawerapplicationsthatwerenowrequiredtokeeptheirbusinessesfunctioning. Very
littlecouldcommunicateeffectivelyorexchangedatareliably.
To stem the bloodshed, companies began focusing on networking technology. Multiple
competing proprietary networking protocols emerged. File servers and network application
servers sprang up all over the place. If you could afford the proprietary network interface
equipmentandthelicensing,youcouldallusethesameapplicationsandsharedata(intheory).
Greedsetinevenworsethanbefore.Itwasnothingtoenduppayingwellover$1,000fora
networkcardtogetacomputeronline.Sadly,youusuallyonlypaidabout$3,000forthePCto
beginwith.Somewhere,inmysouvenirsfromthepast,IhaveanISAbasedBiSyncmodemthat
operatedatawhopping1200baud.Ipaidjustover$1,300foritanditwasabuy!Thename
brandversionwasaround$2,500asIrecall.Thegreatpartabouttheseproprietarynetworking
systemswasthattheydidn'ttalktoeachother.Communicatingacrossthemrequiredevenmore
expensivebridgingsoftwareanddedicatedhardware.Evenwhenyouhadthenetworkingpeople
configuringyourmachineintheoffice,youdidn'talwaysgetnetworkaccess.Intheirownweird
way,thesamebarrierspeoplecomplainedaboutprovidedanearlyunparalleledlevelofsecurity.
Networksweresofinickytogetworkingfromtheinside,hackinginfromtheoutsidewasalmost
amyth.

Chapter1Introduction

NextcametheTCP/IPstandard,andtheInternet.Peoplewantedeverythingtoconnectto
theWeb.Hackersnowhadastandardizedmediumtoexploitandtheytooktoitwithzeal.PC
pricesdroppeddramaticallyandPCsstartedpoppingupallovertheplace.PCoperatingsystems
were(andstillare)sounstableandriddledwithsecurityholesthateveryapplicationandproject
hadtohaveitsownserver. Serversstartedappearingaroundcorporationslikerabbitstaking
bothViagraandfertilitydrugs.Suddenlycompaniesfoundtheywerespendingasmuchonthese
cheapsystemsastheyhadbeenonthemainframesthattookuplesstotalspaceandconsumed
lesspower.
Enterthegreatserverconsolidationmove.CompletelydisregardthefactyourPCserverOS
isunstable,requiringfrequent rebootingandpatching,takingtheapplicationsoffline. Load
virtualizationsoftwareonone,andconsolidate8ormoreintoonemachine.Uptimebedamned!
Nowwhenyouhavetorebootyoucantakeout8ormoreservers.
Oneproblemstillremainedthough.Eachapplicationrunningonaserverwasprettymuch
itsowndataisland.Evenwhenitstoreditsdatainadatabase,thatdatabasewaseitheronthe
sameserveritself,orthedatabasewasn'tthesameoneusedbyotherapplications.Management
hadcostcutitswayintoaverybitterpickleindeed.
Fear not though, the marketing shills had even more to sell them under the heading of
cuttingcosts.Managementalwayslistensintentlytothebuymoretospendlesssalespitch.
Repackagetheseapplicationswiththismagicmiddleware(foranadditionalfee)andyoucanuse
piecesofthem,tyingthemtogetherasyouwish.Theywillallhaveaprotocoltoexchangedata.
Youcanuseorderentryfromthiscompany,inventorymanagementfromthatcompany,andif
you buy today, company three will sell you a piece of their picking ticket & truck loading
module.
Infact,ifyouwanttouseitallfromonevendor,itwillworkthebest.Noneedtoinstall
theirapplications,simplyleasetimeontheirmachines.Getridofallthesepeskyservers.Let
someonehandletheupdatesandcapacityissuesforyou. VendorAhasbuiltamassivedata
centerinasinglelocationwithredundancyuponredundancyallinthesame40acres.Afterall,
theworldisonenetworknowisn'tit? Whyshouldyoukeepbuyingallofthisequipment,
simplypayforthetimeyouuse...

Chapter1Introduction

Sounds kind of familiar doesn't it? Pay by the application module, computer use and
storage. Ifitonlyendedthere,itwouldbelaughable.Butitgetsworse.

1.2

TheDisasterWeAreHeadedToward

Whataretheyusingtohostallofthiswonderfulstuff? RacksandracksofPConacard
servers.Heatisabiggerproblemforthemthanitwasfortheoldmainframes.Somecompanies
are now looking into liquid cooling systems for those personal computer chips. Liquid
cooling,justlikesomeofthebigmainframesused.
Whatoperatingsystemsaretheyrunning?Thesamecrummyoperatingsystemsthatwere
runningattheclientcompany. Securityholesandpatchesareaseeminglydailyifnothourly
occurrence, butthe client companies are used to outages. Outages have become a business
standard.
What happens when one of those PConacard devices fries? Why, they load you up
anotheroneatsomepoint. Can'treallysayhowlongtheoutagewillbe,butyou'reusedtoit
already.Sorryaboutthetransactionsthatwerebeingprocessed,butyouareusedtolosingthose
aswell.
ThesefaultscanallbeclassifiedundertheheadingIgnoranceofaCheapMind.
Whatcannotbeclassifiedunderthatheading,orevenforgiven,isthepackaging. These
supposedforwardthinkershaveallboughtintotheideathatonemassivedatacenterlocatedon
Xacressomeplacecheapisagoodidea. WhatisevenmoreunthinkableisthatCongressis
lettingthemdoit.
I'mnottalkingaboutCongressbeingincontrolofbusiness. I'mtalkingaboutCongress
lettingtheNationalSecurityAgencytaketheseindustryleadersintoadarkalleywithballbats
andcattleprodstoeducatethemonthefinerpointsofeconomicandindustrystability.
LetusassumeforamomentthatCongressistoobusygettingreelectedtodoanything
useful. (Admittedly, not a big assumption.) These data centers on steroids are allowed to
prosper. Theyhavehugedollarsbehindthemanddrive outcompetitorssowehaveonlya
handful. Nah,let'sshrinkthenumber. Weendupwithonlythree,justlikewedidwithauto

Chapter1Introduction

manufacturersyearsago.
Withgreedcoursingthroughtheirveinsstrongerthananynarcoticonthemarket,theyenter
acutthroatcompetitionjustlikethePCmanufacturersdid.Prettysoon,they'vedriventheprice
downtojustacouple thousandpermonthnomatterhow much youuse. Talkingheads at
companiesaroundthecountrystartchantingcutcostsandlookinginthedirectionofthese
serviceproviders.Yes,it'safinancialUtopiaallright.
Inaneedtodifferentiatethemselvesinthismarket,theBig3buyupapplicationsfocusing
onspecificmarketsegments. Oneprovidesthebestofthebestinbankingsoftware. Soupto
nuts online checking, accounting, wire transfer, younameittheycandoit banking product.
Anotherendsupfocusingonthecompletesolutionformanufacturing. Wearetalkingorder
entry,inventorycontrol,salesforcemanagement,assemblylinesystems,shopfloorcontrol,the
works. Thelastofthethreeendsupprovidingbestinclassshippinglogistics. Fromtruck
loadingtorouting,andeverythinginbetween,theyhavemodulestodoit.
Ah,Utopia.Theyevendevelopaworkingrelationship,sothemanufacturingsystemscan
usetheshippinglogisticsmodulesandtheybothusepartsofthefinancialmodules.Ittrulyis
bliss.Thisiswhatmarketinghaspromisedandtheyfinallydelivered.Sortof...
Nomatterhowyousliceit,theseprovidersspentheapsofmoneybuildinguponelocation.
Usuallywheretherewasreallycheappower.Oneofthemendsupgettingbuiltwellwithinthe
blastradiusofMt.Rainierwhenitfinallypopsitstop.(Accordingtoscientistswithinthenext
20years,buttheyguessedalittlelongonMt.St.Helens,soitisprobablyattheshallowendof
the20.)Anothergetsbuiltonamajorfaultlinebecausepowerwashalfthepriceofanywhere
else. Thelastgetsbuiltinthelowcostrealestatedistrictfoundneartheendofmajorairport
runwaysbecausetheygotasweetdealfromthestateandcitygovernments.
It shouldn't be any surprise where this is heading. It doesn't matter how much power
generation and redundancy each location has built into it, they will be taken out, either for
monthsorpermanently.Ajethasenginetroubleontakeoffandcrashes,Mt.Rainierdecidesto
provethenaysayerswrong,andthat8.2quakefinallydoesoriginatefromthedormantfaultline
justlikegeologistssaiditwouldeventually.Inthisdayandage,wealsohavetodealwiththe
possibility of a terrorist group either crashing a jet or driving a truck load of homemade
explosivesintothesite. LetusnotforgetthingslikeKatrinaandthetsunamiforthecenters
withinafewmilesofacoastline.OncewegettoaBig3orevenBig4situationwiththese

Chapter1Introduction

singlelocationservicecenters,thedestructionofone,byanymeans,cripplesanationandquite
possiblytheworldeconomy. PCandUNIXpeoplethinkonlyaboutlossofasinglepieceof
equipmentorpower.Midrangedevelopersthinkaboutthelossofanentirefacility.

1.3

WhyWeAreHeadedThere

Whereweareheadedisnotgoodbecauseofthepremisewhichstarteditall.Actually,there
weremultiplepremisesthatleadusdownthisgildedpath:

Running core business systems on feeble operating systems was OK because the
hardwarewascheap.
UsingoperatingsystemswhichcannotclustercompletelyisOKwhentheyarecheap.
Replacingexistingsystemswithaflatmonthlyfeeservicewasagreatwayofcutting
costs.
Buildingasinglemassivelocationtodoeverythingandgeteconomiesofscalewasa
goodidea.

Cheaphardware leadtothePCsonViagraandfertilitydrugsscenario. Well,that,and


unstableoperatingsystems. EvenIBMisrunningadsaboutserversbeingsonumerousyou
cannotwalkinabuilding. Whiletheyareanexaggeration,theyaren'toffbymuch. Oddly
enough,IBMmarketedtheoriginalIBMPCdirecttobusinessesinthefirstplace,sothisiskind
oflikeprofitingfromthesinsofyourpast.
Cheapoperatingsystems.Gottalovethat.Iremembercompaniesandpeoplecomplaining
about spending $80 forDOS. At least with DOS, once you bought it, it was yours. Now
WindowsismovingtowardtheAssoonasyoustoppayingfortheserviceagreementyouruse
licenseexpiresmodelwithaninitialrentalpriceofaround$300.CommercialflavorsofUNIX
hadtheirowntrappingswhenitcametolicenseagreements.NowpeopleholdupLinuxasthe
beallandendall.Onlyoneproblem,noneoftheseoperatingsystemsclustercorrectlyorwell.
Theynetwork,butdonotcluster. EventheTru64versionofUNIX,releasedbythecompany
thatgavetheworlditsfirst(andstillonly)commerciallyviableclusteredoperatingsystemdidn't
managetogetclusteringworkingcorrectlyinUNIX.Theproblemis,youcan'tbeloyaltothe
UNIXinstalledbaseandcluster.Theplatformismissingcriticalpieces,andwhenthosepieces
are added,itwon'tbeUNIXanymore,itwillbeacloneofOpenVMSwithsomecommand
syntaxchanges.

Chapter1Introduction

Flatmonthlycost.Managementlovestheflatmonthlycostmodel.Indeed,Internetaccess
providers and now cable phone providers are herding consumers towards that mentality.
Managementlovesitbecausetheynowonlyhaveonethingtolookatwhentheysitaroundina
talkingheadsmeetingchantingcutcosts.Leavesmoretimeforthegolfcourse.
Asinglemassivedatacenter.Nowhereisanideastraightfromthe1970s.Youhavetobe
oldtorememberit.TheclassicIBMmainframedatacenter.Raisedfloortohidecabling,route
airconditioning,andprovideawatertrap.Bulletresistantglasswallsopeoplecouldwalkby
andbeamazedbytheequipment. Twotothreelayersoffireprotection. Multiplelockentry
security.Insomecases,evendatacenterguardsbythedoors.Let'snotforgetthemassivediesel
engine generators parked right outside the building and in later years the room full of UPS
(UninterruptablePowerSupply)equipment.
IBMwastheoriginatorofthebigirontrend. Itdidn'tcluster,butitdidhaveit'sown
proprietarynetworkingforcommunications. Astheplatformprogresseditalsohadmachine
partitioning. This would let you divide up your big iron box so it looked like multiple
mainframestotheoutsideworld.Soundsalotlike virtualization doesn'tit? Bigironwasbig
bucks.Theydidn'tbotherwithclusteringtechnologybecauseveryfewcompaniescouldafford
toscatteradozenorsoofthesearoundthecountry.Instead,theyputforthwhatbecameknown
asthemoatandfortressdatacenterdesign.Thisleadtothebanktellerbulletresistantglass
platesandtheotherthingswetalkedabout. Ineverreallydidfigureoutwhatthemoatwas,
unlessitwastheraisedfloororthefactmanycompaniesweretoldtolocatetheirdatacenteron
thesecondfloor,notthefirstorthebasement.Theyusedtogetputinthebasementbecausethe
equipmentwassoheavy,thensomeonethoughtaboutthefloodingissue.
DEC(DigitalEquipmentCorporation)focusedprimarilyonthemidrangemarketformid
sizedcompanies.Thesewerecompaniesthatcouldaffordtospendonehalftotwomillionfor
theirentiredatacenterandcomputersystem. Thecompaniesknewtheyneeded acomputer
systemtocompeteandkeepgrowing,buttheycouldn'tbitethebulletforamultimilliondollar
mainframesetup. Asthecompaniesranmoreefficientlywiththecomputersystemtheykept
findingmoreandmoreusesforit. Foratimetheyboughtbiggerandbiggerboxes,butthe
engineersatDECcameupwithanevenbettersolution.Buymoreofthesameandhookthem
alltogethersofiles,batchjobs,usersandprocessingpowercouldbeutilizedthroughoutacluster
ofcomputers. Ascommunicationsimprovedworldwide, theseclusters,literallyspannedthe
globe.

8
1.4

Chapter1Introduction
TheRootsofSOA

Both DEC and IBM hit on the need for transaction management. IBM created CICS
(Customer Information Control System) and DEC created ACMS (Application Control
ManagementSystem).Bothofthesewereandstillareamazingproducts.ACMShadthemost
farreachingimplications,yetfewrealizedit.Sadly,muchofthemarketmissedit.
WhiletheconceptwillbecompletelyforeigntothosecomingfromthePCandUNIXsides
oflife,thesesystemsallowedyoutobothpackagefunctionsforaServiceOrientedArchitecture
andprovidedguaranteedexecution.AsideeffectwasthateachSOAtaskyoucreatedwiththem
hadamessagingformatthatdidnotallowfordataoverrunorSQLinjectionlikethecurrentWeb
fiascoes. Yes,therearemanythirdpartymessagingsystemsthesedaysmakingclaimsabout
guaranteedmessagedelivery,butnonewillgosofarastoguaranteeitsexecution.
BecauseACMSwasthemostfarreachingandtheoneIhavethemostexperiencewith,we
willbediscussingACMScombinedwithclusteringinthisbook.

1.5

AdditionalReading

Ifyoulikethestyleandcontentofthisbook,orwouldsimplyliketolearnmoreabout
applicationdevelopmentonOpenVMS,pleasepickupcopiesofTheMinimumYouNeedto
KnowtoBeanOpenVMSApplicationDeveloperISBN0977086607.Youcanfollowitup
with The Minimum You Need to Know about Java on OpenVMS Volume 1 ISBN
0977086615ISBN139780977086610.
AtsomepointTheMinimumYouNeedtoKnowAboutLogictoWorkinITwillbe
availableaswell.ThisisnotanOpenVMSspecificbook,butmeanttobeusedasatextbookto
teachthosenewtoITaboutlogic.Itappearstoday'sgraduateshaven'tthefoggiestclueaboutit.
ISBN0977086623ISBN139780977086627.

Chapter2Introduction

Chapter2

Clustering
2.1

WhatisClustering

Clustering,eventoday,isoneofthemostforwardthinkingconceptsintheITindustry.It
wassofaraheadofitstime,themarketcouldn'treallycomprehendit.Clusteringrequiresthat
whenanodejoinsthecluster,ithonorsandrespectstheconsensusofthecluster.Tostartwith,
itmustusethesameUAF(UserAuthorizationFile)astherestofthecluster.Accesstocluster
resourcesiscontrolledbothbythestandard(System,Owner,Group,World)protectionsettings
providedbymanyplatformsandACLs(AccessControlLists).
ACLsrequirequiteabitofknowledgetoimplement.Youcannotsimplyboltthemontoan
OS which doesn't have native support for them. Their use and concept must be firmly
entrenchedwithintheOSkernel.LetmeshowyouanexampleofasetofACLsonadirectory.
$ dir/sec dka1200:[000000]acl_test.dir
Directory DKA1200:[000000]
ACL_TEST.DIR;1
1/18
29-NOV-2004 17:37:24.04 [HUGHES]
(RWE,RWE,RE,E)
(IDENTIFIER=GST_S,OPTIONS=DEFAULT,ACCESS=READ+WRITE+EXECUTE+DELETE)
(IDENTIFIER=GST_RE,OPTIONS=DEFAULT,ACCESS=READ+EXECUTE)
(IDENTIFIER=GST_RO,OPTIONS=DEFAULT,ACCESS=READ)
(IDENTIFIER=[*,*],OPTIONS=DEFAULT,ACCESS=NONE)

The series of RWE letters enclosed in parenthesis to the right is the standard (System,
Owner,Group,World)protectionImentionedbefore.Read,Write,ExecuteandDeletearethe
accessprivilegesyoucanuseforeachclassofuser.Ifauserismissingoneofthoseletters,it
cannotperformthatfunctiononthefileordirectory. UNIXanditsderivativeworksdonot
implementfourlevels,sotheyfallalittleshortfromthestart.
Take a look at the ACL list though. Each identifier gets its own unique set of access
privileges. Thepossibleentries are READ, WRITE,EXECUTE, DELETEandCONTROL.
Becausethisisadirectory,theOPTIONS=DEFAULTclauseisusedtocausethe ACL tobe
inheritedbyallfilesanddirectoriescreatedunderneaththisdirectory.Theverylastentryinthis
listtellstheoperatingsystemtocompletelyignorethestandard(System,Owner,Group,World)
settingsforanyoneotherthanthefileowner.Thewildcardentry[*,*]matchesallidentifiers.

10

Chapter2Clustering

OrderisveryimportantwithinanAccessControlList.Theentriesmustbeintheorderyou
wishthemtobefound.Forthisreason,thehighestprivilegeaccesslevelsarealwayslistedfirst.
Thereason:the ACL issearchedsequentiallyforthefirstmatchingrightsidentifier. Oncea
matchisfound,thatlevelofprivilegeoraccessisgiventotheuserorprocess.If[*,*]werefirst,
itwouldn'tmatterwhatcameafter.
Butwhatisarightsidentifier,andwheredoesitcomefrom?Rightsidentifiersarecreated
byoneofthesystemadministratorsfromwithintheUAFutility.Theyarethengrantedtouser
accounts as the company or system administrators see fit. Normally, companies set up
proceduresandformsforcreatingrightsidentifiersandgrantingthemtoaccounts.
$ set def sys$system
$ run authorize
UAF> add/ident gst_ro
%UAF-I-RDBADDMSG, identifier GST_RO value %X80010001 added to rights database
UAF> add/ident gst_re
%UAF-I-RDBADDMSG, identifier GST_RE value %X80010002 added to rights database
UAF> add/ident gst_s
%UAF-I-RDBADDMSG, identifier GST_S value %X80010003 added to rights database
UAF> grant/ident gst_ro guest
%UAF-I-GRANTMSG, identifier GST_RO granted to GUEST
UAF> grant/ident gst_re guest
%UAF-I-GRANTMSG, identifier GST_RE granted to GUEST
UAF> grant/ident gst_s guest
%UAF-I-GRANTMSG, identifier GST_S granted to GUEST

As you can see, the operating system chooses a numeric value for them at the time of
creation.ThisisanotherreasoneachmemberintheclustermustrespecttheUAFchosenbythe
cluster.Whileyoumightbeabletomanuallycreatematchingauthorizationfilesasfarasusers
goonallmachines,gettingtherightsidentifierstohavethesamevalueonallmachineswouldbe
averytedioustask.
Onceauserhassomerightsidentifiers,itdoesn'tmatteriftheydon'thaveanyoperating
systemlevelprivileges.Aslongastheyhavetheauthoritytologin,theywillbeabletouseany
resourcewithamatching ACL entryforoneoftheirrightsidentifiers. Inthisway,youcan
spoonoutaccessonafilebyfile,directorybydirectory,diskbydisk, batchqueue by batch
queue,executablebyexecutable,etc.basis.Mostcompaniesdon'ttakeittoquitethatlevel,but
youcanifyouwish.

Chapter2Clustering

11

TheUAFandrightsidentifiersprovidetheprimaryaccesskeystoopeningupthepowerofa
cluster.Thehiddenbeautyofaclusteristhesupportforitbuiltintothekernel.Oneofthemain
foundationsforthathiddenbeautyislogicalnametables.MostPCandUNIXtypedevelopers
areonlyfamiliarwiththeconceptofenvironmentvariables.UnderOpenVMSthoseareknown
assymbols.Symbolsaren'treallyusefulinasecuredandrobustoperatingsystem.Theyhave
somepurposes,mostlyforprogramsrunningunderasingleuserID,buttheydon'tallowfor
controlledaccessorforbeingclusteraware.Thesolutionherecomesintheformoflogicals.
OpenVMSandRMS(RecordsManagementSystem)utilizelogicalsextensively.Alogical
ismuchlikeanaliasonlymuchmorepowerful.Someofthemareprovidedbythesystemand
othersyoucancreateyourselfasaprogrammer.Logicalsoccuratwhatarecalledlevels.A
levelisnothingmorethanalogicalnametableinyourlogicalsearchpath.Yoursearchpathis
definedbyalogicalknownas LNM$FILE_DEV. Everyloggedinprocessstartsoutwitha
default version of LNM$FILE_DEV, which is found in the logical name table LNM
$SYSTEM_DIRECTORY. Variouslevelsofprivilegesarerequiredtodefinelogicals,but
everyprocesscandefineitsownprocesslevellogicals.
$

1
2
1

show log/table=lnm$system_directory lnm$file_dev


LNM$FILE_DEV = LNM$PROCESS (LNM$SYSTEM_DIRECTORY)
= LNM$JOB
= LNM$GROUP
= LNM$SYSTEM
= DECW$LOGICAL_NAMES
LNM$SYSTEM = LNM$SYSTEM_TABLE (LNM$SYSTEM_DIRECTORY)
= LNM$SYSCLUSTER
LNM$SYSCLUSTER = LNM$SYSCLUSTER_TABLE (LNM$SYSTEM_DIRECTORY)
DECW$LOGICAL_NAMES [table] = (LNM$SYSTEM_DIRECTORY)

Thedefaultdefinitionof LNM$FILE_DEV showsyoutheprimarylevelsoflogicalname


tables. LNM$JOBisthejoblevelnametable. Eachtimeauserlogsinoradetached/batch
processiscreated,itgetsassignedauniquejobIDandajoblevellogicalnametableiscreated.
The process level logical name table is created for each process as that process is created.
Processeswhicharespawned,orotherwisecreatedaschildrenofaparentprocessinheritthe
parentjobleveltable.Thegrouplevellogicalnametableexistsforeveryoneinagroup.One
tableiscreatedforeachusergroupfoundintheUAFatsystemstartup.Eachuserprocessmaps
ontothegrouptableforitsgroup.

12

Chapter2Clustering

The system level table gives us some interesting talking points. As each node boots it
createssystemlevellogicalswhichareavailabletoallprocessesandusers.Aseachnodejoinsa
cluster,theclusterimposesitswillbydefiningclusterwidelogicals.Theselogicalsexistinthe
localcopyofthesystemtableoneachnodeinthecluster,butanyupdateormodificationofa
clusterwidelogicalgetsreplicatedacrosstheentirecluster.
Eachapplicationyoucreate,buyorotherwiseinstall,can,andusuallydoes,createitsown
applicationlevellogicalnametable. Sometimesaccesstothesetablesisthrownopentothe
world,andothertimesthetableiscreatedwithanACLforsecurityreasons.(Youdon'twanta
guestusertobeabletolookatlogicalsusedbyyouraccountingsystem.) Whenauserneeds
accesstotheseapplicationlevellogicals,thenametableisusuallyinsertedintotheirlocalcopy
ofLNM$FILE_DEV.
CREATE_NAME_TABLE.COM
$ create/name_table/parent_table=lnm$system_directory
my_app_tbl
$!
$ set security/class=logical/acl=(identifier=gst_re,access=read+execute)
$!
$ set security/class=logical/prot=(w) my_app_tbl
$!
$ define/table=my_app_tbl first_logical sys$login
$!
$ exit

my_app_tbl

The above is a command file or script for creating a logical name table. Below is its
executionandoutput.
$ @create_name_table
$ show log/full/table=my_app_tbl
(MY_APP_TBL)

[super] [shareable]
[Protection=(RW,RW,R,)] [Owner=[HUGHES]]
(IDENTIFIER=GST_RE,ACCESS=READ+CREATE)

FIRST_LOGICAL [super] = SYS$LOGIN

Youwillnoticethattheprotectiononthistablewasn'topeneduptotheworld.Theworld
portionof(S,O,G,W)hasnoentriesinit.Somewhereintheuser'slogin,orthestartupforthe
application,therewouldbeacommandlikethefollowingtoinsertthisapplicationnametable
intotheusersdefinitionofLNM$FILE_DEV.
$ DEFINE/TABLE=LNM$PROCESS_DIRECTORY LNM$FILE_DEV LNM$PROCESS, LNM$JOB, LNM$GROUP, LNM$SYSTEM

Chapter2Clustering

13

Logicalsarerequiredtomakeclusteringwork.Youcannottrytosimplyexpandsymbolsor
environmentvariablespasttheircurrentlocalandglobaltypes.Itsimplyisn'ttheirlotinlife.
Globalsymbols,bytheirnature,areunprotected.Thereprimaryuseistosimplifycommandsor
exchangenonsensitivedata.Tryingtoaddsecuritytothemwouldbreaktheirfunctionality
badly.Logicalsweredesignedwithsecurityinmind.
Onethingyoumayormaynothavecaughtontoisthatanapplicationlevellogicalname
tablecanalsobedeclaredasaclusterwidenametable. Insteadofhavingtheparentbelnm
$system_directory,theparentwouldbe lnm$cluster_table. Aseachnodejoinedtheclusterit
wouldinheritthetableandenforceallaccessrulestoit.Anychangemadetothetableonone
nodewouldbereflectedinthetableonallnodes.
EarlierItoldyouthateachnodejoiningaclustermakesitsresourcesavailabletothecluster.
Intheearlydaysofclustering,makingthediskdrivesmountacrosstheclusterandappearas
localdrivestoauserwasagreatachievement. Nowthatmostdiskfarmsconsistofmultiple
SAN (Storage Area Network) or disk array subsystems, this may not seem like such an
achievement.Tothecontrary,itstillis.
Diskstoragesubsystemshavethebuiltincapabilitytomapanamazingnumberofspindles
intowhatlookslikeasinglephysicaldisktotheconnectingcomputer.TheirbuiltinRAIDand
hotswappingcapabilitiesoffloadalotofworkfromthecomputersutilizingthem.Thebuiltin
cachingsupplementstheoperatingsystemleveldrivecaching,increasingoverallperformance.
Thesearegreatachievementsindeed!Theyhavesomelimitsthough.
BecausediskarraysandstoragenetworksfocusontheIOsubsystemdirectly,inorderto
support a large number of operating systems, they don't provide anything in the way of
transactionalintegrity. Yes,thesubsystemcandolocaldriveshadowing,andwillnotreturn
success until all writes have completed, but this still doesn't provide you with transactional
integrity. Toachievetransactionalintegrity,youneedadistributedtransactionmanagerbuilt
intotheOSkernel.

14
2.2

Chapter2Clustering
DistributedTransactionManagement

Adistributedtransactionmanager(DECdtm)makesthetransactionalintegrityprovidedby
relational databases seem almost weak by comparison. A distributed transaction manager
providesatransactionlevelsafetynetacrossawiderangeofitems.Theseinclude,butarenot
limited to, indexed files, message queues and relational databases. If you write a program
utilizingthedistributedtransactionmanager,youcanreadamessagefromaqueue,updatesome
indexedfilesandwriteinformationtoarelationaldatabasewiththefullconfidencenochanges
willtakeplaceuntilyouactuallycommitthedistributedtransaction.
MostofyouarefamiliarwiththeCOMMITandROLLBACKcommandsfoundinrelational
databases.Thesecommandsarepartoftheintegrityprovidedbytherelationaldatabaseengine.
Theydonotprovideanyfunctionalityoutsideoftherelationaldatabase. If100%ofourdata
residedinsideofarelationaldatabase,thiswouldbeagoodthing.Thefactoflifeisourdata
doesn'tallresidethere. IntheworldofSOA,wehavehundreds,ifnotthousandsofmessage
queuestodealwith.Therealwaysseemstobesomelegacydatathatmustremaininindexed
filesaswell.Quitesimply,youcannevergetthere.DECdtmunderstandsthisandmakesyour
lifebetter.
Whathappenswhenyouarehalfwaythroughprocessingamessagefromaqueueandyour
programcrashesforsomereason? Withoutadistributedtransactionmanager,yourrelational
database mightbeabletorealize yourprocesshasdiedand ROLLBACK yourtransaction
there,butwhatabouttheindexedfilesyouwroteto?Whataboutthemessageyoupulledoffthe
queue?Youhaveapartiallyprocessedtransactionwithnomethodofstartingover.Youhave
lostdataintegrity.
The vast majority of commercial messaging systems try to provide their own form of
COMMITandROLLBACK.Afewofthesemightalsohavetheabilitytodeterminetheprocess
thatreadamessagefromthemnolongerexists.Mostdonothavethatcapability.Becausethe
messagingsystemstrytosupportalargenumberofoperatingsystemstoincreasetheirmarket
share,theytendtoimplementthingsliketriggers,whichkickoffajobtoreadandprocessthe
message.Theyonlypromisethemessagewillnotbelostbetweenqueues,andthattheywillfire
the trigger thefirsttimeamessagearrives. Ifyoureadthemessage,startprocessingandfail,
theywillneverfirethetriggerforthatmessageagain.

Chapter2Clustering

15

Many shops try to implement a work around by having the trigger fire whenever the
messagedepthhitsNmessagesinthequeue.The trigger processthenissupposedtodrainat
leastthatmanymessagesfromthequeue. AllwellandgoodIsuppose,butwhataboutthat
partiallyprocessedmessage?Nothinghasdoneanycleanup,andyournexttriggerfirewilltryto
process itagain if ithas been restored tothe message queue. If the message has not been
restored,itislostforever.Whathappenswhenyourtriggerdepthissetto10,andtheveryfirst
messagebeingprocessedwastheonethatmadethetriggerprocessabend?Dependingonhow
yourqueuingsystemcounts,thedepthwilleitherbenineorstillbesittingat10.Ifitisat10,
yourtriggerwillneverfireagain.Ifitisnine,yourtriggerwillfirewiththeverynextmessage,
butthemessagebeingprocessedduringtheabendislostandgoneforever.
Aclusterawaredistributedtransactionmanagerisabletodetermineyourprocesshasdied
nomatterwhatnodeitwasrunningon. Itthenperformsthe ROLLBACK operationforyou.
RobustqueuemanagerslikeIBM's MQSeries arefullyintegratedwith DECdtm. Whenyou
startadistributedtransactionandreadamessagefromanMQqueue,themessagestaysthere,
butisflaggedasunavailableuntilthetransactioncompletes.Ifthetransactioniscommitted,the
messagegoesaway.IntheeventofaROLLBACK,themessageisreactivated,maintainingits
placeattheheadofthequeue.Thisensuresthemessagewillnotbedispatchedtoanotherserver
priortothecleanuphavingcompleted,anditensuresthemessagewillnotbelost.Guaranteed
deliverywithoutguaranteedexecutionisameaninglessfeature.

2.3

TwophaseCommit

AfeaturecommontotheOpenVMSmarketandquiterareonotherplatformsissomething
calledatwophase commit. Whilethereareseveralverydetailed(andsomemightsaymind
numbing) explanations around, let me sum it up for you. The DEC transaction manager
communicateswithallotherresourcemanagers.WhenyouissueaDECdtmcommit,itqueries
alloftheinvolvedtransactionmanagers. Iftheysaytheyarereadyandabletoperformthe
commit,itissuesthe commit tothem. Oncetheyhaveallresponded the commit completed
successfully,thecommitthenreturnsacompletionsuccesstoyourapplication.Ifevenasingle
resourcemanagerrespondsthatitcannotparticipateatthistime,nocommithappens.
Therearequiteafewconceptualstatestothetwophasecommit.Ifyoureallywishtoknow
howitworks,youcandelvedeeperintothedocumentationprovidedbyHP.Whatisimportant
toknowisthatyouwillnevergetapartiallycommittedtransaction.

16

Chapter2Clustering

ACMS is capable of handling this for you. Each time a transaction starts it can
automaticallystartadistributedtransaction. Youcan,ifyourlogicrequiresit,startyourown
DECdtmtransactionsfromwithinyourACMSserver.
Withoutatwophase commit,itisphysicallyimpossibletocoordinateatransactionacross
multipleresources. Whenlookingatpotentialmessagequeuesoftware,youneedtoseewhat
external transactionmanagerstheysupport. Rollyourownlogiciswhatyouwillfindmost
shopsusingfreeorcheapmessagequeuingsystemsdoing.Thisisinherentlyflawedandleadsto
significantproblems.Whenamessagequeuecannotbesynchronizedwithdatabaseandlegacy
fileupdates,youendupwitheitherlostmessages,orpartiallycommittedtransactions.Thisisa
problemwhenyouhavetofaceanaudit.It'samajorPRproblemwhenyouhavetoexplainto
yourbiggestcustomerwhyyouprocessedtheirordermultipletimes.

2.4

SharedResources

We have mentioned a little bit about shared resources in a cluster, but haven't really
discussed it. We have already spoken about diskdrives (either physical orthe virtual kind
providedbyadiskarray)beingmountedandsharedacrossacluster. Wehavealsodiscussed
thatuseraccountsandrightsidentifiersarecommonacrossthecluster. Nowweneedtotalk
abouttheotherresources.
Abatchqueuecreatedonanygivennodeintheclusterwillmakeitselfavailabletoallnodes
inthecluster. Auseranywhereintheclustercansubmitajobtoit,providedtheyhavethe
correctrightsidentifiersorprivilegestodothat.Youcanalsocreategenericqueuesthatsimply
holdandspooljobsforotherbatchqueues.Thisgenericqueuecanbemadetoknowaboutallof
thebatchqueuesonallofthenodes.Eachbatchqueuetypicallygetscreatedwithalimitofhow
manybatchjobsitcanrunsimultaneously.Thegenericqueuewilldispatchtowhateveractual
batchqueueisavailableatthetimeitreceivesajob.
Althoughitmayseemsomewhatprimitive,itisaformofdynamicloadbalancing. Just
becauseyouareononenodeandalloftheavailable batchqueue slotsareconsumedbylong
runningjobs,doesn'tmeanyourjobhastowaitfortheircompletion.Withalloftheresources
availabletoallofthenodes,thejobsimplygetsroutedtoanodewiththecapacitytorunit.

Chapter2Clustering

17

Genericbatchqueuestendtobeservedbyselectgroupsofactualbatchqueues.Thisisn't
duetoanyrestrictionofthecluster,ithastodowithsoftwarelicensing. Somecommercial
packagesgetlicensedinfunkywaysmakingitprohibitivelyexpensivetolicenseaproductfor
allnodesinthecluster. Ifyouboughtsomeformofcommercialaccountingsystem,butonly
licensedittorunonthreenodesofa20nodecluster,youmaycreateageneric batchqueue
calledACCOUNTING$BATCHthatonlydistributesjobstobatchqueuesonthosethreenodes.
Thesetupforthepackage,ortheuserlogin,woulddefinethisgenericqueueasthedefaultbatch
queueforthatapplication.
Printqueueshavesimilarfeatures.Youcancreatebothgenericspoolinganddevicespecific
printqueues.WhenyouareonanoderunninginCaliforniaandcreateareportforadepartment
atyourGermanylocation,youcansimplyprintittothequeuebeingservicedbyaprinterintheir
area.Thequeuelookslikeitisalocalqueuetoyou. Someshopswillgosofarastosetup
symbolsineachuser'saccountforprintingtothedifferentprintqueuesandassignthelogicalfor
theirdefaultprintqueue(SYS$PRINT)tobetheprinterclosesttowheretheysit.
While physically separate nodes do not directly share memory, it is possible to create
regionsofmemorywithcommoncontentskeptinsyncviaQIOcallsand/ordaemons.Itisalso
possibleforusersononenodetocreateprocessesthatrunonothernodeswithoutthemever
actuallyloggingintothosenodes.Onceagain,theusermusthavethecorrectlevelofprivilege
andrightsidentifiers.
ThelargestsharingofresourcesoccurswhenyouimplementyourSOAarchitectureusing
ACMS. EachnodemayrunaninstanceofyourACMSapplication. Astasksarequeuedfor
servers in that application, ACMS searches and finds the instance of the application with a
currentlyavailableserver.Ifnoserversarecurrentlyavailable,buttheapplicationrunningona
givennodehasn'treacheditslimitforthatserver(setbyyouoranoperator)ACMSwillstart
anotherinstanceofthatserverunderneaththeapplicationanddispatchthetasktoit.Likewise,
afterservershavebeenidleforacertainperiodoftime(setbyyouoranoperator)itwillbegin
shuttingdownthoseservers,thusdecreasingoverallclusterusageandhelpingtomaintainload
balancing.

18

Chapter2Clustering

Thereisalsoaminimumkeepaliveservercountwhichyoucontrol. Itisimportantto
notethattheseserverswillnotstayaliveforever.Afteraserverhasbeenidlefortheperiodof
timewhichyouset,ACMSwillkillitoff.Iftheresultingservercountisbelowtheminimum
keepalivevalue,itwillstartanewone.Whilethatmayseemoddtomanyreaders,itisan
incrediblefeature.Itpromisesyourapplicationwillnotcometoascreechinghaltduetohung
servers.
Ifyourserverinitializationcodehasanissuewithtrampdataorsomeotherprogramming
bugthatcausesittogointosleepmode,itwillonlysleepaslongastheidleservertimeout
period.Whileitistruethatthiscouldmaskabugforyou,ACMSerrsonthesideofapplication
stability. Thelastexecutablestatementineachofyourprocedures(initialization,processand
termination)shouldbetowriteasingletextlinetotheserverlogfile.Whenyouseethemessage
fromtheterminationprocedureinalogwhichdoesn'thavethemessagefromtheinitialization
procedure,youknowyouhaveaproblemandneedtotakecorrectiveaction.

Chapter3

WhatisWrongToday
3.1

WeSoldModules

My first programming job was at a DEC (Digital Equipment Corporation) VAR (Value
AddedReseller).Therewerealotofthembackthen.Everyoneofthemseemedtohavesome
cannedpackage theyweresellingalongwiththehardware. Mostofthemfocusedonthe
basicsofmanufacturing: OrderEntry,Shipping,InventoryManagementandBillofMaterials
(BOM). Everyoneofthesepackagescameinacustomizableform. Thismeansthebase
packagewassostrippedyoucouldn'tdoanythingbutoperatethemostgenericofbusinesses.
Whyweretheysoldthisway?Becausetherealmoneywasinthemodifications.Astaffof
developersexistedateachoftheVARstobothworkonthenextversionofthepackageandto
providetime&materialsmodificationservicestotheclients.Nocustomerboughtthecanned
versionofthepackage.Theyallwantedittweakedfortheirownbusinessrules.Few,ifany,of
thecustomershadtheirownprogrammingstaffs.Everycustomerhadtheirownuniquesetof
businessrulestheywantedincorporatedintotheapplication.
TheVARssoldtheirapplicationsinmodules.Youcouldbuyaslittleorasmuchasyou
couldafford. StartwithOrderEntry. Whenyoudecideyoulikedit,buyoneortwomore
modules.Eventuallyyouendedupwiththeentiresystem.Ofcourse,thereweresomegotcha's.
PartoftheInventoryandCustomerManagementsoftwarehadtobeincludedwiththeOrder
Entry modules. They simply couldn't work without it. Eventually, sales would talk most
customersintobuyingtheholytrinity,OrderEntry,InventoryandCustomerManagement.The
rulestheyneededwouldbeimplementedinthosemodulesandonlythosemodules.Whenthey
came backtogetadditionalmodules,theyhadtopayforanotherroundofmodificationsto
supportthemodificationsalreadyinplaceinwhattheyboughtthefirsttime. Onceyougota
customertobuytheholytrinity,itwasalicensetoprintmoney.

20

Chapter3WhatisWrongToday

Customizedsystemshaveacaveatthatvendorsdon'ttalkabouteventoday.Youareeither
lockedintothatversionforever,oryoupayforthesamemodificationsoverandoveragainwith
eachnewreleaseoftheproduct. Thereisnomiddleground. Oh,yes,thebillingratesbeing
chargedformodificationstothenewversionofthepackagearehigherthantheywerefortheold
versionaswell.Thisproblemexistsevenwiththebigvendorstoday.Nomatterhowexternal
youtrytomaketherulesmodules,youstillenduphavingtoopenuptheircodetohookinthe
rules. Assoonasthecodehasbeenopened,youarelookingathavingtomakethosesame
modificationseverytimeanewreleasecomesout.
Somecompaniestriedtoeasethispain. IknowofsomepayrollsystemsthatusedANSI
COBOLwithlinenumbers.Theywouldshipmodificationsourcemergefilestothecustomer
andmakeitthecustomersresponsibilitytoensurenoneoftheirmodificationswouldbewalked
onbythesenewlines.Forsmallreleasesandfixesitworked.Withmajorreleases,youdidn't
haveaprayer.

3.2

WeAreStillSellingModules

The1980sestablishedamindsetthatapplicationsshouldbesoldbymodule.Thatmindset
stillexiststoday.Whenyoumovetooneofthebigvendors,youbuyamoduleatatime.They
would like to sell you every product they have, but you simply cannot afford it. Some
companies have soughttoeliminate thelocked intoaversion problem bymodifyingtheir
businesstofittherulesalreadybuiltintothesystemtheyarebuying.
IlovewatchingtechnologycommercialsonTV,especiallysoftwarecommercials.Fromthe
1970stotheearly1990s,thesoftwareyouranyourcompanyonwasastrategicedge.Youmay
havesoldthesameproductsasyourcompetitors,butyoudidbusinessdifferently,thatwaswhy
customerscametoyouinsteadofthem.Thenthemarketingarms...err...Imeantheindependent
analysts,gotpaidtopromotetheconceptsofsoftware asanexpenseandusingthesame
softwareaseverybodyelse. Thelemmingssnappedintoline. Theystartedaxingallofthe
programmerstheyhadwhichunderstoodthebusinessrules,buyingcannedpackagesfromthe
majorvendors(asdictatedbytheindependentanalysts),andmodifyingtheirbusinesstouseonly
therulesalreadycodedintothepackagesotheycouldupgrade.Nowyousellthesameproducts
asyourcompetitorsandusethesamesoftwaretorunyourbusinessintheexactsameway.
Hellopricewar,goodbyestockoptions.Recently,I'veseensomecommercialsonTVsaying,if
you'rejustlikeeveryoneelse,whydobusinesswithyou?Iguessthefalloutnobodythought

Chapter3WhatisWrongToday

21

aboutwhenresurrectinga1970sbusinessmodelisthat1970sbusinessmentalitywouldcome
backwithit.
Inthe1970s,companiesleasedtimeoncomputersystemsbecausetheycouldn'taffordtheir
own. They paid to have customized applications installed on those systems so they could
continue to run their businesses the way they always had, just more efficiently. In 2007,
marketing types are trying to get customers to lease time on computer systems owned by
someoneelse,butstillusethesamecannedgenericbusinesspackageseveryoneelseisusing.
Doesanyoneelseseetheproblemhere?

3.3

TheEndofModules

Iftheindustryreally isgoingtoembrace Service OrientedArchitecture (SOA)thenthe


modulementalityhastodie.Youcanstillusemodulardevelopmentandstepwiserefinement,
buttheconceptofanapplicationmodulehastodie.Thisisgoingtobeahardsell,especiallyto
thecurrent leaders intheSOAfield. Theyaretryingtosellmodulesasaservice. Thisis
destinedtofail.
SomeofyoureadingthismightnotbefamiliarwithwhatImeanwhenIsaymodule.I'm
talkingaboutanapplicationmodule.Letmetrytobreakitdownforyouwithanexample.
ConsideraCustomerManagementmoduleforyourtypicalmanufacturingcompany.There
willbemanycomponentsofthismodule.Thebulkofthesecomponentswillbeaccessedviathe
Customer Maintenance screen or menu. The main or driving screen will allow you to
lookup/enter/modifyalloftheinformationforamaincustomeraccount.Additionalscreenswill
allowyoutosetupsecondarylocationsoralternateshippingaddressesforthismasteraccount.
Theaccountingpeoplewillhavetheirownscreenswheretheyadjustthecustomerscreditand
status. Higherendsystemswillalsohaveahistorytableshowingtotaldollarsforthemaster
accountandbreakitdownintototaldollarsforeachalternateaddressorsecondarylocation.
Therewillalsobeamailingpieceusingthisinformationtoinformthecustomerofvariousprice
cutsandcompanynews.Thissamepiecewillbeusedbyaccountingtosendeverincreasingly
nastymessagestocustomerswhoarepastdue.

22

Chapter3WhatisWrongToday

AlloftheabovewouldbeaCustomerManagementmodule. Therewouldbeadditional
pieces for businesses which offering rolling accumulated pricing discounts to customers.
(Rollingaccumulatedpricingdiscountswouldbeanadditionalpercentageofffortotalsales.i.e.
$8millionintotalsalesgetsyouanadditional5%,$10millionanadditional8%,etc.)
Themodulementalityhasworkedfor30someyearsinthisindustry,butitwon'tworkin
SOAwhenyourservicesarehostedbymultiplevendorsatmultiplelocations.Thisisthedirty
littlesecretbehindthesalespitchforSOA. Onceyourdataisontheirsystem,it'snotyours
anymore.Youhavetobuywhattheysellfromthatpointon,andpaythepricetheyask.Youno
longerhavecomputerscapableofhostingallthisstuff.Evenifyoudidyoucouldn'taffordthe
licensing.

3.4

HowDoWeFixThis?

WhenSOAisdoneinhouse,itrepresentswhattheprogrammersweretellingmanagement
theyneededallalong.Managementhasbeenunwillingtobearthecostofitinthepast,soI'm
doubtfultheywillbearthecostofitnow. Iftheyarewillingtobitethebullet,itcouldbeas
industrychangingastheinventionofthesemiconductorchip.
Tostartwith,thepiecesinyourexistingmodulesaren'tsmallenough. Theyneedtobe
muchsmallerthanyouwouldimagine.Everyfeatureinthatcustomermaintenancescreenhas
tobebrokenoutintoitsownservicethatwillacceptamessageandissuearesponse.Youhave
tostandardizewhatthosemessagesareandpublishtheirformattoallwhowillusethem.
Let'slookatthebasicfunctionality.Theveryfirstscreenfornewcustomerentryusually
acceptsthecustomername,contactinfo,address,etc.,priortowritingittothedatabase.Italso
doessomethingwhichgoesunnoticed. Itassignsauniquecustomernumbertothatcustomer.
Youshould split thisintotwoservices. Thefirst willaccept arequest foranew customer
numberandreturnit. Thesecondwillsendamessagewithallofthenewcustomerdata. It
won'tsendittoanaddcustomer service, itwillsendittotheupdate customer service.
Why?Becausetheservicesassigningtheuniquecustomernumberwillhavetocreatetherecord
in your database, unless you create a separate table which contains only unique customer
numbers. Thecurrentmoduleismostlikelylockingthecustomernumberithasduringthe
entry process, or waiting to request it at the time of record creation. If you take the last
approach, you can have an add customer service, but it must be capable of returning the

Chapter3WhatisWrongToday

23

customernumberbackinitsresponse,oranerrormessageiftherewasaproblemwiththeadd.
The update customer service gets a little trickier. In a traditional environment, the
modifyingapplicationreadstherecordandlocksitwhiletheuserismakingmodifications.The
applicationgenerallyhassomeformofbuiltinidletimeouttokilloffthelockiftheuserhasnot
entered anythingforawhile. Thisexiststopreventdeadlocksinyourdatabase. TheSOA
versioncannotoperateinthismanner. Whenauserwantstoupdateacustomerrecordfrom
someWebscreen,theyhavetosendarequesttothecustomerinquiryservicetoobtainthe
record,thensendamessagetotheupdatecustomerservicefortheupdatestobewritten.The
messagetoupdatecustomerhastocontainbeforeandafterimagesofthecustomerrecord.
Whydoestheupdatecustomerservicehavetogetbothcopiesoftherecordyouask?
Becauseithastohavebrains.Therecordwasnotlockedwhileitwasbeingmodified.Another
usercouldhaveusedtheservicetomodifyit.Theupdatecustomermodulehastoperforma
fieldbyfieldcomparisonofthebeforeimagewithwhatiscurrentlyonthedatabasetodetermine
iftherewereanychanges.Mostshopswillattempttobelazyatthispoint.Theywillsimply
returnanerrorandtelltheusertoretrieveagain.Thesmartshopswillapplythechangedfields
iftheirbeforeimagematchesthedatabasecurrentvalue.
Therearesomeschoolsofthoughtwhichsayyoushouldonlysendthebeforeandafter
imagesofthechangedfieldstoreducenetworktraffic.Theseschoolsofthoughtalsotellyouto
useXMLforthetransfer.Ifyoureallyareworriedaboutnetworktraffic,youdon'tuseXML,
youtransferbinarydataasitisthemostcompactandsecure. Binarydataiscertainlynotin
vogue,untilyoutalktopeoplewhohavetodoencryptedtransmissions.
YouuseXMLwhenyouneed thewidestpossibilityofacceptance. Knowthis: Every
servicewillhavetoparseandgenerateXMLifyouplantogothisroute.Youcannothavesome
oftheexternalservicesuseitandsomenotwhentheyareallpartofthesamebusinessconcept.
IftheupdatecustomerserviceisgoingtosendandreceiveXML,thenthecustomerinquiry
andcustomeraddservicealsomustuseit.Theyareallservicesrelatedtothesamebusiness
concept.GeneratingandparsingXMLisaprocessingoverhead.Whiletherearefreelibraries
suchasXerces,theirCPUandmemoryusageisnotfree.

24

Chapter3WhatisWrongToday

Wearenowseeingwhatsomerefertoasamiddlegroundbetweensecureencryptionand
theXMLusers.ThedatacontainedbetweentheXMLtagsisencryptedinatextualformat.The
vendorsofXMLtoolsaretryingtokeeptheirproductsrelevantintheworldofidentitytheft.
WhenIseeafiletransmittedinthismannerIamalwaysremindedaboutthedefinitionofan
elephant.Anelephantisamousedesignedtogovernmentspecifications.
WhenmovingtoaninhouseSOA,youmustmakeadecisionabouthowmanyinterfaces
youwishtoallow. IsthebulkofyourSOAgoingtobeforinhouseuseonlyoverasecured
network?Iftheanswerisyes,youdon'tneedXML.Thetokenfewserviceswhichtheoutside
worldcouldaccesscanuseXML,butsenditthroughsomeformofgeneralserverthatisbothon
thesecurednetworkandcapableofbidirectionalXML.Thepartofitthatcommunicateswith
theactualservicesyouhavehostedwillbecommunicatingusingbinaryrecordsormessages.
ThisisbyfarthebestimplementationbecauseyoucanensurenoWebpagehasdirectaccessto
yourcustomerdatabase. SQLinjectiontechniquessimplydon'tworkwhenthemessagebeing
sentisgoingtobeparsedintoabinaryorfixedwidthrecordthatgetspassedon.Thatserverin
themiddlewillneedsomeformofmaintenanceeverytimeyouaddinformationtotheoutside
world,butifwrittencorrectly,itcanignoreanynewfieldsyoudon'tallowtheoutsideworldto
see.

3.5

Today'sSOACamps

CurrentlytherearetwocompetingcampschampioningtheirvisionoftheServiceOriented
Architecture.Thefirstcampisrunprimarilybythelargepackagevendors.TheirvisionofSOA
isareturntothe1970scomputingmodel.Youpayonlyforthepiecesyouuse,butyouuseiton
theirmachines.Thismeansyouronlychoiceiswhattheysell,andtheykindoflikethatmodel.
Oursecondcampisrunprimarilybythesoftwarevendors.Yes,theyarepromotingopen
sourcetoolslikeJava,RubyandWeb2.0. Theyarealsopushingveryexpensivecommercial
middlewarewitheverescalatingsupportcontracts.Iftheycannolongersellyouthecompiler,
theyaregoingtosellyousomethingyoucan'tlivewithout.TheirviewoftheServiceOriented
ArchitectureisthatyouwritethousandsoflittleWebappswiththetoolstheyvendtodirectly
accessyourdatabasesfromtheWeb. Yes,theythinkitisagreatthing. Nothingbetterthan
beingabletoaccessyourcustomer'sprivatedatafromanywhereontheWeb.Alloftheselittle
serverswillbescatteredaroundtheworldandyouwillhookthemtogetheronapayperuse
basis. Theywilleachdoonelittlethingandreturnyoutheresult. ForgetaboutthatInternet

Chapter3WhatisWrongToday

25

beingfreestuff. Web2.0willbeacompletelycommercialpayperuseenvironmentintheir
mind.
Bothoftheseapproacheswillhavebillionsflusheddownthetoiletafterthem.Bothofthese
approacheswillruinlives.NeitheroftheseapproacheswillcreateasuccessfulServiceOriented
Architectureforyourcompany. We'vealreadydiscussedthemodulebymoduleapproach,so
let'stakealookatthesecondapproach.
PCandUNIXvendorscan'tgetenoughofdoingwhathasbeendonebefore,puttinganew
nameonitorprovidingsomeotherformofmarketingspin. Theyhaveconsistentlyrepeated
development blunders that occurred during the evolution of the mainframe and midrange
computingmarket.
Mainframesweredataislands,theydidn'tnetwork,thenmidrangecomputerscameoutand
wereabletocluster,somainframesgotbetteratnetworking. InitiallyPC'sweredataislands.
Theydidn'tnetwork. Thenpeoplestarteddevelopingfileserverssopeoplewouldn'thaveto
handwalkfloppiesaround,andtheystartednetworking.
Initially, mainframes and midranges didn't have databases. When data requirements
exceededthecapabilitiesofwhattheyhad,theygothierarchicaldatabases.Whenthelimitsof
thosewereencountered,theygotrelationaldatabases.Somecompaniesnowevenhaveobject
orienteddatabases.Initially,PC'sdidnothaveanyformofrecordsmanagementsystem.Itwas
arollyourownsituation. ThentheygotsomestandaloneproductslikethevariousXBASE
products.Nexttheygotagoodserverbasedproduct,Btrieve.Forthemostparttheyseemto
have skipped hierarchical databases and went straight to either relational or objectoriented
databasesnow.
Initiallymidrangeandmainframecomputersdidn'thaveanyquickmethodoftossingupa
data entry screen or writing a report. You had to code it all by hand in either a 3GL or
Assembler.Nexttheygotsomereportwritersandscreengenerators.ThentheygotCommon
DataDictionariesand4GLtools. PC'sinitiallydidn'thaveanythingusefulalongtheselines
either.Thentheycameoutwithabunchofdevelopmenttoolsets(notreally3GLandnotreally
4GL)andcodegeneratorsthatwouldaccess thedatabasetogenerate dataentryscreensand
reports.TheykindofskippedtheCommonDataDictionarythingbecausetherewaslittleinthe
way of organized code control or multitool development like midrange and mainframe
computers.

26

Chapter3WhatisWrongToday

When DOSfinallygave waytoa GUIversionof itself, thena reengineered GUI,this


developmenttoolsetconceptgotrecycledalloveragain.Reportgenerators,screengenerators,
you name it, all directly connected to your databases across the company network. Your
programs could now integrate with spreadsheets and a host of other things they couldn't do
before.
EntertheWorldWideWeb. Afteraperiodoftimegivingitaway forfree, itisbeing
redevelopedasWeb2.0,thecommercialversion.Makenomistake,whilesomepartsofthenew
Web will remain free, this is quickly becoming a payperuse business model. Guess what
conceptisbeingrecycled?Youbetcha!Awholebunchoftoolsetsandlanguagesthatwilllet
you directly (via commercial middleware) connect to your database from any Web page
anywhereintheworld. Allofyourinformationandyourcustomer'sinformationexposedto
whomevertriesanSQLinjectionorotherhackingtechniquefirst.
Whatisdifferentbetweenthenandnowisthenetworkandtherisk.Backaroundthetime
frameofDRDOS6.0andWindows3.1,networksdidn'thavealotofexternalexposure.True,
somecompaniesputpasswordprotectedmodemsonthenetworktoallowfullaccess,butmost
companiescommunicatedoverleasedlinesfromlocationtolocation.Thedevelopmenttoolsets
wereusedinhousebypeoplewhoalreadyhadaccesstothedata.
Don'tforget,hackersarealsopushingfortheServiceOrientedArchitecture.Theywantthe
verysamedatayouareobligatedtoprotect,passedaroundtheWebtoutilizeservicecomponents
whichwillbeoutthere.Ifyoutakethistothelogicalend,itmeansthatyourcustomercredit
applicationscreenwouldhaveanentryforSocialSecurityNumberandabuttonforCheck
CreditScore.TheSSNwouldbeputintoanXMLmessageandpassedtoaserverreturningthe
customer'screditscore.Oneofthreesituationswouldhavetooccur;
1) youraccountandpasswordwouldhavetobestoredonthemachinetobeincludedin
themessage.
2) Theuserattheterminalwouldhavetohavethisinformationandenteriteverytime,
eventhoughyoumakeuseofdozensofthesedifferentservicesonthatsamescreen.
3) TherawSSNwithallidentifyinginformationwouldhavetobepassedtotheservice
acrossaninsecureInternetconnection.
Anywayyousliceit,thingssuredon'tlookgoodfordatasecurity.

Chapter3WhatisWrongToday

27

OpponentsofwhatIsayherewilltrytotellyouI'mpaintingaworstcasepictureforyou
anditreallywon'tbethatbad.Well,asanITprofessionalIhavetoalwayslookattheworst
casescenarioanddefendagainstit.
TheargumentalwaysofferedupisyouwilllinkinthingslikeaGooglesearchtoyourpage
orsomeotherfreeservicewhichhasnosecurityrisk.Whileserviceslikethatarebothuseful
andfamiliarinthisdayandage,theydon'tcompletelyfulfilltheServiceOrientedArchitecture
mantra.
Companies headed down the path of developing a Service Oriented Architecture must
developwithasinglemindset.Alloftheservicestheydevelopmustbeopticallyisolatedfrom
theInternet.Anyserviceavailabletotheoutsideworldmustgothroughamiddleserverwhich
reformatsmessagesbetweeninternalandexternaluse.NeverdirectlyconnectaWebpagetoa
databasethathasanydatathatisn'tforpublicconsumptionanywhereinsideit.Eventually,the
toolthatmadeitsoeasyforyoutotossupthatpagewillhaveadesignflaworaprogramming
bugexploitedthatwillgiveanoutsidehackercompleteaccesstothedatabase.Mostofyouwill
havereadaboutSQLinjectiontechniques;theyareprettycommonplace.Therearealsobuffer
overrunsandahostofotherproblemsthatwillcontinuetosurfaceineachnewtrendytooland
beexploitedbyhackers.Becauseyoucannoteliminatethisproblem,youmustdesignitoutof
yourServiceOrientedArchitectureplans.
XMLseemstobethestandard(fornow)ofhowtheexternalworldwishestocommunicate.
That'sfine.UseXMLforthemessagescomingintoandgoingoutofthatserverwhichoptically
isolatesyourSOAcomponentsfromtheInternet.Useacompletelydifferentmessageformatfor
yourSOA components. PutallofyourXMLparsing outonthatopticallyisolatingserver.
Makeitcreateinternalconsumptionmessages,andtranslatetheinternalconsumptionmessages
itreceivesbacktoXMLfortransmissiontotheInternetuser.Whatevertechniquesthehackers
trytouseindoctoringupthosemessageswillbethwartedbytheconversionprocess.Eitherthe
parser will gag on it, or the internal consumption message will be garbage and your SOA
componentwillrejectit.Eitherway,you'vestoppedputtingyoursensitivedataatrisk.

28

Chapter3WhatisWrongToday

MovingtoSOAisabigbullettobite.Youhavetoovercomenotonly30+yearsofmodule
mentality,butofmodulegrowth.Asnewfeaturesandfunctionswereneeded,itwasfarsimpler
toaddafewlinesofcodetoanexistingprogramwhichalreadyhadallofthenecessaryfiles
open.Programsthatstartedoutaslessthan2,000linesarenowover30,000linesandgrowing.
They'vebeeninplacesolong,nobodyreallyknowseverythingtheydoanymore.Thebusiness
rulesthathaverunyourcompanyfordecadesareprimarilyforgotten,yettheyliveoninthe
code.

3.6

StartSmall

Pleaseallowmetoemphasizeonepointagain,startsmall. Thereisnopointintryingto
stuffacompletemoduleintoaservice. There isalsonopointintryingtostuffacomplete
programfromthatlogicalmoduleintoaservice.Itwillonlyendindisasterafteryou'vesunka
lotoftimeandresourcesintoit.
Remembermytinyexamplewiththecustomerfilemaintenancescreen? BreakeachIO
operationupintoitsownserviceasIinstructed. Oncethosearedone,createsomeformof
screentousethemfromyourinternalnetwork.Expandout,takingeachfunctiontheCustomer
Managementsystemdidandbreakitdownintoitssmallestlogicalcomponents.Makeeachof
thosecomponentsaservice. Establishaninterfaceforthem. Hookthemuptosomeformof
screen. Dothisinparallelwiththeexistingsystemuntilyouhaveitfunctioningthewayyou
want,thenturnofftheoldinterfaceandtrainusersinthenewinterface.
Chooseanothermoduleanddothesamething.Besuretodocumentwhateachserviceisin
your architecture and what its interface messages are. Eventually, you will find the people
creatingthescreensstarttoaddnewfunctionalitytothescreensbecausetheservicesarethere,
theyjustneededtobehookedtogether.
Howwouldthathappenyouask?Itdependsontheorderofmigrationyouchoose.Ifyou
startwithCustomerManagement,thenmovetoorderentryandinquiry,thentoseveralother
systems, by the time you get to inventory, you will probably be able to give the inventory
managerssomethingthey'vealwayswanted:Theabilitytoseewhatcustomersarebuyingan
item.Youwillprobablyhavealreadydevelopedaservicefortheorderinquirysystemthatwill
letcustomerservicefindanorderwithaspecificitemonit.Iftheserviceisdesignedcorrectly,
itwillfindtheordernumbersforanycustomerifthecustomernumberisn'tspecified.Thiswill

Chapter3WhatisWrongToday

29

givetheinventorymanagertheordernumberstheyneedandtheirscreenmightnowhavean
orderinquiryoptiononit.
Onceyouhaveallofthelowlevelservicesinplace,hookingthemtogetherbecomesthe
choiceofthescreendesigner.Youwillneedtoimplementpolicieswhichrestrictingaccessto
someinformation.Theinventorymanagerhasavalidreasonforwantingtoseewhatcustomers
arebuyingaslowmovingitem.Ifitiswalkinonlycustomerswhodolittlebusiness,theymay
wishtomaketheitemaspecialorderitem.Ifthecustomerissomeonetheyknowdoesalotof
businesswithyourfirm,theywillopttokeeptheiteminstocktoretainthecustomer'sbusiness.
Previously, the type of inquiry they needed to do was coded directly into the Customer
Managementsystem,whichtheydidn'thaveaccessto.Now,thepiecesofitthatareneededfor
themtodotheirjobproperlycanbeparceledout.
FromwhatIreadandhear,mostcompaniestryjumpingintoSOAwithbothfeet. The
industrymarketing...errr...analyststellthemitisthenextbigthingsotheythrowtheirresources
behindit. TheyissueamandatethatalloftheirsystemsmustemploytheSOAmodelbya
certaindate,thensitbackandupdatetheirresume.It'sagoodthingtheykeepthatresumeupto
date,becausetheyjustorderedtheirpeopletowalkoffacliff.

Chapter4

GreenScreensontheWeb
4.1

ObtainingaWebServer

You have a lot of options when it comes to obtaining and running a Web server for
OpenVMS. Toimplementthislittletrick,youneedtoactuallyruntheWebserveronyour
OpenVMSbox.IoptedtodownloadtheWASDproduct.Why?BecauseWASDdidn'trequire
metofilloutabunchofregistrationinformation. WASDcomestoyouinsourceformwitha
buildprocedure andinstallationprocedure. YougetaWebservercompileddirectlyforthe
installedlibrariesonyourmachine.
ThebestplacetostartlookingforyourWebserversoftwareiswww.openvms.org.Thisisa
greatsitefortheOpenVMScommunity.Onthelefthandsideofthemainpage,youwillfinda
NavigationmenuitemwordedsomethinglikeOpenSource&Freeware.Clickthatlinkand
lookaroundontheresultingpageforyourWebserveroptions.
Onceyouhavethefileunzipped,followtheinstructionstolaunchthebuildandinstallation.
DONOTSKIPANYSTEPS,eveniftheysaytheyareoptional. Duringmyfirstpassatthe
installationIskippedtheoptionalsecuritystep.BecausetheWebserverdidn'townanyofthe
filesinitsdirectorytree,itwouldn'tstart,butthetestonelaunchedduringtheinstallwouldwork
becausethatranundermyuserid.Yes,trackingthatdownwasafunhalfhour.GoodthingI
keepamassivescrollbackbuffer.
TheinstallationwillcreateanHT_ROOTdirectorytreeonthediskdriveyoutellittouse.
YouthenneedtocreatearootedlogicalnamedHT_ROOTsothingswillruncorrectly.
$ define/system/exec/trans=(conceal,terminal) ht_root dqa0:[ht_root.]
$ show log ht_root
"HT_ROOT" = "DQA0:[HT_ROOT.]" (LNM$SYSTEM_TABLE)

Afterthat,youarereadytolaunchyourWebserver.
$ @ht_root:[startup]startup

32
4.2

Chapter4GreenScreensontheWeb
ObtainingaWebTerminal

JavaAppletshavealotofsecurityrules.Toopenasocket,anAppletmustonlyopenthat
socketbacktoeithertheDocumentBaseorCodeBaseoftheWebservertheAppletwasloaded
from.UnlessyouhavethesitesetupasatrustedsiteortheJARcorrectlysigned,itwillnotbe
abletoopenlocalfilesordomuchelseonthesystemrunningtheWebbrowser.
Thankfully,someonedealtwiththeseissuesforyou. Youcanvisit http://javassh.org and
downloadaJavabasedVT320emulator.Touseit,youneedtocopytheJARfiletoadirectory
accessiblebyyourWebserver,thencreateanHTMLpagetoserveitup.Iputmineintheroot,
butyouprobablywanttoputyoursindifferentdirectoriessoyoucanhavealocal applet.conf
fileforeachapplicationyourun.
Terminalapplet.html
<html>
<body>
<applet CODEBASE="http://192.168.2.8"
ARCHIVE="jta26.jar"
CODE="de.mud.jta.Applet"
WIDTH=960 HEIGHT=560>
<param name="config" value="applet.conf">
</applet>
</body>
</html>

Ifyouarelikeme,youwillstumblearoundprettybaduntilyoufinallyfindthepageonthe
Websitewithagooddefault.conftocreateyourapplet.conffrom.Hereiswhatminelookslike.

Chapter4GreenScreensontheWeb

33

Applet.conf
#
#
#
#
#
#

-- IMPORTANT NOTICE -Copy this file when creating your own configuration and name it different.
default.conf is used by the software for initial setup. Your own config
may not need all the fields found in this file but only those you want
to change.
-- IMPORTANT NOTICE --

# =======================================================================
# common program defaults
# =======================================================================
plugins
=
Status,Socket,Telnet,Terminal
pluginPath
=
de.mud.jta.plugin
layout
=
BorderLayout
layout.Terminal
=
Center
layout.Status
=
South
layout.MudConnector
=
North
# help url/filename
Help.url
= /index.html
# =======================================================================
# Applet defaults
# =======================================================================
Applet.detach
=
false
Applet.detach.fullscreen
=
false
Applet.detach.immediately
=
false
Applet.detach.menuBar
=
true
Applet.detach.startText
=
Connect
Applet.detach.stopText
=
Disonnect
Applet.detach.title
=
Logikal Solutions Alpha
Applet.disconnect
=
true
Applet.disconnect.closeWindow
=
true
# to make Netscape behave good we would like to have some privileges
Applet.Netscape.privilege
UniversalConnect,UniversalPrintJobAccess,UniversalSystemClipboardAccess
# =======================================================================
# Socket defaults
# =======================================================================
# This is set to the webserver by default.
Socket.host
= 192.168.2.8
Socket.port
= 23
# for SSH use the port below
#Socket.port
=
22
# =======================================================================
# Timeout settings
# =======================================================================
Timeout.seconds
=
60
Timeout.command
=
exitn
# =======================================================================
# Terminal defaults
# =======================================================================
Terminal.foreground
=
#ffff00
Terminal.background
=
#000000
Terminal.cursor.foreground
=
#000000
Terminal.cursor.background
=
#ffffff
Terminal.print.color
=
true
Terminal.border
=
2
Terminal.borderRaised
=
false
# if you use your own file use a fully qualified URL!
Terminal.colorSet
=
/de/mud/terminal/colorSet.conf
Terminal.scrollBar
=
West
# now the real terminal configuration
Terminal.id
=
vt320

34

Chapter4GreenScreensontheWeb

Terminal.buffer
=
5000
Terminal.size
=
[132,34]
Terminal.resize
=
font
Terminal.font
=
Monospaced
Terminal.fontStyle
=
plain
Terminal.fontSize
=
12
# if you use your own file use a fully qualified URL!
Terminal.keyCodes
=
at386.keycodes
# /de/mud/terminal/keyCodes.conf
Terminal.VMS
=
true
Terminal.IBM
=
false
# the setting below should be correct, but it does not work
#Terminal.encoding
=
ISO8859_1
# the setting used it probably incorrect but forces the default behaviour
Terminal.encoding
=
latin1
#Terminal.beep
=
http://www.mud.de/se/jta/BOUNCE.WAV
# =======================================================================
# MudConnect defaults
# =======================================================================
MudConnector.listURL
=
http://www.mudconnector.com/java/Telnet/javalist.db
# =======================================================================
# MudConnect defaults
# =======================================================================
Capture.url
= Configure this URL!

Thisterminalhasawaystogo.ItdoesseemtohandletheVT320escapesequencespretty
well, but it has no support for the numeric keypad. Most of the keys are controlled by a
keycodesfile.Youmaynoticethatthefileisspecifiedintheapplet.conffile.Ihighlightedthe
lineabove.Onmydualcore64bitAMDmachinerunningUbuntuLinuxGutsydistribution,
itseemstogiveadequatetypingperformance.Someofthekeysaren'tcurrentlyopenedupfor
redefinition.ItismostinfuriatingthattheNumLockkeyhasn'tbeenopenedupbecausethisis
the key most of us define to be the GOLD key. The fullsource code is available on the
downloadpage,so,anyonecouldaddthesupportforthisandreturnthecodetotheauthors.

Chapter4GreenScreensontheWeb

35

Theaboveimageshowstheterminal.Yes,thescalingdownmadethetextquitehardtoread
inthisbook.Itisprettyreadableonmyterminal.Youdohavetogetusedtoclickingonthe
terminalbeforelogginginsincetheappletdoesn'tgetfocusuponload.

4.3

IsThisSOA?

Theshortanswerisno.Itisawayforyoutoavoidpayinglargefeesforterminalemulation
programsandawayforyoutoletemployeesloginremotelyfromanywhere.AsIstated,the
emulatorneedssomework.
ThelongansweristhatmostmanagersbelieveanythingthatcanbeaccessedfromaWeb
page isSOA. Because mostofthemareprettyclueless whenitcomestotechnology,only
hearingbuzzwords,youmustletyourownethicalthresholdguideyou.

Chapter5

ACMSFundamentals
5.1

WhyAreYouOnlyHearingAboutACMSNow?

Thisisprobablyaveryvalidquestion. ACMSappearedinthe1980s. ItwasaBestin


Classsoftwareproduct.Therewereseveralmajorstrikesagainstitthough.Firstandforemost,
ithadtheworld'sworstmarketingcampaign.Thiswasahorribletimeintheindustry.DEChad
letMBAsgetintothecompanyandMBAsthoughttheycouldmanageanything.Naturally,they
wanted to manage the sales and marketing since that meant traveling to parties and having
expenseaccounts.Theydidn'tactuallyknowanythingaboutwhattheyweremarketing,butthat
didn'tstopthemfromtryingtomanageit.
ThesoftwareengineershadmanagedtokeeptheMBAsoutofthesoftwareandproduct
developmentprocess. Theydidn'tmanagetokeepthemoutofthepackagingsideofthings,
HencethedisasterswhichhappenedinthePCmarketforDEC.Thedutifulsoftwareengineers
werebusilylooking30yearsintothefutureandplanningforwhattheindustrywouldneed.
Theysawtheultimateuseoftheirdistributedclusterasbeingdistributedfaulttoleranttasks.
TheycreatedACMS.
MBAscouldn'tevenunderstandthecluster,sotheyhadcompletelypassedoutbythetime
theengineersfinishedspellingoutwhatACMSmeant. Engineeringwentthroughalengthy
presentationonthefeaturesandbenefits. Finally,attheend,oneoftheengineersshookan
MBAtowakethemup. Astheygroggilycameto,theyheardthephraseIt'souranswerto
CICS. Thatonephrase, becametheentiretyofthemarketingcampaign,which,ifmemory
servesme,lastedaboutthreeweeks.Onceagain,itwasuptotheengineersanddocumentation
topushaproduct.
Yousee,CICShadbothbatchandinteractivetransactioncontrol,butalmostnobodyknew
aboutthebackendcontrols.EverybodyontheblueboxesseemedtobeusingCICSforscreen
interactionandleavingthebackendalone. ThebeautyofACMSwasitscapabilitiesonthe
backend.Thecompletetoolforaserviceorientedarchitecture.

38

Chapter5ACMSFundamentals

WhenpeoplestartedbuyingtheVAXStationsoftheday,theyfoundtheboxestobeboth
priceyandextremelyunderpowered.Loadingthemupasfulltimeclustermemberstousethem
asintelligentterminalsmuchliketheIBM3780wasforCICS,reallyboggedtheseboxesdown.
Theywereoriginallydesignedfordeveloperstowriteandtestcodebeforemovingituptothe
development cluster. They were also designed for the document processing market.
VAXStationscamewith20inchmonitorslongbeforemostothercomputershadthem.Atthe
time,theextremeendofthePCmarketwasusing17inchmonitors. Somepeople(notme)
actuallylikedWPSfordocumentwritingandcreation.Lettingtheseuserssharedocumentsona
cluster,butworklocallywasamajorbenefit.Italsodramaticallyreducedlicensingfees.
Yousee,theproblemwasinthatlastphrasetheMBAsheard.Sincetheyuseditfortheir
marketingcampaign,customerstriedtousetheproductlike CICS. Thehardware DEChad
availableforthedesktopatthetimecouldn'tbeafullclustermemberandgiveadequateresponse
timetousers. Theseboxescamewith1Gigharddrivesthathada17or21msseektimeif
memoryservesmecorrect.Largefortheirday,butveryslow.Pagingmemoryinandoutwas
extremelytimeconsuminganditdegradedresponsetime.Memoryfortheseboxeswas(andstill
is)quitepriceysomostbuyersskimpedonRAMandgotthebiggerdisk.
Had the MBAs never heard that phrase, we would have been doing ServiceOriented
Architecturebackinthelate1980s.Indeed,somecompaniesdidsetupservicesthiswayback
then.TheyarestillusingACMStoday.
Oddlyenough,IBMisnowmakingamassivemarketingpushforthebackendservices
CICS canprovide. ItisbecomingacornerstoneoftheirSOAofferings. Ifyoucanlivewith
knowingyourmoatandfortresscanbetakenoutbyanynumberofnaturaldisastersorterrorist
acts,itisdefinitelythebesttoolonthatplatform.HPdoesn'tseemtobemakingthesamepush
withACMS.TheyhavehadTPWebConnectorandTPDesktopConnectorforquitesometime.
The major drawbacks for both of these products is they currently only support Microsoft
operatingsystems.BecausetheTPDesktopConnectornowhasitslicenseincludedwithACMS,
itwouldbesweetbeyonddescriptioniftheyaddedsupportfor64bitUbuntu Linux onAMD
boxes.

Chapter5ACMSFundamentals
5.2

39

FlowDescription

ACMSwasdesignedtouseaslittleorasmuchoftheentireclusterasyouchoosetogiveit.
WhenoperatingintheCICSstyleusingDECForms,oneormorelightweightnodescanhandle
theformsprocessingwhileoneormoreseriouslyequippedbackendnodeshandlethebulkof
thetransactionalprocessing.Thetheoryatthetimewasthatcustomerswouldbuyseveralless
expensiveVAXStationmachinestohandlealloftheformsandbuythehigherhorsepowerVAX
modelsforthebackend.WhateventuallyhappenediswealllearnedtheVAXStationsweretoo
underpoweredfortheamountofusersbusinesseswishedtorun.
Fromanarchitecturalstandpointthiswasagranddesign. Itjusttookalongtimeforthe
hardwaretocatchupwithit. Intoday'sworldyouthinknothingofusingyourdesktopPCto
enterdataonaWebform,thensubmititoffforbackendprocessing.Itwasahardsellinthe
'80s.
WhiletherealtimeaspectsofACMSwereatechnicalmarvel,thecompletelyoverlooked
queueing capabilities were jaw dropping. Terminal IO (real time) requests were normally
handledwiththeRI(RequestorInterface)librarycalls.IfyoudidnotwishtouseDECForms,
youcouldusetheSI(SubmitterInterface)tocreatearealtimeinterface.Youcouldalsousethe
queueingfacilitytosubmittasksforlaterprocessing.
Thequeueinginterfacecouldgiveyourealtimeresponse,dependingonsystemload.Either
yourtaskorthemessagehadtocontaininformationaboutwheretosendtherealtimeresponse.
Normally,whenI'mdoingthiskindofdevelopmentIuseMQSeriesfortheexternalmessaging
so the entire system has endtoend guaranteed delivery. The real beauty of the queueing
interfaceisthattheACMSapplicationitselfdoesn'thavetobeavailable.Aslongastheentity
whichqueuedthetaskcanhandledelayedresponseinsomemanner,youaregolden.
ManywhoaretakingtheinitialstepstowardsSOAonlywishtolookatrealtimesolutions.
Theyhavecompletelyforgottenaboutthevastquantityofactivitiesthatareadelayedprocessby
theirverynature. Toomanypurchaserealtimeonlysolutions,thenfindthemselvestryingto
makeeverythingfitintotherealtimemethodology.

40

Chapter5ACMSFundamentals

Thinkforaminuteabouthowyouplaceanorderonline. Youpickandchooseitemsfor
yourshoppingcart. Atsomepointyouchoosetocheckout. Atthepointofcheckout,the
shippingchargesandtaxarecalculated,apaymentmethodischosenandverified,thentheorder
issubmitted.
Upuntilwegettothesubmittedstage,youneedrealtimesolutions.TheSIinterfacecan
givethattoyou.Thesubmissionportionisbyitsnature,adelayedresponsetask.Atsomepoint
apickingticketwillbegeneratedforthewarehouse(s).Theproduct(s)willeventuallybepicked
and packed. Once they enter the packed stage, a shipping label and notification will be
generated.Mostcompaniessendtheshippingnotificationviaemailtoday.Emailisadelayed
responsecommunication. Thepickingandpackingare delayedresponseactivities. Because
everything thatwilloccur after the submittingis a delayedresponse activity,you shouldbe
queuingthetaskforordersubmission,nothandlingitinrealtime.
The distributed nature of ACMS and its process flow makes it ideal for SOA
implementation. BoththeSIlibraryandthetaskqueueingcapabilitygiveyouallofthetools
youneedtoprocessinformationfromyourWebinterface.

5.3

GeneralPrincipals
ACMSworksontheACIDprinciple:Atomic,Consistent,Isolated,Durable.

Foratransactiontobeatomic,itmustbestructuredinsuchawaytoprovideanallornone
completion.Ifatransactionfails,nopartofitcanbeleftaround.ThisiswhyACMSintegrates
withDECdtm.Anyindexedfileyouaregoingtoupdateormodifyneedstobeanhave RMS
journalingenabledsoDECdtmcanworkitsCOMMITandROLLBACKmagic.
Consistencyisprovidedbytheapplicationdeveloper.Itmeansyourtransactionconsistently
appliesthesameadditionsorupdatesinthesamemannereverytime.Ifyouhaveabuginyour
programwhereyouperiodicallyskipupdatingsomefieldsinadatabaseorindexedfilerecord,
thenyourtransactionisinconsistent.

Chapter5ACMSFundamentals

41

Isolationisauniqueconcept.Notsomuchuniqueasitisdifficultforalotofmodulebased
developerstounderstand. Itisnotuncommonfortheretobejobsinacustomermanagement
systemthatperformabulkupdateoftelephoneareacodes. Duringthelate1980sandearly
1990stelephonecompanieswentonaspreeofcreatingnewareacodes. Inpartitwasdueto
populationgrowth,andtheotherpartwasthattheydidn'tinitiallyallocateareacodesforcell
phonesandpagers. Nobodyknewhowsuccessfulthenewtechnologywasgoingtobe. You
wouldnotmakethistypeofjobpartofyourSOA.Itisstillthetypeofjobwhichmustberunin
batch during a maintenance window. Earlier I gave you an example using just the
entry/maintenanceportionofthecustomermanagementsystem.SplittingtheIOoperationsso
thateach wasan independent IO process. Thisishowyouobtainisolation. Itensures the
transactionscanrunhoweverthetaskmanagerdispatchesthem.
Durability soundsreallygood,butmeansnothingmorethanthechangestoyourdatabase
arepermanentuponcompletionofthetransaction.Youaren'tgoingtosuccessfullycompletethe
transaction,thenrollitback.AdhocSQLupdatesdon'tfallintothedurabilityclass.Youare
experimentingwiththoseuntilyoufindtheupdateyoulike. Thenandonlythen,wouldyou
issueacommit.
The primary concept behind ACMS is restartable units of work. Each transaction is
consideredaunitofwork. Unitsofworkaredispatchedtotasksinserversthatperformthe
work.Ifaserverdies,foranyreason,theunitofworkwillbedispatchedtoanotherserveronce
DECdtm has done its cleanup. This cycle will continue until the unit of work has been
dispatchedasmanytimesasyouconfiguredoritcompletes.Assumingyouhaveamalformed
messageorabuginyourservercode,theunitofworkwillendupgettingplacedonanerrors
queue.Youmustthenhaveameansofeithermanuallyjunkingthismessage,orfixingitandre
queuingittothecorrecttaskqueue.
Nosystemcanbefaulttolerantorclaimtoofferclusteredtransactionswithoutadistributed
transaction manager built into the operating system kernel. This transaction manager also
providesdurabilitywhenyourmachineisrunningasanindependentsystem.Ifyoustartaunit
ofworkinACMS,thensufferacatastrophicpowerfailure,DECdtmautomaticallycleansthings
upwhentheoperatingsystemisstarted. Thereisnomanualsweepup. WhenyourACMS
applicationstarts,theentrieswillstillbeonthequeueforittoprocess.Ihavefoundnothingelse
in the marketplace thatcan honestlymake this claim. The thirdparty transaction managers
requiremanualintervention,orsimplylosethetransactionwhichwasbeingprocessed.

42

Chapter5ACMSFundamentals

Letustakealookagainatthefewcustomermanagement transactions wehavealready


talkedabout.Wewillassumeyoumadethechoicetohaveaseparatecustomeraddservice.
Thenewuniquecustomernumberwillbegeneratedeitherdirectlybyyourservice,orlogicbuilt
intoyourrelationaldatabase.Oncethenewcustomernumberisgenerated,thenewrowisadded
tothetable. Theresultoftheaddandthecustomernumberwillbeplacedontheoutbound
messagequeuebacktotheprogramorscreenthatrequestedtheservice.
Thistaskisisolated. Itmayverywellfailontheaddifthere are otherconstraintson
columnsintherowandtherequesterdidnotprovidethecorrectdata,butitisisolatedfromother
transactions.Eveniftwoaddoperationsattempttostartatthesametime,theresultwillonlybe
aslightdelay.
Howabouttheupdatetransactionwetalkedabout?Yourservicerequiresboththebefore
andafterimage. Ifyourprogrammerisn'tlazy,theycanperformanintelligentupdate. This
handlesthecase ofanotheruserupdatingthecreditlimitorstatuswhilethecurrent useris
changingtheshippingaddress. Whatyoucannothaveisalazyprogrammerwhojustblindly
updatestherow. Theycanonlydothisifthebefore imagematchesthecurrentrowinthe
database. Yourexistingapplicationgotaroundthisproblembylockingtherowuntilitwas
done.WedonotwishtoallowaWeborotheroutsideoperation,whichmaysimplygoaway,to
havealockonarecordinourdatabase.
Tomakethesetransactionssecure,theymustnotconsistofdynamicallyparsed/interpreted
SQLstatements. EachSQLinteractionmustbeprecompiledandlinkedintothetask. There
can be no calls to any PREPARE function/method which dynamically compiles an SQL
statementbaseduponanyuserinput.ThisruleeffectivelystopsallSQLinjectiontechniques.

Chapter5ACMSFundamentals
5.4

43

IORoutines

Twodecadesago,whenIstartedoutinIT,wewereallinstructedtouseIOroutinessothe
underlyingstoragemethodcouldchangewithoutimpactingourapplication. Thiswasagreat
idea,butithadsomeflaws.
The first flaw was the nature of the languages themselves. Every language on robust
businessplatformsincludeddirectaccesstothestoragemethodsonthatplatform.Inthecaseof
VMS(laternamedOpenVMS),thismeantthateverylanguagehadbuiltinextensionsforRMS
indexedfileaccess.WritingIOlibraryroutineswasalotofworkanddidn'tprovidemuchinthe
wayofimmediatepayback.
Asecondflawwaserrorhandling. IactuallyworkedatashopthatusedIOroutinesto
encapsulatefileaccess.EveryoneofourmajorindexedfileshadanIOroutineandanassigned
channelnumber. Everydeveloperwasrequiredtousethoseroutines. Intheory,wehandled
everyconceivableerrorinsideofthoseroutines.Sadly,onlythecommonerrorswereactually
tested.WewereworkingwithDECBASICatthetime.EveryroutinereturnedtheBASICerror
codeforthoseerrors forwhichBASIChadanerrornumber. WhathappenedwhenBASIC
didn'thaveacorrespondingnumberforthaterror? Youbetcha! Wereturnedthe RMS error
codeandtheapplicationhadtodealwithit.
WhywereweusingIOroutinesinthefirstplace?Becausetheapplicationwasoriginally
writtenforSingercomputers.Goodluckfindinginformationaboutthemtoday.Thevendorof
theapplicationwantedtobeabletojumptoanewplatformaseasilyaspossible. Theyjust
didn'tlooktoocloseatwhatwereturnedwhenBASICdidn'thaveanerrorcode.Then,theygot
pressuredbycustomerstocomeoutwithaUnixversionoftheproduct.TheUnixplatformin
questiondidn'thaveaBASICcompiler,ordidn'thaveonewithanywherenearthecapabilitiesof
theDECBASICdialect. So,theyusedacommercialtranslatortoconvertfromBASICtoC.
Thatwentwell...NOT!
Ofcourse,thoseofyouwhoreadTheMinimumYouNeedtoKnowtoBeanOpenVMS
ApplicationDeveloperknowwhatcamenext. Clientcompanieswantedarelationaldatabase
version.IOroutinesareaniceidea.Implementedcorrectlytheycanletyousurvivehardware
architecturejumps.Theycannotletyousurvivestoragearchitecturejumps.

44

Chapter5ACMSFundamentals

Indexedfilesofthedaycontained multitypedrecords. Thismeantalloftherecordsfor


somethinglikeanorderweregroupedtogetherinonefile. Itwasfast,efficientandtheway
thingsweredoneonmostbusinessplatforms.Relationaldatabasesmakeyoustoreeachofthe
recordtypesinaseparatetable.Thelogicinyourprogramwasacompletedooverevenifthe
IOroutinecouldhandleit.
ThoseofyouwhothinkwehaditbadshouldtalktosomefromtheIBMcampwhowent
fromISAMtoVSAMtoahierarchicaldatabasetofinallylandinarelationaldatabase.Every
changewasadoover. Overthecourseofthepastdecadeorso,vendorsofobjectoriented
databaseshavebeentryingtogetustoswitchagain.Theirproductshavemerit,butwearetired
ofdooversandnoteverylanguagecandirectlysupportanobjectdatabase.
Onethingyouwillhearmostdatabasevendorshawkingnowisstoredprocedures.While
I'mcertainsomecompanieswilljumpinwithbothfeet,thatisarecipefordisaster. Youare
locked into that database from the first day you put your stored procedure into production.
Storedprocedurestendtobeveryvendorspecificwiththeirmethodofinvocation,development
andresultsets.Haveyoueverbeenonaprojecttoportanapplicationfromonedatabaseto
another? Ihave. IOroutinesmighthaveactuallysavedus,buttheyweren'tused. Thepast
historyofgettingburnedbythemhasmostcompaniesavoidingthem. RDBisoneofthefew
databases with external SQL Module compilation. This was done so the database or the
architecturecouldchangeoutpainlessly.Naturally,mostotherdatabasevendorsdon'tprovide
thiscapability.

5.5

TheMajorPieces

ACMSdevelopmentmustbedonefromtheinsideout. Whenitoriginallycameout,this
wasthemostconfusingtraitaboutthedevelopmentcycle.Nowthatweareinthemiddleofthe
SOAwave,thisisthecommondevelopmentmethodology.EveryoneissettingupWebpages
linking to a bunch of services that already exist somewhere. ACMS has the same design
methodology.

Chapter5ACMSFundamentals
Application
ADF

username
LogicalNameTableSearchList
CDDdefinitions
Otherdetails
Group

GDF

CDDdefinitions
3GLInitializationmodules
3GLTerminationmodules
ServerDefinitions
Task
TDF

CDDdefintions
3GLProceduremodule
Task
TDF

CDDdefintions
3GLProceduremodule
Task
TDF

CDDdefintions
3GLProceduremodule

Task
TDF

CDDdefintions
3GLProceduremodule

45

46

Chapter5ACMSFundamentals

ThediagramontheprecedingpageisattemptingtoshowyouthatanACMSapplication
consists of a group of servers. Each server must have one initialization procedure and one
termination procedure. A server may have many task procedures (or as I call them later
Procedureprocedures). Foryourownsanityandthesanityofanydeveloperfollowingyou,I
humblysuggestyoudon'tputmorethanonetaskinanygivenserver. Beforeyoucanbegin
developing the ACMS portion of your application, you must choose a 3GL programming
language and code each Init, Term and procedure for each server so each compiles into a
separateobjectfile.No,youcannotuseJavaorsomeotherinterpretedlanguage.
Iftheserveryouareassignedtocreateweretobecalledfoo_serv,thenyouwouldneedto
create FOO_INIT_PROC.OBJ, FOO_TERM_PROC.OBJ, and FOO_PROC.OBJ. I put the
_PROCwartinmyfilenameswhendevelopingACMSsoIdon'taccidentallyblastanOBJfile
duringcompilationbyhavinganamecollisionwithoneoftheACMSsourcefiles.ThereasonI
doitnowisbecauseatonetimeIdidn't,thenIhadsomerealfuntryingtotrackdownaproblem.
Itlinkedjustfine,buttheserverkeptdeployingitselfratherthanexecutingtheprocedureitwas
supposedtoexecute.Atleastuntiltheusernametheserverwasrunningunderranoutofquota,
thenitdiedahorribledeath.
Eachserverinitializationprocedureneedstodothefollowing:
Createauniquelynamedlogfile

Attachtothequeuemanagerforanymessagingsystem(likeMQSeries)

Mapontoanyglobalsectionsyouareusing
Initializeanyglobaldatathatcouldbeusedbytheapplication

Connecttoanydatabasesthatwillbeneeded
ReturnanaccuratecompletioncodetoACMS

Eachserverterminationprocedurehasthefollowingresponsibilities:
Closeanymessagequeuesthatmightstillbeopen

Disconnectfromanyqueuemanagertheinitializationprocedureconnected

Disconnectfromalldatabases
Freeallmappedglobalsections

Closelogfile

ReturnanaccuratecompletioncodetoACMS

Chapter5ACMSFundamentals

47

The responsibilities listed for the initialization and termination procedures need to be
performedinexactlytheordertheyarelisted.Thelistofresponsibilitiesshouldmakeitpretty
apparentwhyItrytokeepeachservertoonetask.Ifyouractualprocedureissimplyprocessing
arawdatapacketitgetsviasomeTCP/IPserviceonaport,thenyoucouldputasmanytasksas
youwantinaserver. Ifyouareusingsomeformofmessagequeuingforreliablemessage
delivery,thenyoureallywanttorestricthowmanytasksyoubundleintoaserver.
ThefirstACMSsourcefileyouneedtoconcernyourselfwithhastheextensionTDF.This
istheTaskDefinitionFile.Eachtaskismeanttoencompassasinglerestartableunitofwork.It
definestheworkspace(ifany)thatisusedbythetask,thetaskitselfandtheactionstoperform
dependingonhowitcompletes.Thereisnologichere.Whilethereisaparticularsyntax(which
wewillgointolater),thisisnotyetanotherprogramminglanguage. Theprocedure(s)you
definehereareallthenamesofobjectmodulesyouhavewrittenandcompiledinyour3GLof
choice. Aseachtaskgetscompiled,itputsinformationinto CDD (CommonDataDictionary
nowownedbyOracleCorporation).ThatinformationisusedbytheGDFwhenitcompiles.
Ataskshouldnotestablishanydatabaseconnections.Allofthoseconnectionsneedtobe
handledbytheinitializationprocedure. Feelfreetowriteanylogmessagesorcreateanylog
filesyouwishinatask,butdonotestablishnewconnections. Ataskisconcernedwithan
update,aread,awriteoradelete.ThegreyareahereiswhenyouhaveRMSindexedfilesused
forreference.Youshouldopenthemintheinitializationprocedure,butyoucouldmakeacase
foropeningthemonanasneededbasissincetheywon'tbeupdated.
Whydoestheserverestablishallconnectionsduringitsinitializationprocedure?Toensure
allresourcesareavailabletothetask. Ifadatabasehastobeshutdownforsomereason,the
serverwillthengetshutdownbecauseallconnectionsmustbeclosed.Thiswillbeanorderly
andgracefulexit. Anyadditionalentriesqueuedforthisservertoprocesswillremainqueued
untilanewserverisbroughttolife.Itisalittlethingwecallreliability.
Pleasepaycarefulattentiontothewording.Isaidconnections.Ididnotsaytransactions
orcursors. Eachtaskwillneedtocreateatleastoneofthosewhendealingwithadatabase.
SomeconnectionsarecreatedbehindthesceneswhenyouusethingslikeSQLMODsoyouneed
tobecareful.

48

Chapter5ACMSFundamentals

A GDF (GroupDefinitionFile)definesallofthe WORKSPACES,returnvaluemessage


filesandserversthatwillbegroupedtogetherinyourapplication. Eachserverneedstohave
threeproceduresdefinedforit:

Initializationprocedure
Terminationprocedure
andforlackofabettername,theProcedureprocedure.

Youonlyhaveoneinitializationandoneterminationprocedureforeachserver,butcould
havemanyproceduresfortheserver.Italldependsonhowmanytasksyoudecidetobundlein
theserver.AGDFfilealsodeclareswhichtasksarepartofthisgroup.Thatdeclarationiswhat
retrievesthetaskdefinitionfromCDD.
Mostdeveloperswillwriteallthreeoftheseproceduresatthesametime.Theyarerather
tightly integrated. I have seen developers write a single, well written program with a
housekeepingsection,anapplicationsectionandaterminationsection;testit;thensplititupinto
three separate compilation modules. I've actually ported programs to ACMS in this exact
manner.
OnceyouhavegottenyourGDFtocompilecleanly,youcanwriteyourADF(Application
DefinitionFile).AfteryoulookatthesourceforaGDFfile,itmayseemtherecouldbenothing
lefttodefine,butACMSisafinelytunedsystem.TheADFfileiswheremuchofthattuning
takesplace.Hereyoudefinethelogicalnametablesearchpathfortheapplication,theusername
underwhichitwillrun,andtheattributesforeachserverintheapplication.
Attributesmaybeasomewhatconfusingtermbecauseitissooverusedinthisindustry.
Therearemanythingsthatcanbeconfiguredonaserverbyserverbasis.Someofthemarethe
logfile,theerrorfile,theminimumandmaximumnumberofserversandthegroupdefinition
theserverbelongsto.Whileitisnotagoodpractice,youcould,intheory,declareserversofthe
samenameindifferentgroupfilesandmakebothgroupfilespartoftheapplication.Ihumbly
suggestyoudonottryit.

Chapter5ACMSFundamentals

49

Wehaveonlyonerealdrawbackwiththeapplicationdefinition.Itdefinesthenameforthe
applicationasitwillbeknownbyACMS. ThatnamewillbeknownclusterwidebyACMS.
YoucannothaveaproductionversionofMY_ACMS_APPrunningononenodeinthecluster
and a development version running on a different node. To ACMS they will be multiple
instancesofthesameapplicationanditwilldispatchworktowhicheverapplicationhasafree
server at the time it gets work to dispatch. I have been to places where people did this.
Productiondatawenttothetestsystemandthenbackoutagain.Inonecase,adeveloperwas
tryingtotestamodificationtotheorderprintingsoitcouldhandlea12digitdollarvalue.That
orderslippedintoaproductionsystemattheendofamonthandthewarehousepickedtheorder.
Theresultofthisdrawbackisthatweneedadifferent ADF fileforeachenvironmentor
yourbuildprocedurehastomodifytheapplicationnameinthissourcefilewhenitisbeingbuilt.
Eitherapproachcanbejustified,ashardasthatmaybetoswallow.Weshallseewhatneedsto
bedonelaterinthisbookwhenwegettothecodingportions.
Fromadevelopmentstandpoint,wehavecoveredthemajorcodingpiecesrequiredbyall
ACMSapplications.Thereareenvironmentalandconfigurationthingsthatwewillgetintoafter
wedevelopourACMSapplication.EveryapplicationmustbeinstalledinACMS.Youneed
todefineandauthorizeauserwithinACMS(mostnotablyforoperatorlevelcontrol).Youalso
needtocreateandactivateatleastonequeue.Allofthosethingswillbecoveredlater.

5.6

WhichTypeofACMSApplication?

Aswediscussedearlierinthisbook,therearetwomaintypesofACMSapplications.The
firstistheinteractiveterminaltypeandthesecondisthedetachedprocessorbatchtype.Fora
briefperiodoftime,manyoftheterminaltypeapplicationswererunningontheWeb.Theyhad
usedthe DECForms screenproductwithaWebinterfaceproduct. Forwhateverreason,HP
decidedtheWebinterfaceproductshouldn'texistanymore.
Whileitmayhavebeennicetohavetheexistinggreenscreenapplicationalreadyuponthe
Webinsomefashion,itcertainlywasn'tSOA.Therewasstillamoduletypementalitytothe
application. Thecustomermanagementsystemwehavebeentalkingaboutwasstillasingle
entity.Generallythetasksweren'tsplitupenoughsothattheycouldbeusedbyentitiesoutside
oftheapplication.

50

Chapter5ACMSFundamentals

Thedetached processtypeofapplicationfitsmuchmore cleanlyintotheSOAlifestyle.


Eachtaskdoesonlyonethingandcanbecalledfrommanyplaces,providedyouchoseaproper
methodofcommunication.Youmayenduphavingtoprovidebothsetsoffunctionalityinside
ofthesameapplication.Itiscertainlynotunheardof.Onceataskhasbeenqueued,QTIdoesn't
reallycarewhereitcamefrom.Alloftheuserandrightsvalidationoccurredpriortotheentry
beingwrittentothetaskqueue.QTIwilldispatchthetask.Ifyoudon'tunderstandhowsecurity
workswithinOpenVMS,thatmaysoundstrangetoyou,butallofyouaresupposedtohaveread
TheMinimumYouNeedtoKnowtoBeanOpenVMSApplicationDeveloperbeforereading
this.
Wewillexperimentwithdifferentanswerstothisquestionduringourjourneythroughthis
book.

5.7

Security

AveryshorttimeagoItoldyouthattheADFcontrolledwhichusernametheapplicationran
under(bydefault). Youdon'trealizeityet,butthatisamassiveplusintheworldofSOA.
Insteadofhavingtogranteachandeveryuseraccesstofilesandtables,youcangrantasingle
known user (the user under which the ACMS application runs) all of the rights identifiers
needed. Youthenonlyneedtoensurethattheexternalcommunicationoccursviaatrusted
source.
Wehavemanymoremethodsofensuringthattrustthanmayfirstbeapparent. Tostart
with,SOAneednotbedeployedviatheInternet,itmayexistonlyonanintranet. Wecan
mandateallexternalcommunicationoccurvia MQSeries, whichmeanseachqueuehastobe
authorized to connect to our queue manager. We could choose a roll your own TCP/IP
connectionorsomethingelse.Wearealongwayfromcoveringtheexternalsecurity.Internal
security is provided by the DODcertified operating system named OpenVMS. The only
operatingsystemtobebannedfromeverreappearingatthenationalblackhatconferences.Yes,
itisthatsecure.

Chapter5ACMSFundamentals
5.8

51

TheMarchForward

I'mgoingtostartoutshowingyouthebadwaybecausethatiswhatyourmanagementwill
pushyouinto.WewilldirectlyconnectJavatoanRDBdatabase.Afterthatwewilldevelopa
smallorderentryapplicationusingACMS.
WhileitmayseemlikeoverkilldevelopingsuchasmallapplicationtoACMS,andthe
directdatabaseviaJavamayseemthemoreexpedientroute,directlyconnectingdatabasesto
JavaapplicationsrunfromaWebbrowserisnotagoodidea.Ihavesaiditbefore,andIwill
beatuponitprofuselythroughoutthisbook.Adirectlyconnecteddatabase,nomatterwhatkind
offrontendyouputonittoblockSQLinjectionandotherattacks,willstillbevulnerable.
Managementfallsvictimtomarketingandtheirunnaturaldesireforaquickwinwhenit
comestomonumentalundertakings.Manyofyourmanagerswillprobablyrunoutandpurchase
aproductlikeReactivitybecausethemarketingliteraturesaysitblocks SQLinjection attacks.
Well,itdoes,justlikeavirusscannerblocksviruses.Itblocksallofthosetechniquesitknows
about. All you have to do is read the news to understand that a new virus effects tens of
thousands,ifnotmillions,ofcomputersystemsbeforethereisanewsignatureorvirusscanner
patchavailable.
Whatisdifferentbetween SQLinjectionandviruses?Intent.Someonelaunchingavirus
intotheworldislookingtoeitherdamageyourPCforfun,installakeyloggertosnagallofyour
account/passwordinformationforsale/useorturnyourmachineintoazombietheycanrentout
forattacks. Inotherwords,younoticetwoofthevirusesmainintents. Yourmachinestarts
runningreallysloworyounoticealotofnetworkactivitywhichtellsyousomethingisrunning
onityoudon'tknowabout. Thoseintentofwipingyourmachinemakethemselvesapparent
eventuallyaswell.
AnSQLinjectionattackisdoneprimarilytoexposeyourdata.Identitytheftisabigticket
item today. Insurance companies are making fortunes selling insurance against it and the
attackersaremakingmillionswiththedatatheyget.Thereintentistogainenoughcontrolover
yourdatabase(s)togleanallofyoursensitivecustomerinformation.Thereintentistoremain
undetectedforaslongaspossibleminingandusing/sellingasmuchaspossible.

52

Chapter5ACMSFundamentals

Letmetellastorytoyouwhichwasfirsttoldtomebackinmycollegedaysbyaprofessor.
Myapologiesifyouhaveheardthisstorybefore.
BeforewehadtheInternet,wehadmodemaccesstosystems. Alotofcompaniesdidn't
think much about data security. Some went so far as to use a modem with an embedded
passwordinit.Othersjustusedanoddcommunicationssettingsohackerswouldn'tbeableto
connectproperly. Whiletherewerethosewhowoulddutifullytrytoguessapasswordand
account name once they found a system, the most reliable method of gaining access was
dumpsterdiving.Kidswouldactuallygototherecyclingorotherdumpstersatlargecompanies
anddigthroughthetrashlookingforsoftwaremanuals. Themanualsweren'ttheinteresting
portionthough. Mostuserswouldwritetheiraccountandpasswordinthefrontoftheuser
manualforasystem.Whentheygotanewmanual,theyrarely,ifever,changedtheirpassword.
Whatisinterestingaboutthisstoryisitisrumoredtohavebeenanelectriccompanythat
tookthehit. Notinbillingwhereonewouldexpect,buttheinstallation/repairsdivision. The
kid(s)foundinformationthatletthemgetintothissystem.Oneofthemhadarelativeofsome
kindwhowasanelectrician.Thenewinstallationgrouphadaverydetailedbidaccountonline.
It kept all of the contact information, components, text of the layout and amount bid. The
biggesthelpwasthatfromthereyoucouldactuallyplaceaworkorderforequipmentdeliveryto
ajobsite.
The way they chose to make money was to follow the electric company around to the
companiestheyhadjustdonebidsforandmaketheirownbid.Allofthesameequipment,but
30%cheaper. Oncetheygotthecontract,theywouldhavetheequipmentdelivered,dothe
work,andcollectthemoney.Theynevergotbilledfortheequipment.Itwentonforquitea
whileuntilaninventoryauditturnedupwhyaccountingwassofaroutofbalance.Eventually
theywerecaughtandprosecuted.
Iftheprecedingstoryisn'tyourbiggestfearwithSOA,itshouldbe.Rightnow,companies
havemanagedtoavoidgoingtoprisonoveridentitytheft.Thatwillmostlikelychangewiththe
nextpresidentialelection.Thebiggerfinancialimpactforacompanyanditsshareholdersisthe
story above. What if your company routinely ships product to job sites rather than only
customers?Ifyounormallydo$4050million,theycouldprobablyhityoufor$23millionper
yearforaverylongtime.Therealkickeris,youwon'tbeabletoprosecutethemwithoutgoing
publicwiththestory. SometimesIponderjusthowmanycompanieshavebeenhitlikethis,
foundoutaboutitandburiedthelossratherthanprosecuting.

Chapter5ACMSFundamentals

53

Sadly,mostofyouwillbeforcedintoa LAMParchitecturebecausesomeMBAsawa4
colorglossyonitorisstupidenoughtofollowtheadviceoftheIndustryMarketing...errImean
Analysts. (Don'tevengetmestartedaboutthosedaftenoughtoactuallypayforthatadvice.)
LAMP tends to be defined as Linux, Apache, MySQL, PHP. It also happens to include
PostgreSQL,Perlandbasicallyanyotheropensourcetoolonthemarket.(Wedon'tcurrently
haveabuildofPostgreSQLforOpenVMS.)OnethingIhavenoticedatclientsitesthatclaimto
beimplementingLAMPisthattheywriteaboatloadofJavacode,butyoudon'tseeJavalisted
anywhereintheacronymtranslations.
Consider once again the commercial tool you or your company purchased to provide
securityandcontroloutsideconnectionstoyourLAMParchitecture.I'msuretheemployeesat
thecompanyslavedawaypluggingeveryknownSQLinjectiontechnique.Justhowbigofan
informationpooldoyouthinktheyhadtoworkwith. Otherthanthewhitehatsspoutingoff
aboutwhattheydiscoverontestsystems,howmuchinformationcouldtheyhavehadtowork
with?TheprimaryintentofanSQLinjectionattackistogounnoticedforaslongaspossible
stealingasmuchdataaspossible.Howmanycompaniesouttherearewillingtogopublicwitha
storyaboutsomeoneclippingthemfor$512milliondollarsoverthecourseof312years?
AfunnythingishappeningwithXML.YourememberbackwhenXMLcameoutandwe
allusedDTDsdon'tyou?Thiswassupposedtobesogreatbecausethelengthofthedatacould
changeandnothingelsehadto.ThisisexactlywhatleftthedooropentoSQLinjection.Now
everyoneismandatingyouuseaschemaandsetthemaximumlengthattributeforalltagsthat
could/willbeusedinanSQLexpression.Wehavealmostmovedbacktocompletelyproprietary
dataformats,butwearetoostubborntoadmitit. Yes,fixingthemaximum(andminimum)
lengthofonetoNtagsinaschemaiseasierthanupendingaproprietaryrecordformatsoyou
canexpandafieldwhichdoesn'thappentobethelastfieldintherecord.Manyofthebenefits
havewentawaythough.

54

Chapter5ACMSFundamentals

ThereisnowaytoavoidXMLintoday'smarket. Companieshavesunktoomuchinto
buyingparsersanddevelopingstandards. Letmebeatthisdeadhorseonceagain. UseXML
betweenexternalsourcesandaproprietaryfixedformattocommunicatewithyourbackend.
This one simple act, while creating some maintenance work on your part will protect you
99.99999%fromSQLinjectionattacks.Theonlyloopholeishavingacolumninyourdatabase
thatisusedforselectioncriteriaandissufficientlywidetoallowaninjection.Youcanweedout
alotmorebysettingtheattributesforyourselectioncolumnsinyourXMLschematoonlyallow
AZ,azand09.
I'mnotdissingthecommercialfrontendsthatcontrolaccessandprovidelotsofdifferent
kindsofsecurity.I'mtellingyoutoknow,inyourheartofheartsasadeveloper,thattheywill
failatsomepointandyourcodeisthesecondlineofdefense.Writeitwisely.

Chapter6

OurFirstSteps
6.1

DecidingontheMethod

AtthispointinthebookitisassumedyouhavereadTheMinimumYouNeedtoKnowto
Be an OpenVMS Application Developer ISBN 0977086607. It is also assumed you
understandboththeapplicationandthefundamentaldevelopmentconceptsontheOpenVMS
platform.WhileitisnotrequiredthatyouhavereadTheMinimumYouNeedtoKnowAbout
Java on OpenVMS Volume 1 ISBN 0977086615, it is highly advisable. We will be
stealingsomeconceptsandsourcecodefromthatbookduringthecourseofthisbook.
Managementdoesn'tunderstandSOA.TheyjustwanttosaytheyhaveimplementedSOA,
wantitdoneyesterdayandwantittouseJavasoitcanbesupportedbystudentandtouristVisa
workerstheyarepayingthroughathirdparty.Asfarasmanagementknows,ifyoucanrunit
fromtheWeb,itmustbeSOA.
YourfirstcutatthiswillbetosimplyputitontheWeb.It'snothowyouwanttodoit,but
youknowitwillworkandthattheoffshoreteamwon'tbeabletosupportit.Whilemanywill
saythatisabadandevilthingforyoutodo,puttingtheentireapplicationonsomeinsecureWeb
serverusingamishmashofJava+Ruby+Ajax+trendoftheweekisanevenevilerthingtodo.
Youarelookingoutforthesecurityofyourcustomer'sdata,thoseusingtheothertoolsetaren't.
ThecorrectmethodistofirstporttheapplicationtouseACMS.OnceyouhavetheACMS
serversrunningusingtheexistinginterface,setupTCP/IPportservicestoexposethoseservers
orMQSeriestocommunicatewiththem.Virtuallynobodyisusingthecorrectmethodtoday.

56
6.2

Chapter6OurFirstSteps
DirectDatabaseAccessviaRemoteJava

Imightaswellstartoffshowingyoutheworstpossiblewayofdoingit.Thisisgoingtobe
whatyourkneejerkbossasksyoutodo.Itiswrong,soverywrong.Wewillstartoutsmalland
workourwayforward.
ToreallyunderstandthissectionandtherestofthechapteryouneedtohavereadThe
MinimumYouNeedtoKnowAboutJavaonOpenVMS ISBN0977086615.Iwillbere
usingthingsfromthatbookthroughoutthischapterandnotcoveringthemagain.
The firstsmallstepwe need totake isensuringwe can access the RDB database from
outsidetheOpenVMSmachine.TodothisIcopieddownrdbThin.jarviabinaryFTPtransferto
thesoa_worksubdirectoryonmyUbuntumachine.ThenIcopieddownTestRdb.javaviaatext
transfer.BecausethatprogramrequiredafewmodificationsIwilllistthefinalversionbelow.
TestRdb.java
/*
** The bulk of this code was stolen from RDBJDBCCHECKUP.JAVA which
** you will find in the RDB$JDBC_HOME directory when you install
** the RDBJDBC driver.
*/
// You need to import the java.sql package to use JDBC
import java.sql.*;
import java.io.*;
class TestRdb
{
public static void main(String args[])
throws SQLException, IOException, Exception
{
int l_x;
System.out.println( "Obtaining classname");
Class.forName ("oracle.rdb.jdbc.rdbThin.Driver");
String driverConStr = "jdbc:rdbThin://192.168.2.8:1701/";
System.out.println("Please enter information to test connection to the database");
String user;
String password;
String database = "MEGA_DB_RDB";
user = readEntry("user: ");
password = readEntry("password: ");
System.out.print("Connecting to the database...");
System.out.flush();
System.out.println("Connecting...");
Connection conn = DriverManager.getConnection
(driverConStr + database, user, password);

Chapter6OurFirstSteps

57

System.out.println("connected.");
// Create a statement
Statement stmt = conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rset = stmt.executeQuery("select * from drawing_data limit to 10 rows");
while (rset.next()) {
for (l_x=1; l_x <= 7; l_x++)
System.out.print(rset.getString(l_x) + "\t");
System.out.println( " ");
}
// Go back to top of cursor
//
rset.first();
System.out.println( "\n\nRetriving via column names");
System.out.println( "Draw_Dt
\tNo_1\tNo_2\tNo_3\tNo_4\tNo_5\tMega_No");
System.out.print( rset.getString( "DRAW_DT") + "\t");
System.out.print( rset.getString( "NO_1") + "\t");
System.out.print( rset.getString( "NO_2") + "\t");
System.out.print( rset.getString( "NO_3") + "\t");
System.out.print( rset.getString( "NO_4") + "\t");
System.out.print( rset.getString( "NO_5") + "\t");
System.out.println( rset.getString( "MEGA_NO"));
while (rset.next()) {
System.out.print( rset.getString( "DRAW_DT") + "\t");
System.out.print( rset.getString( "NO_1") + " \t");
System.out.print( rset.getString( "NO_2") + " \t");
System.out.print( rset.getString( "NO_3") + "\t");
System.out.print( rset.getString( "NO_4") + "\t");
System.out.print( rset.getString( "NO_5") + "\t");
System.out.println( rset.getString( "MEGA_NO"));
}

// close the result set, the statement and connect


rset.close();
stmt.close();
conn.close();
System.out.println("Your JDBC installation is correct.");

// Utility function to read a line from standard input


static String readEntry(String prompt)
{
try
{
StringBuffer buffer = new StringBuffer();
System.out.print(prompt);
System.out.flush();
int c = System.in.read();
while (c != '\n' && c != -1)
{
buffer.append((char)c);
c = System.in.read();
}
return buffer.toString().trim();
}
catch(IOException e)
{
return "";
}
}
}

58

Chapter6OurFirstSteps

While it may seem like I'm just taking up space in this book, here are the differences
betweentheprogramwehavenowandtheonefromthelastbook.
$ diff TestRdb.java ref_dir:
************
File DEV_DSK:[HUGHES]TestRdb.java;1
11
******
File MEGA_ROOT:[CMS_REF]TESTRDB.JAVA;1
11
import com.logikal.OpenVMS.routines.*;
12
13
************
************
File DEV_DSK:[HUGHES]TestRdb.java;1
19
System.out.println( "Obtaining classname");
******
File MEGA_ROOT:[CMS_REF]TESTRDB.JAVA;1
21
String driverConStr = "jdbc:rdbNative:";
22
VMSLogical db_logical = new VMSLogical();
23
24
System.out.println( "Obtaining classname");
************
************
File DEV_DSK:[HUGHES]TestRdb.java;1
22
String driverConStr = "jdbc:rdbThin://192.168.2.8:1701/";
23
******
File MEGA_ROOT:[CMS_REF]TESTRDB.JAVA;1
27
driverConStr = "jdbc:rdbThin://localhost:1701/";
28
************
************
File DEV_DSK:[HUGHES]TestRdb.java;1
27
String database = "MEGA_DB_RDB";
28
******
File MEGA_ROOT:[CMS_REF]TESTRDB.JAVA;1
32
String database = db_logical.firsttrans( "MEGA_DB_RDB");
33
************
Number of difference sections found: 4
Number of difference records found: 7
DIFFERENCES /IGNORE=()/MERGED=1DEV_DSK:[HUGHES]TestRdb.java;1MEGA_ROOT:[CMS_REF]TESTRDB.JAVA;1

Thefirstdifferenceyouwillnoticeisthatweremovedthelibrarywecreatedinthelast
book. BecausetheplatformwhereexecutionoccursisnotOpenVMS,wecannotuseanyof
thoselibraryroutines. Thatsameremovalleadtothedifferencesfoundatlines27and28. It
alsoleadtothehardcodedIPaddressyouseeinthedriverConStr.Yes,Icouldhaveprompted
theuserforthatjustlikewedidforthepasswordandusername.Thatwon'tbethecasewhen
youconvertthiscodetoanappletthough. Anappletwillneedtoconnectbacktothehostit
camefromsoyouwillneedtopassitasaparameter.

Chapter6OurFirstSteps

59

NoticethatweareusingadifferentJDBCdriveraswell.WhenrunningonOpenVMSwe
usedthenativedriver,whichcontainsalotofCcodeforspeed. HereweusethepureJava
driver.ThisdriverconnectswiththethinserverontheOpenVMSmachine.
TocompilethisonUbuntuIhadtocompletesomesetup.Myfirstsetupstepwastoinstall
SunJava6.ThedefaultonUbuntuisaGNUJavaimplementation.ThismeansIhadtodosome
tweakingbecausethatimplementationremainsthedefaultevenafteryouinstallSunJava.
Note:IissuedthecommandexportPS1=Ubuntu:>tochangemypromptforuseinthis
book.ThedefaultUbuntupromptisuser@node:path$.Whilethatisveryinformative,when
usingOpenOffice,oranyothercurrentwordprocessorpastingsomethinglikethatingenerally
causesittobehighlightedasamailto:link.MostUnix/Linuxbookswillsimplyusea$forthe
prompt,butgiventhatisthedefaultpromptonOpenVMSIoptedtousethispromptsoitwould
beclearwhichplatformwewereusing.
Ubuntu:> sudo update-java-alternatives -s java-6-sun-1.6.0.03
Ubuntu:> sudo gedit /etc/jvm

Ichangedmyfiletolooklikethefollowing:
#
#
#
#

This file defines the default system JVM search order. Each
JVM should list their JAVA_HOME compatible directory in this file.
The default system JVM is the first one available from top to
bottom.

/usr/lib/jvm/java-6-sun
/usr/lib/jvm/java-6-sun-1.6.0.03
/usr/lib/jvm/ia32-java-1.5.0-sun
/usr/lib/jvm/java-1.5.0-sun
/usr
/usr/lib/jvm/java-gcj

Ifyouareunfamiliarwiththesudocommand,itallowsyoutotemporarilybecomethe
rootuseronmostformsof Linux,ifyouenterthecorrectpassword. Intheoryyoucoulduse
java6sunintheupdatecommandbecausethatlinkissupposedtofloatbetweenallupdates.I
rebooted aftercompletingtheabove justtomake certain allthingswere usingtheSunJava
platform.GeditisthedefaulteditorwhenyouinstallthedefaultUbuntuconfiguration.Ituses
theGnomedesktop.IfyouinstalledKubuntutheeditorwouldbeKate.

60

Chapter6OurFirstSteps

We still have just a little work to do on Ubuntu before we are ready for development.
Compilingwillgojustfine,butrunningwillhaveissues:
Ubuntu:> javac TestRdb.java
Ubuntu:> java TestRdb
Obtaining classname
Exception in thread "main" java.lang.ClassNotFoundException: oracle.rdb.jdbc.rdbThin.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at TestRdb.main(TestRdb.java:20)

Tofixthisproblemweneedtoissuethefollowingcommand:
Ubuntu:>export CLASSPATH=.:/home/roland/soa_work/rdbThin.jar

NoticethatIseparatedthe.forthecurrentdirectoryfromthepathtomyJARfilewitha
colon. This is a Unix thing. Actually both the . for the current directory and the colon
separatorareUnixthings.
Ubuntu:> java TestRdb
Obtaining classname
Please enter information to test connection to the database
user: hughes
password: **************
Connecting to the database...Connecting...
connected.
2005-06-24 00:00:00.0
14
43
44
50
56
2005-06-28 00:00:00.0
2
20
37
43
46
2005-07-01 00:00:00.0
14
25
41
42
50
2005-07-05 00:00:00.0
22
38
48
50
55
2005-07-08 00:00:00.0
9
23
45
48
50
2005-07-12 00:00:00.0
5
17
32
39
53
2005-07-15 00:00:00.0
9
13
25
36
48
2005-07-19 00:00:00.0
7
13
48
51
54
2005-07-22 00:00:00.0
7
18
27
35
54
2005-07-26 00:00:00.0
1
10
18
29
55
Retriving via column names
Draw_Dt
No_1
No_2
2005-06-24 00:00:00.0
14
43
2005-06-28 00:00:00.0
2
20
2005-07-01 00:00:00.0
14
25
2005-07-05 00:00:00.0
22
38
2005-07-08 00:00:00.0
9
23
2005-07-12 00:00:00.0
5
17
2005-07-15 00:00:00.0
9
13
2005-07-19 00:00:00.0
7
13
2005-07-22 00:00:00.0
7
18
2005-07-26 00:00:00.0
1
10
Your JDBC installation is correct.

No_3
44
37
41
48
45
32
25
48
27
18

No_4
50
43
42
50
48
39
36
51
35
29

No_5
56
46
50
55
50
53
48
54
54
55

7
4
40
29
3
36
2
11
34
8

Mega_No
7
4
40
29
3
36
2
11
34
8

Chapter6OurFirstSteps

61

You'venowtakenyourfirststeptomakingRDBonOpenVMStherelationaldatabasefor
yourentirecompany.IsthisanSOAimplementation?No,itisclientserver.BoththeJARfile
andtheJavaprogramwerestoredonthePCIwasusing.ItdoesprovethatyoucanhitRDB
fromanyofthesecheapplatformsMBAsareallgagaoversothereisnoreasontoabandonthe
mostrobustdatabaseplatformontheplanet.
ThereareafewthingsIneedtomention.ThedefinitionofCLASSPATHandthechangeto
the terminal prompt will not survive a log out nor will they be available in other terminal
windowsyouopenunlessyoueditthefile.bashrcfoundinyourhomedirectorytoaddthese
statements.Iamassuming,ofcourse,thatyouareusingthedefaultbashshellonUbuntu.There
aretwoseparatefileswhichperformwhatLOGIN.COMdoesforusonOpenVMS.Thesecond
fileisalsofoundinyourhomedirectoryandisnamed.profile.Therearecommentsatthetopof
bothaboutthekindsofmodificationsyoushould/canmaketoeach.Inthecommentsyouwill
alsofindanexplanationofwhatgetsrunforaninteractiveloginversesabatchordetachedlogin.
Whenyouenteryourpassworditwillactuallybevisibleonthescreen.Ieditedoverthat
part when pasting it into this book. I didn't use any fancy classes orfunctions to hide the
password. Ifyouare lookingtodothatwhenpromptinginconsolemode,youcan usethe
followingsnippet.
java.io.Console cons;
if ((cons = System.console()) != null) {
char[] passwd;
passwd = cons.readPassword("[%s]", "Password:");
password = new String( passwd);
}

PleasenotethatthisonlyworksinlaterversionsofJava. BecauseI'musingJava6from
Sun,itworks.Thedrawbacktothisapproachisitdoesn'tprintanycharacters,sotheuserhasno
ideahowmanykeystheyhaveactuallyhitiftheyaren'tatouchtypist.Thepromptingsequence
looksasfollows:
Ubuntu:>java TestRdb
Obtaining classname
Please enter information to test connection to the database
user: hughes
[Password:]

62

Chapter6OurFirstSteps

So,youdidallofthestuffItoldyoutodoandyoureceivedsomeformofconnectionerror.
Youranitmultipletimesandareabsolutelypositiveyoutypedthepasswordcorrectlyforyour
account.Well,youdid.YousimplyforgotaboutafewthingsfrommyJavabook.Thefirst
thingyouforgotwastosubmitthefileLAUNCH_JDBC_SRV.COMtobatch.Thesecondyou
forgotwaswhatportyouusedinLGKL_RDBJDBCCFG.XML.ImustadmitthatforthisbookI
changedtwolinesinthatfile;notbecauseIhadto,Ijustthoughtitwouldsavepaindownthe
roadifmymachinewasrebooted.
autostart = "true"
autorestart = "true"

Intheprevious bookIhadleftthemsettofalse because weweren't connectingfrom


outsideofthesystem. BecauseIwouldalwaysbeloggedinandhadthestartupfileinmy
directory, there was no reason to make certain the JDBC services were up and running for
anyoneelse.Inaproductionenvironmenttherearereasons.Youmightevenwanttoaddthe
launchcommandfiletoyoursystemstartup.
Pleasekeeptroubleshootinguntilyouhaveatleastthismuchworking. Makecertainthat
yourLOGIN.COMfileisdefininganylogicalsyouneedtoaccessthedatabaseyouwant.Once
youcansuccessfullyaccessRDBfromUbuntu,youarereadytoproceed.

6.3

SomeThoughtsonEditors

We will assume that you obtained a CD or downloaded Ubuntu and took the default
installation. ThismeansyouareusingtheGnomedesktopinsteadofKDE. Therearemany
moredesktopsavailableforLinux,butthesearetwoofthemostwidelysupported.Indeed,their
supportingcampscontainwhatmostwouldcallreligiousextremists.
WhenusingGnome,thedefaulttexteditorisGedit.KDEprovidesKateasitsdefaulteditor.
Bothoftheseeditorshavesyntaxhighlightingandconfigurationoptionsthatmakethempassable
fortheamountofcodingwewilldointhisbook.Ifyouareusedtomorepowerfuleditorsfrom
otherplatforms,therearemanyoptionsavailabletoyou.

Chapter6OurFirstSteps

63

IfyouareanoldhandonOpenVMSwhonevermovedfromEDT,thereisevenhopefor
you.SomepokingaroundonSourceForge.netwilllocateanEDTcloneforXwindowssystems.
ItisdistributedinsourceformwithaREADME.TXTfilethatexplainshowtocompileand
configurethekeypad. Thedefaultmappingscertainlyaren'twhatInormallyconfigurewhen
settingupaVTemulator,butthereisaprocessforchangingsuchthings.Ididn'tdigthroughthe
productenoughtoseeifitsupportscommandslikeF=PASTE,butfeelfreetospendyourtime
doingthisifyouwant.WhatI'mpointingoutisthatyoucanremainprettyclosetowhatyouare
usedtoifyoureallywant.
WhenbeingforcedtoworkwithJavaorPerl,Iprefersyntaxhighlighting.Sometimesitis
evennicetohavewhenworkingwithC/C++. Thedefaulteditorsof Gedit andKateprovide
syntaxhighlighting. Theyevenletyouturnonthingslikelinenumbersandconfigureother
settings. Idon'tcareforthecolorschosen. ItseemsthatUnixdevelopersandthoseonthe
derivativeplatformsneverlearnedwhatweonOS/2andotherplatformslearned. Comments
shouldbegreenandtheyshouldbetheonlygreencolorinyoureditor.
BeforeanyoneleapstodefendthecolorchoicesfoundintheeditorsImention,orpointsout
thatyoucanchangeallofthem,letmementionportability.AsasoftwareconsultantImakeita
pointtonotchangemuchwhenIarriveataclientsite.WhileImayaddafewlinestotheLSE
startup,Iwon'tcompletelyreconfigureaneditorpreloadedontotheboxI'vebeengiven.Imay
pulldownafreeeditorwhichisrunfromalocaldirectoryifthatisallowed;butotherwise,I
attempttoconformtotheenvironment.Why?BecauseI'matourist.Mycontractthereisgoing
toendatsomepointandthecode/environment needstobewhattheemployees are usedto
seeingorworkingwith.
ThenicepartaboutworkingonUbuntuisthatthereisabsolutelynoneedwhatsoeverto
purchaseacommercialeditor. IfyouaregivinguponeofthoseothercrummyPCoperating
systems put out by some company in Washington state, then you no longer have to spend
hundredsofdollarsoneditorslikeSlickEdit.Herearesomethingsforyoutolookat:
BluefishEditor
Geany
jEdit
MadEdit
SciTE

64

Chapter6OurFirstSteps

Illustration6.1.

Chapter6OurFirstSteps

65

The image on the preceding page isthe editor I've worked the least withwhile onthis
platform.I'mgoingtocoveritfirstbecauseofoneverynicefeatureithas.Noticethecolumn
betweenthelinenumbersandthesourcecode?Whenyouclickononeofthoseboxeswitha
dashinit,thespanofcode/commentsbetweenitandthematchingenclosurefolds/hidesandthe
boxwillthenhaveaplussigninit.TheeditorwearelookingatiscalledGeany.Itisfreeand
oneyoushouldseriouslyconsiderwhenchoosinganeditoronthisplatform.

Illustration6.2.

66

Chapter6OurFirstSteps

Bluefish isaneditorthatalotofpeopleswearby. Theoriginalmarketitwasserving


appearstohavebeenHTMLdevelopers.Somehowthisopensourceprojectistiedinwiththe
OpenOfficeproject.Incaseyouweren'tpayingattentionearlier,thisbookisbeingwrittenwith
OpenOffice.Ihaven'tusedBluefishenoughtobegoodwithit,but,likemostofthegraphical
texteditors,youcanbeabumblingidiotandstillgetyoursourcecodeentered. Bybegood
withitImeanperformcomplexsubstitutionsorsubstitutionsacrossmultiplefiles.Inshort,the
kindofstuffwedidwithEDT_MASS_SUB.COM.

Illustration6.3.

Chapter6OurFirstSteps

67

SciTEisaverycapableeditoronthisplatform.Yes,GeditisthedefaultandIuseitalot
because of that, but SciTE has some endearing qualities. For one it has the comments
highlightedingreenoutofthebox.Thiswasobviouslyaneditorwrittenbyprofessionalswho
knowwhattheyaredoing.Configuringthingsontheeditorcantakealittlepokingaround.It
usesoptionfiles. WhenyouinstalltheeditorviatheSynapticPackageManager,theglobal
optionfilewillbeownedbyrootsoyouwon'tbeabletoaccidentallychangeit.Youcanlookat
itandcopythingsfromitintoyouruseroptionsfile,thenchangethevaluesthere. AtfirstI
foundthisabother,butafterusingtheeditorforawhile,Ithinkitismoreconsistentwiththe
LinuxphilosophyandhowweconfigureLSEonOpenVMS.Sofarmypersonalconfiguration
filelookslikethis:
strip.trailing.spaces=1
tabsize=4
indent.size=4
use.tabs=0
indent.auto=1
indent.automatic=1
indent.opening=0
indent.closing=0
line.margin.visible=1
font.base=$(font.monospace)
font.small=$(font.monospace)
font.comment=$(font.monospace)
font.text=$(font.monospace)
font.text.comment=$(font.monospace)
font.embedded.base=$(font.monospace)
font.embedded.comment=$(font.monospace)
font.vbs=$(font.monospace)
save.recent=1
save.session=1
buffers=30
position.width=800
position.height=800

Thegeneralruleofthumbisthat1turnssomethingonand0turnsitoff.GiventhefactI
believealltextshouldlineupinaprogrammingeditor,youwillseeIseteverythingtousethe
configuredmonospacefont.Onethingyouneedtobeawareofwithgraphicaleditorsisthat
theydon'talwaysuseamonospacedfont.Manyofthemwilltrytouseapredeterminedpoint
sizewithaCourierfont.Itwilllookasifthingslineup,untilyouchangethepointsize.
Oneofthemoreinterestingeditorsintheworldoffreeis MadEdit. Youcanfinditon
SourceForge.AsfarasIcantellitdoesn'tcomeonanydistributionsofLinuxbydefault,butit
isaverycapableeditor.Oneofthebestthingsaboutitisyoucantryitrightnowonyouricky
Windowsbox.Onceyougetusedtoit,movingtoUbuntuwon'tbesuchacultureshock.

68

Chapter6OurFirstSteps

Illustration6.4.

You have been reading a free preview. Please visit


http://www.theminimumyouneedtoknow.com to learn more about
this award winning technical book series and where it can be
purchased.

You might also like