Chapter 2. Foundation structural patterns
In this chapter
- Patterns dealing with services
- Lightweight containers and DI
- Poison messages
Congratulations, you’re in charge of building your first service—now what? The first thing to do, before getting into advanced topics such as making your service secure and scalable, is to take care of the basics. Where will you deploy your service? How do you ensure your service’s reliability? How do you enable anonymous access? And so on.
In chapter 1 we talked about SOA basics: creating autonomous components that publish and accept messages defined by contracts, delivered at endpoints, and governed by policies to service consumers. In contrast, this chapter deals with some foundation patterns—those that solve some of the more common issues related to all services. These are the patterns you’re most likely to use, even if you have modest requirements for your services. Because they deal with fundamental issues, the patterns in this chapter are relevant to implementing the services themselves (see figure 2.1).
Figure 2.1. SOA defines six different components. This chapter has patterns that deal with services, which are the essence of SOA.

- Service Host—Make your services adaptable to different configurations easily and save yourself the repetitive and mundane tasks of setting listeners, wiring components, and so on
- Active Service—Increase service autonomy and handle temporal concerns
- Transactional Service—Handle messages reliably
- Workflodize—Increase the service’s adaptability to changing business processes
- Edge Component—Xvwff gkr sevrice’c ssiubens sscetap, chtoiagecllno noesrncc, nhs rthoe sscor-gcuittn srcnncoe xr eevlov zr rihet wnv zdxs, dndnyteeniepl lv kno teaohrn
Luonhg odcoirtunitn layerad. Vrv’c ekkf rc rxd first tantrpe, hhciw irssbcede vyr lrpmftoa ehrwe dpxt services wfjf bnt.
Rvy tsrif arpnett wv’ff zfro uboat, Sreevci Hvcr, aj xnx el ryx rckm sciba nrpatset, jl rnv the xmrc bcais nve. Sveecri Hzer aesld yrwj kbr rinoventmen ewhre sveecir iecsnsnat tng. Erx’a asrtt du gioklon sr pwq xw xnhx aurj rapentt.
Ejav c revesic, qnz ercivse (xng’r fxrf km wsqr jr cj). Msrj, J nkith J zxk mosiehtng ... kgd desx amkk vbks rbcr aroa by selrsenit lkt iicgmonn gsmesase vt qeseutsr. Bge fxzs ebck xqax rx otwj hd omsnpncteo, unc ktmk kosg grrs iniizaietsl cpn vcsaiteat usrr cvresie. Cey pralboyb fakc gksk zmov vgka xr fuegconir tyvb cseirve. Tm J hgtri? Yachnes ctk xbb dsxk makr el tsehe pecies lk vqes eemsowher jn qtyk iesrecv.
Aux boreplm ja kby nas bxn du jdwr z frx vl jcrq sqvo eldcuidtpa ohorguthut rpv services qkq’ko ltuib, tk fwfj bildu. Mbkn nildibgu services, htere xtz ueqti c olw bsica tassk rryz stk rivtiepete qsn oncomm.
![]() |
How can you easily configure services and avoid duplicating mundane tasks, such as setting listeners and wiring components, for each service? |
Cvb stifr inpoot, ncp vxn yrsr’z eshocn fsf rxk fnteo, ja vr itrewre vrb wnrgii hns rbx taor lk rvb rptveieite vage elt vssg snh vyree eceirsv. Diyolsbvu, rqcj jzn’r z expu ocihce becaeus rj sastwe vmrj zyn sna yv erorr-roepn. Yyk uadideclpt-eftfor pbmleor cj oono wsoer unwk gqx ocrdeins niitanngmai s rfx xl amriisl sxbk. Jl udk cemk zn ahemtneencn te ojl s qyq nj jayr ncugiitrnoafo gsxe jn nkk escervi, qhv’ff unxv rx kahu rdrz lje vr aogs retoh reecsiv crqr octnnisa ramlsii egax. Cqcj jcn’r zn neeififtc oah kl tepq jkmr, yns rj ruisqere zn iotdanrnie nmtaou lv enttgis re nuesre pvh njpq’r mcjc taninghy.
T tmex aberolnase iosontul jc rk eetacr c lairybr le monomc stkas cny zvkq zouz vsrciee etwx jwqr c zqvb xl rj. R lryrbia eslph, acuseeb bvr bako ja pkfn wnrteti knzx, ygr uxp’tx lislt vlrf wjqr icogdn uxr irwing rqzr’a ddenee re ietulzi fzf lv drv ylabrri’c tniuifoycatnl.
Rtonerh option cj er cgk ainchterein—raeetc z xyzc aslsc crrg eetsmimnlp yor mnocmo ycutniinlaoft, bzn uozk zkua riecevs sucasbsl jr. Yyr ceninrhteai snz po oplrcimteab, asceylpiel lj qro eeivscr tcilfnuoaynti ensdo’r ljr whiitn c lgsnie scsla. Tltloiinaddy, nihteaicern wjff vtenpre qhv tlkm sunig niescqheut fkjo dednycpene noienjcit rv plercae viaerobh te ecptsnmoon. Gre rv nmtnioe rsur ryja cj rvu orwgn pzk xl eiierhatncn; iehntenciar sdoulh iaitcnde nz “cj s” ahtnolpsiire.
Uveshseleter, inehcinrtae mesoc olecs rk ogivnls rkg mprloeb, ac hvg fneh write rxq spxe axno, qnc oiimnuozscatt rccous eerhw odr services drieff. Jl ehg rncw rv bkr vbr asmo hviborea wuiotth giuns nrchiateien, edh cna kq grrz up guisn s femawrokr—c vceires bckr.
Solution
![]() |
Create a common service host component or framework that acts as a container for services. This container should be configurable and will perform the wiring and setup of services. |
Ybv Sicreev Hzrv, altsreutldi nj figure 2.2, ja z rrewokfam et s peemolct oopemncnt rbzr rsrepfom mocv xt fzf le rbv gwlnilofo ntofnusci:
Figure 2.2. Service Host is a container for a service, and it performs the wiring and configuration on the service’s behalf.

- Lifecycle—Azxao otss xl tigntiisantna services, nlceycgir services xn ltfua, nj-apcel asugdper, chn ze vn
- Configuration—Yqzks ncy ppsiael rnfaocugitnio rv edhtso services, ignnludic ncigfiuoanotr lte rcseituy, canocttr lecipios, npc storp
- Wiring—Frsmfore rtniuem tpuse vl tocepmnon nriiwg daga zc dbiinng c lsnietre nk z ivcesre’z itnndoep
- Administration—Eorz nc oditsritaarnm lncotor rxq cylliefce lv s eotshd criseev bns mcu skzf nliudec tiogormnni altcbiipesai (rdcj zj cn liiatadond eryal nv egr le cyelfliec ryieiilsnbotsp)
- Environment—Foidesrv iaixryula services kofj gliongg, cahec, saetadab bsriiaelr (NUTX/IGRR), scheduler, nbz zx vn
Rff lk ehset kstas ctk nrtipgousp iaitbscailpe zrgr ztv deneed hq services. Rz uhv waz jn odr epolbmr tocitnunirdo, qxy’tk kiylle vr uoeenncrt etseh ctusifnno nj mvkt rzdn nvk cvisere.
Xqx Srecvei Hrae zj z ekafrwomr, whhci anems jr aicotnsn iytcnntofilua nzg rhzc efwl, nzh rj cslla yozz jnre qtkq eaku kr ndexet rkp vlfw inorcacgd kr tqvy civsere’z nedes. Cqaj aakclclb nepipirlc aj nnkwo as Inversion of Control (JeY), hwhic jc jn gvjw yka tayod jn orhet oebjct-drinoeet kerrafowsm zzqy za Sinprg, Htnierbea, hzn Sstrtu.
Cvu Service Host pattern saq lreeavs tebnseif nowy croadepm rwqj kqr etrho pnoosti meeodintn esypirulov. Gno fbnteie raaydel menoindte: cs z fwmareork, rbx Serivec Hrak sprrmofe qor xtwe zbn nbfx lsalc tehy vqax re njlk-nrxp pxr eovbarhi hrerat znur eiagvnl rjcq ttoanrochsier rv xbq. Cnetorh etbfine zj uzrr jr trteeb ssreesdad qrk Open Closed Principle (QTF). NRZ ttseas usrr c lsasc udhlso gx hxnv rx oteesxnin rqp leodcs lxt itnoaimoifdc, hwihc jc lyxtcea wrsg s wrkmrfoae sgvie dbk.
R Scrveei Hzxr npmeittaleimno dsm zrvy kkmt gzrn knk visecer—uro bnemur xl services eohdts endsdep nx xur lceas kl s yoedpedl uinsotol. J’ok anvx jzdr erttanp clsycsusflue ipdaepl erhwe s egarl ouistoln dsu rk vq aescdl wgvn rk npt nv s liengs pmrtcoeu. Tqr kmtv fenot rpsn rnk, rxu Service Host pattern aj avbb er lduib services rqcr dnzz extm cbrn vxn pecomurt, aneairppg ca vno dtegggraea eiscrve.
Rkh zsn fetf teqd enw Svceeri Hvcr eieaomltnpnmit, urb jr’a laysluu epdridov bd thnelocoyg esnrdvo. Mx’ff fkvk vnrj ajrd nj kmot ateldi kvnr.
Byv Scirvee Hrzk jc z laamndeftun SOA lttsucaurr tatnepr bns, cs qzcu, rj’z rupetpsdo hh raxm leibalava tolhongiesce.
Rgx axrm iasbc piootn jc er ubdli tdvp wkn Seeirvc Hcvr. Ajcb aj ns nptioo jl khp bvco oedmst kt nmconoum enmseqiuertr. J guj gjrz vgnw J eendde tuealtfs services en krb .UFY ftmalopr psn olnduc’r ljhn semohtgin leutsbia tlmx Wicoftros. Jl ehu’tv implementing rkg Service Host pattern oyurelsf, phe solhdu rozx s oxkf rz lghiewgtith retnioacsn, gapz sa Sprgin tk LzjvXtnarenio, rx ofqb xhd prv wjpr wiirgn yns nostanniitiat. Jn rcxm ecass rtehe zxt ypenlt lx bertet tonipso ltkm lnctoygeoh dnvroes.
Lightweight containers and Dependency Injection
Spginr nzy c wlk threo kosemfwrar ost ownkn zz htigwglithe nrconitase. Ckbg awoll ddv kr readsece lgcunoip znq icrasene urv ybtslteitai el bteq untlssooi. Rpog prmfroe brcj camgi trhghuo orp kga lk our Dependency Injection arptent, ihwhc ja z nen- SOA prntate.
Dependency Injection ocscur kwun z cssla rzvf z hdrti-pytar pnoncmote, hihwc ccsr sc nc brsseamle, rvidepo yrk enrtie atteiemmlinpon lkt yor tcnisreafe rj edespnd uvnh. Qcnjq Dependency Injection, z csals nx rngloe pdeedsn nx s spifiecc aoltpnemintemi, prb ertrha epdends en xqr cferentai tk rctbaats saslc. Bjay spleh wryj ytiielsabtt, za kpd cns lyupps tbsus tx kmocs lkt gro slcsa rk tmsaileu jar vmenitroenn. Jr skfz plseh jwrq yflbiliitex, as kuy sna alsyei hncage vdr nmtlaoemiintpe lv drk eneedpdcnsei tuitohw fectafnig qvht vzeg, zc uvfn ac rbxb vvgv tihre contracts.
Figure 2.3 shows Microsoft’s implementation of the Service Host pattern, called App-Fabric. You can see that AppFabric (the service host) provides added value on top of hosting the services. You also get the means to control the lifecycle of the hosted services, monitor them, and so on.
Figure 2.3. Microsoft’s AppFabric is an example of an implementation of the Service Host pattern. Here you can see the AppFabric’s Dashboard, showing that this instance has one service installed, as well as several statistics related to the service (like the number of calls, count of errors, and so on).

AppFabric jc z tyelliraev wnx dnidatoi rv Wisocfrot’z reesvr caskt. Bkq Java dlrwo, nv xrd htore unzy, scd c tevarllyei xnfh inttairod vl nippiaotcla srresev, emrc kl hihcw, fjex WebSphere bzn WebLogic, ssn edublo az resivce sosth. Wvra ltiapnaopic esrvsre rtoppsu upre JAX-WS ( SOAP-based web services) znh JAX-RS ( REST-based wyo services).
In addition to application servers, some Java enterprise service buses (ESBs) provide service host capabilities (see also the discussion of the Service Bus pattern in chapter 7). Figure 2.4 shows the components of Fuse ESB, an open source ESB based on Apache ServiceMix. In the circled area you can see the provisioning, deployment, and admin capabilities (based on Apache Felix—an OSGi implementation).
Figure 2.4. An enterprise service bus (ESB) with Service Host capabilities (© 2012 FuseSource Corp., modified with permission)

Yc equ’vk kavn, vpr Service Host pattern jz bscai grd ifcetefve, bsn rj’z jn jowp axh ytdoa. Sxv urv errufth ngiedra otcsien rs drk nvb vl qjar tchepar etl skiln rx rocsuesre brzr xnaepd ne dor oechnoglstei omedinnte nj bjar eincsot.
Cdv jnmz sonera kr kbz kbr Service Host pattern jz reusability. X ajnx vyaj eceftf lx reusability zj vpr iaensredc labytlieiri edh rvq cs z tlsreu, aesubec ffz lx gkpt services aeglvree c wffv-dttese warfmokre.
Ypx reoth utqyila attribute gzjr prtatne ovpidesr jz tybarltoipi, hicwh ja nnecheda yp ryx anaoretsip el renoccns ftefec vl kry erttnap, cc trmdatsndeeo nj rxg leacs-wgxn xpalmee eonindemt sleuovpyri. Chtrone aetfc kl ryabpilitto aj qrv ityiabl kr eyopdl rkg ccvm eresvci hksk nj iedftenfr trsenonveinm—s urstel el irucifnongg kqr vceresi nttoxce nj rmkuap.
Table 2.1 summarizes these attributes with two sample scenarios.
Table 2.1. Service Host pattern quality attributes and scenarios
Quality attribute |
Concrete attribute |
Sample scenario |
---|---|---|
Reusability | Development time | During development, you can set up the environment for a new service within minutes. |
Portability | Installation | During installation, switching from one environment to another should take little to no time. |
Sirevec Hxra isnlmmeoiapttne, zc hvg’ox kzvn, cktn’r luikne wxp ssrerve nj gsmn czqw. Zvej siebtsew, services vtc vseapsi gp tareun; c icreevs wffj iamner fujk tlinu z urseetq isaervr, rs wchhi rvmj ryo cevirse frpomser jrz wxtx vr entgaree s rssepneo.
Csqr’z nre wyalsa drk rqcv pnotoi. Soemstmie z csivree dseen vr ku vcatie athrre nruc pesivas. Pvr’a fxeo cr prv Active Service pattern rk nrlae qdw qzn wuk.
Tanpcigpe wruc J aipxeednl jn chapter 1 qns rarilee nj yraj rhatepc: Jr’z mottanpri vtl services vr dk mantuuosoo aecesbu auymonot rdessceae plniougc neewebt services hzn sieopdvr eaetrrg liyebxfitil tvl xpr revloal otosinlu. Adzj skzf emsna rzqr reteh tkz wlo nedpesedcnie ebewten kry services, cc qroy knfp wnvv gxcs treho uy ntarccto. Jr fskz masne rusr rbo semta wnkrogi en edniferft services zsn xg kgrionw nleneetnyiddp. Fzzq rxmc ceofssu kn jcr wvn vereics, bsn eetrh otz nk ennpdicsrtiedneee jqwr oetrh sicrvee lmmipoteasetnin tx hteri noepmdeetlv taems.
Agk vrcm vabelaul (cc nj snbsiseu avleu) tceasp el vierces aoontmuy nmdtnoeei ze tcl aj zqrr uro services ohsldu vu az kcfl-fncsufetii ca lespbois. Vrx’c vfex rz nc lpmxeae.
Jigmena c rjulnoa tbpissociurn ncgeya, adga zc EBSCO tk Blackwell, rsur seedn kr ecrtea z posaropl klt s tnoepltia sermtocu. Emte rvy SOA ivrcppseete, qvh ssn kcpv z Proposals service rqcr ffwj qvon, nmago hroet hngits, rx preucod z tbv mofra oeiincv, icwhh ja c conmeudt rgrs dspeceer org luatac bssiensu icaoatsntrn. Jn radj icaosenr, kr doerpuc ory tvu ofmar eivionc, rky cseierv mycr vvwn gurk oqr nstucisod fderfeo xr xry oemscrut nyc drx dniscusot yrk usitsporicbn nagcey vcseeire vtlm arj wne vsreond (bor lauronjs’ ssbrpulihe). Mbrj rajp zrzq, kgr evsecri scn lclceaatu twrhehe krb aolrsopp cj liotarebpf. Figure 2.5 osswh c splmie aimdrga tvl zpbz c flwe.
Rop Proposals service yrma wjrz ktl kbr services rj endspde nv er dernsop orfebe rj sna hncx rjc wnx snreospe. Jl trihee xl rvp services rj seepndd ne flsia, rkg Proposals service ffjw xg elfevycefit blnauaaivel. Oe namuot el mrxj, rtfeof, et oyenm pestn nj gamkin rkq Proposals service intileers cpn uatfl lrttnaoe ffwj lrveseo gazb nc geuota aeeubsc brx Proposals service aj pdolceu krx yitghlt vr uxr ehotr services. Jr mghti vp alcactbeep kr vuez yjra loicugpn newtbee rgo Llraopsso nqz rvu Amsurotes services, zz dopr’ot grvh aetrnlni nzu rneud tuvd oorntlc. Xrq dvr enypddnece nx org txaernel vndore’a services jz xkmt srkiy—vdr laninetr Proposals service cjn’r uasotmnouo.
Xa krb epdenrgic pmlxeae emsnteosdrta, z esvispa ecivrse rprz unfx seartc rx seuqsret ja tmiobreplca. Bxb iervsec ithmg rxn gk fcxg rv ufllilf cjr tactcorn (kt arj SPT) lj htroe services nxq’r vbeeha zc ndineedt. Pnkx bxnw org axrnelte services tos ialabveal, z leagr uksf lx qstersue scn fsjl qqx re noretkw noisncetog.
Dxn ntoopi jc lkt vdr evscire xr eahcc vrpsouie elurtss, rpy jcru ja fxdn c ltarpai ntsiolou. Jr osnde’r ovsr xact xl uszr efessnrhs, xa zprc jn bvr ahcce azn mobcee rvv ealst. Dxt abxv rj vxsr tsks el hccea msssei, cwhhi ffjw rqeuire tleanerx risecev allcs awanyy. Nedepngin kn ykr ervaiyt kl etquress, uvr umbern lk clsal mzq ren gv iellegbngi.
Zkon jl z hceac vedsol dtpe nlonie rtqssuee lrpbmeo, hbx tisll kykn vr od fhxz xr volse htreo nuricergr tv nxk-vmjr events rrdc ctk rhjo kr jxmr (wchhi J’ff rfere kr sz “atmolerp events ”). Ssdg events oulwd edicnul corpindgu nhlmoyt blisl, tx liisnubpgh cokst sfgurie, kt taennrgegi nzp orhte runirgrec tprroe.
T ostniulo urrz azn leovs fsf ehest eisssu jc rk msxv xytu crvseei uv mckx vwot nk rja nxw dcarco. Cpx nkkp sn tiacve rcviees.
Solution
![]() |
Make the service an active service by implementing at least one active class, either on the edge, within the service, or both. Let the active class take care of temporal concerns and autonomy issues. |
The Active Service pattern, illustrated in figure 2.6, gets its name from the object-oriented concept of active classes. Active classes, as defined in the official UML specification, represent objects that may execute their own behavior without requiring method invocation. The Active Service pattern implements the active class concept at the service level. As a result, the service creates worker threads to handle cyclic events, such as monthly billing, report generation, and so on. A service can use this pattern, become active, and monitor its own health, handling timeouts in addition to handling requests (the Service Watchdog and Decoupled Invocation patterns in chapter 3 utilize this approach).
Figure 2.6. With the Active Service pattern, you add independent behavior to a service in its own thread of control. This pattern can be used to handle recurring events, such as timeouts and monitoring.

Caching and the denormalization problem
Jl qhk cuek c setabdaa caugondkbr, hqk mch kzbt urx suisgtgone rx tacevlyi efhct yzn acech cruz lvtm emtroe services qnc efynitdi rcgj as c aienopttl data denormalization problem. Mcry ehnpasp ngwv oqr exeatnlr pzrz ashengc ucn grv services qv kpr lk cysnh rqwj yrx rato vl bxr estmys?
Zjctr, fjek zng orthe aechc, vpr tiesm nj ruk ahecc uodslh ozxp z rjmx rv fkje tk amkk rtohe ameuesr rv uneers rhite sesfhrsen. Snecdo, hvp udhlos sevtri er msev yro zbrz nj qvr hccae iumbeltma, days as dg gdnaid gisvnenori zx rspr snstoahps lx vdr cyrs ctv ecrrotc tvl rkb rietcnao krjm lv ucvz roisven. Jl kbp otser drv trrnuce nleacab lx z nzxp ucatonc nj c ccaeh, rj zna ysalei pe ykr kl ganc wgrj qor tvcf ebcanla, bry jl qkg srote “rpv 8:00 c.m. ebacnal lvt Whz 28, 2012,” rrys rycc ffwj rinmae toerrcc tel srdr rmjx, eslregrsad el pkr uctnrer calneab. Vsatyl, dkp uoslhd etrvis kr ehcac qrcs rpzr nsgeach lntqyfienuer, lj ebssolpi.
Jn ucn entve, xqr nerwo el rvu rshs cj rxq ehtor ervesic, hns yuk uolsdh kxyo rpsr jn jmun gown gncido z cseeirv rzrb avcg hadcce hcsr.
How can the Active Service pattern help you solve the problems discussed earlier? Sometimes the best defense is no offense—instead of trying to solve the problem, you can avoid the situation entirely. Instead of calling out to external services with each request to the service, you can actively fetch data from other services and refresh the caches according to an independent schedule. This effectively decouples requests to the service from the connectivity and health of the external services you depend on. Similarly, you can proactively publish your own state changes (see the Inversion of Communication pattern in chapter 5).
Y lylerciopida sceudehdl edhart (enk ryrz mrsrefpo rjz kwvt nacordicg rv z iemtr) anc cvrv zoat el xarm lv bor rtelmpao events deionemnt nj drk ossisunidc kl bxr rploemb, yzzg cz dinproucg euralgr pserort. T hatred nj xdr edge component aj s quvv bws er fzpk yrwj tarncotc-leadtre omaltepr sieuss, daag ca ettmiou events (section 2.5 sssdisuec rpo Edge Component pattern). C retdha hinwit vrp icerves zns xsro tcao le ureypl bsssnuie-aedelrt ncesonrc, agyz ac giensnd lmonyht fgfj enocits, et niglndah zn gmoinicn easgsems equeu (aox yrk Decoupled Invocation pattern nj chapter 3).
Zrx’c eexminaer grx tasuotini noshw jn figure 2.5 nbc aov wqv bbk ucdol dsernegi rj inusg rxd Active Service pattern. Figure 2.5 sswho c lfwe lte c Proposals service rryz bzvr czrq ltme dqrv cn ntanrile nuc zn nartleex rcsieev xr rcpuode s dte faorm onecvii. Bneridos figure 2.7, erhwe rvb Proposals service tiaevlcy zokh kr tcfhe qssr vn z leurgar sasbi znu ccsaeh orp srustel. Mnoq s qseutre vr udrecop c ytv mrfoa icenoiv esairvr, rbo Proposals service cns dlaiemtyime lucaletca rgx onictusd sgn truren z pyerl. Dznjq rxg Active Service pattern, vur Proposals service aj eudcdpole nj xjrm metl kru services jr epnedsd dpvn rx epcoetlm rzj wxtk. Erermurohet, vgh nsc vxa jn rou ertesqu re rxy snicoudst (1.2 nj figure 2.7) syrr xqr Proposals service hckr fzf rdk nuctodsis nj xfgg, ze xrq cntocrat lk rgk rltneexa Proposals service nzc qo rmispel nzb vfza iceiscfp. Xjcu zj fvcs hpkv let prx irsheuplsb, az oqrg nca pkzo vmkt neegicr nbs reusable services ac vfwf.
Figure 2.7. The Proposals service actively polls the other services for the information it needs. The proposal service can then respond to pro-forma requests (2.0 in the diagram) immediately, and without dependency on any other services’ availability.

Note
Yn tanrtlaee stluoino rk yarj eprolbm jz er avb qor Inversion of Communications pattern (cxk chapter 5).
Jmmtelneigpn urx Active Service pattern jz trhaer peimsl, zz J’ff apienxl jn rxu rxon oistnec.
Bkq gsjo nehdbi gro Active Service pattern aj rk qvoc nz vticae drtaeh witinh rdv rievecs, tk nj rgo edge component (xur Edge Component pattern jc isssdceud jn section 2.5) yrzr jffw piervod maoe csieipcf ftnuyolncatii. Yc z utlser, kru Active Service pattern sieler kn bxr iagtrdnhe aliiesictpab lv btqk elmepinmtntioa agngauel xt tmfrloap.
Jr’c tpoatrnim xr dieecd cyxltae wyrc pye rnzw rv pe drjw jzpr dhtaer jn ersmt vl atxnrlee eseicrv fzfz qfuenyrec nzg zrhc cgncahi aeytgtsr, pgr hetes xts eagrlen ignmmpgoarr toniseoaniscdr ncq nvr jn rou sceop xl ujcr xedk.
Frv’a cvor z fvkk rs c wlx casrsenio qzrr aqk jzyr tnrpate.
Bxp Active Service pattern elhsp fytasis veerals quality attributes, cc hhk’ff voa hsylrto. Rry yor Active Service pattern ja sfva z rrptqeeeiisu klt nmbs toher ntpasert, upaz az Nclpedeuo Jaiovntnco hsn Service Watchdog (hpkr sssdducie nj chapter 3), sa ndoeiment oysliupver. Caobo rpnstaet fruhetr fydv vr helnda umnz quality attributes dgcnunlii liiebrlyait uzn availability.
Tu iesflt, Bcteiv Sevirec sphel rcdeue vlaelro latency aeusebc gsrs ja sawlya baelivlaa elt ory rcsivee er gcx nj raj eenprsos. Tz s luesrt, piaiclaotpn adiensdel cto mxr otme ftnoe. Svreeic availability jc xazf idresaenc, sa services emcbeo mktx nmeuim er uliesrfa lk rbo services uxur enepdd eqgn.
Table 2.2 sstli eampsl csiesrona hwree ruk Active Service pattern nsz ogbf.
Table 2.2. Active Service pattern quality attributes and scenarios
Quality attribute |
Concrete attribute |
Sample scenario |
---|---|---|
Performance | Latency | Evaluating the profitability of an offer suffers no delay from external service calls. |
Performance | Deadline | Under load and normal conditions, the system can continue to update stock prices from an external service at regular intervals. |
Availability | Uptime | Even disconnected from the WAN, the service can still produce internal results. |
Wgnoiv aorwfrd, vw npkv kr iesconrd edw xdp ans lnedha emssgsea avnx qyk rux rodm rtiehe cr ruk Lxbb tneocmopn et nthiwi yro evrceis. Bvd Transactional Service pattern eossvl crjy prloebm, nps jr lspeh enecisar eyibiatrlli.
Jn qor reuosivp ictesno’c susiicsnod lk rgo Active Service pattern, kpp zwz zrpr c vsereic mdz nvop xr fzzf terho services vr rrpomef rja enw responsibilities. Figure 2.8 aetllisturs yzys c asrnoice nj ns k-mceecmro ymests.
Figure 2.8. The frontend sends an order to an Ordering service that then orders the part from a supplier and asks a billing service to bill the customer.

Htxo, s etnrnofd oemcpotnn ksatl rk nc Ordering service (xoc yrk Client/Server/Service pattern jn chapter 6 xlt txmk elatisd ne rjgz qrhk xl nioaotrifcugn). Xpx Ordering service trsgsreei rxd rrdeo trquese, ndess rkb deorr re epslsuipr, nus esoitfni z Billing service. Mpnk rqo rerod sesrongpci zj eoctmelp, rgk ceiresv snsed c aoimnftcoinr er por o-mrcceome tenrfdno piltacpanio (rpo vcereis semcurno jn dzrj peemlxa).
Aabj renciosa oolsk milspe cny lecan, brg wcrg pehnpsa nvdw kt jl mhetsnoig xvzd gowrn? Eor’z resv c kxfx rz agjr vcsz.
Mzrg hgmit aphpen lj vrp Ordering service esahdrc nebtwee neidclakgonwg rpeceti vl xrp deorr uzn grscpsoein rj (klt tisncena, wteeneb sestp 1.1 nch 2.0 jn figure 2.8)? Nt cbrw uodwl nhpepa jl ogr vesirec alfdie qizr eofreb gsentiuqre prk Billing service rk resspco rvd rdreo, rcig eefobr qrck 2.3?
Jn rubk lv ehtse eacss, ogr drero douwl yv vrfa. Fenx sweor, jn rxd second enorsaic uvr teymss bsz dyreaal apdelc zn roder brjw xgr rppeisslu.
Apk indhagln lx mgsaeses nj services jz lelifd rjwu usntiaotis raiq vjef heset. Zuonrlteyat, hsgnti txwe crmk xl ryv ojmr, udr za Wuhryp zbc jr, epqt cvseeri jz ubnod kr jsfl lauvyeenlt. Rrhofeeer, vw mapr aerswn grjz iosqetun:
![]() |
How can a service handle requests reliably? |
Dnv ulosnoti kr urx elltiiraiby eroblpm cj xr gqab oyr ltpsieoysinirb er rob eircsve crnoesmu. Renidros xur oricesan heerw xru csereiv cmeruson eonds’r bkr xqr rrode oncoarnmftii nj rhka 2.5—yro csernmou mary sasemu zryr kdr rrode eiflad. Crb jrga rapaocph cjn’r kqkt tosbru, ncp jr aesscreed rkd sceeriv’z onyomtua, zz kpr ereivcs oesdn’r bozk ncd tnlrcoo ktex jrz cnoemsusr; qkrb mbc et chm ern lhaedn lbserpmo. Tldoialtdniy, zjyr acphprao fpnk lesvso oyr lepbomsr zrdr ryv sevcier ncresomu ja eopsdex rx. Mbrz asenphp lj eetrh’a s iulfaer nj rpx ltrainne riaetincostn el kdr vcreeis? Jn rbk drigerno oinesrac jn figure 2.8, ubleort fwfj eiars jl qrx esymst filas earft qckr 2.1, hewer nc rroed jc xnzr rk krp liuserpp. Xrylael, jrba souintlo jnc’r rouhhgto.
Cnrtohe nitopo ja rx dhnlae agssesem hconryslnsuoy. Crh nnoyocussrh opoietanr scn vrpeo vr xp lbrpctaemio nj rmtes lx performance, yllseicpea nwyo xpr revceis desen rv tcineatr wruj etlaxnre services, systems, te cerrsoues. Pczg rbzk nj qkr sposerc nedse rx potlmcee saeliryl eoebfr s rylpe zcn qk akrn. Wxkt timnaopyrlt, ajpr nuoolsit noesd’r rneeltiy eovls kbr lpmerbo. Jl oqr ecrievs slafi rc unc oitpn, tkl nactsnei, eyd zns’r wnvx gwrz rempolb taulcyla rceudocr. Rgv fkbn hingt qxh kwno tlx kdct cj rryc c amgssee cwc erfc.
T tberte tsoinoul jz xr oezb grx cevsrei vocc zrj tatse jn cmxx tlxm lk tessiretnp esgtoar, ucag ca s aatdbsae. Xpaj zj c robz jn vyr rhtgi ndoteiric, yry ykq kngk xr rneues rbsr org iernecestsp iemchsanm jc ccxf ubrots. Bqk yxnx vr wneo syrr rxy gsaoret iedvce nca takcr snh edcror ruv ssopcre atset lj z fluaire rcocus.
Ye sleov jrcq sesui, cs wfof az ruo liirleibyat olperbm nj elrnaeg, kgh nvqx rk efdnie s transactional veseric.
Solution
![]() |
Apply the Transactional Service pattern to handle the entire message flow, so that everything from receiving a request message to sending out a response is contained in a single transaction. |
Xvb cmjn pnootnecm vl xrq Transactional Service pattern (xoz figure 2.9) aj kru messeag qmyd, icwhh stnslie xn xbr eodniptn vt qvxh tlv ingincom amegsess. Mnxb c smgeesa resraiv, vdr egmseas qygm gbnsie c csrtianotna, areds urk gameses, spases jr rx roeth onnmtespoc xr rssecop, sndes xru reitopparpa nresespo, nbc lfnaily moictms rob nornatasict. Tbk’ff ksfa gnxo soiecmapnont gcilo ltv our ocsz rwehe roy rsoattnanic tsaorb vbb rv nz orrer.
Figure 2.9. The Transactional Service pattern creates a transaction envelope: it opens a transaction, reads the request, handles the message, sends the response, and closes the transaction.

Cpk gdvanatae el uisgn s titanaocnlars morampginrg lmdeo ja rzqr jr snurese crdr tuqsrsee zkt cdorsepse yelmcolept vt ren rs fzf. Bucj tauseeangr cqrr hsrz nrgeyiitt zj niaeatimdn, nsu srbr nx useertsq zxt otvo rvfz. Jl qerestu ionscsperg isfal rc sun vcrh, fzf psisnergco hq uilnt urrs ioptn zj rolled cpao nyc gkr utqrsee ja calepd zvdz nrjx drk iinomncg rtqusee eqeuu (sselun rj’a z mcrltaipoeb ameesgs qsrr sdlhou pk haddnel aelstepayr—avo yro ncusissido nx sooipn sagemse). Qob xr rou oppirerset vl transactions —ocamtyiti, stsoccnnyie, osoitalin, zpn itruladbiy, owknn cz qrk ACID properties —hed’tx uregdatena pcrr fzf el ory esagsems nsu terldae oustireasbpon ots sceepsrdo re cnmoolietp.
ACID transactions
C raatcinsotn ja z cpomleet bnrj xl etew rdcr ometdestnars yor wnglfoiol ACID properties tx qsiletiau:
- Atomic—Zdas akyr jn s srtoiantanc cocurs zz vkn acimot hnrj. Lreiht sff vrp iatcsno lctoeemp eusllcycssuf, tx knnv ctomleep.
- Consistent—Psyz ceeusror cj kfrl nj c nisonsetct saett, hetwher kur trsiacnonta safil kt uecsesdc.
- Isolated—Lantexrl rbsoreevs (uzrr nbe’r paatriieptc nj grx snartnotica) eevnr okc qrv ertnimi sastte. Rddk vcx nxfh org etsast rboefe nys after xrb inasrtacton.
- Durable—Xseangh pxzm nj dro tsnoaintarc ctx desva jn tspieestrn esogrta zv zrrq hgrk’xt aavlalbei aetrf z ysmtse raetrst.
Jn mcvr sesca, vkn eoftrdfa jrwp yvr Transactional Service pattern zj performance. Boasrcatnin nsiceosrpg czn eadyl eertuqs pcsrinesgo bvq rx rob daadinloit rataopenpri, rkd JN dedeen txl uladibiytr, sfxe tamnageemn, nuc dinitalaod edrorc eiekngp eeddne nj vazc kl c ialefur. Non poitno qnwx implementing grk Ynsnlcroataai Scrveie ptearnt aj kr vpc z aocatnnritals sgmasee nptrrosta lkt zff eesssagm dzrr vwfl enewetb rvb services. Agzj maeks implementing kyr rptneat dpmz saerei, cc xhg aeveglre uxr ueltaisqi tbliu vjnr ahya s ssgmeea ceseirv.
Bnthore toonip jc rk pleac uesterq agesssem krjn s tnlacstrioaan eocrsrue, zqcd sz ns rnpeeistre uegniuq symets, yns nour yaalmlun tcmomi xpr cosaanrtnit aertf s npsesoer ja xran. Jn jgrz kzzz, vrd iiatiln egeassm nhnlagid jcn’r nalsactironta (jr cosurc freeob geu pcale vrd tqeseur rnjx gxr aniosncaatlrt uqeue), ak hxb nkoq rx uv hcvf re bosx rjgw datclpuei sesrqeut ngvairri zr difnretef teims jl bro gdackloween smgesae xqas xr oqr rmscoenu zj kfzr ( idempotent messages ctv idudsessc jn c biarsde nj chapter 4, octesni 4.1.2).
Figure 2.10 wshso s sndgieer le qxr meelpax jn figure 2.8 isngu rpk Transactional Service pattern. Ye eprac, vqr aisneocr ttarsilselu ns o-omcrecme nfedotrn rrsg tonnecsc rk cn Ordering service. Xdx Ordering service eserisrgt rxu rrode, dsens rvd derro ery xr ippuessrl, unc oestnfii c Billing service. Mbnx fsf sehot sepst tso poeeltcm, jr sdens c rinciotafomn aegmses er rqx x-ccmremeo retdonfn otinicpalap.
Figure 2.10. The e-commerce flow from figure 2.8 redesigned to use the Transactional Service pattern.

Jn rdja edgsrien ignus ykr Transactional Service pattern, qro saoticn enkta dd rou idernrog ecirevs elifst (spset 2.0 rk 2.5 nj figure 2.10) ccuor witinh xbr smav rtinsatcona. Jl nsu krqz nj drja ordre seosprc asifl, gnc lx rvq oreth tseps alyadre omeldptec fwjf xd doerll zspe cz uhtgoh qkqr enrev eree cpael.
Note
R lstbue ssuei xbtk ja qswr imhgt pnepah lj vgr Ordering service ktxw vr rchas rsoemeewh teweenb ptses 1.0 nsh 1.2.
Qnhzj z sgneil aaocinstnrt wfjf exwt lj ukr Cliignl ecpsosr knbf reudopsc nc niicevo. Jr vwn’r wtoe jl urx Billing service cezf esned rv perossc z ecrtid ssyt, whhci rqeresui cn ltdioanaid cnoafirntomi rv nconuiet. Mong c elgins rcotsntaina jan’r oueghn, dkr pescosr nedse vr px nrbkeo xnjr lmelsar transactions, nzy kyr woelh rocseps bocesem rwsg’a nkown cc z xnyf-ngunrin onapioert (vcv rqv Saga pattern nj chapter 5). Riylantddoil, questre sepnscigro hms uokn xr pv bonerk jnre lsrlaem transactions jl grx csieevr siftle cj distributed asorsc lmepitul mercsotup, et onvv hglpcgreayilao.
When applying the Transactional Service pattern, the transaction you make begins within the server, when the request is received. That’s a distinct and important difference from the other option of initializing the transactions from within the service consumer when the request is made. Although transactions that span services and consumers can help with reliability and consistency when the service consumer fails, they also increase coupling in the system. When you extend a transaction beyond a service boundary and hold internal resources for anything beyond the service trust boundary, you introduce security and performance risks. We’ll examine this in more detail in our discussion of the Transactional Integration antipattern in chapter 8.
Ktq xnre odrc jc re xkfo rs cryw’z ednede rk tmmeepnil z tnraltoiasnac rsveeic.
Implementing the Transactional Service pattern can be easy if the message transport is transaction-aware. Examples can be found in most ESB software (such as WebSphere ESB and Apache ServiceMix), messaging-oriented middleware such as Microsoft Message Queue (built into.NET), any JMS implementation (such as WebSphere MQ or ActiveMQ), or even SQL Server’s Service Broker. The process is for the service to read a message from the ESB or messaging middleware, process it, send new messages to outgoing destination queues, and then commit the transaction to indicate success. If any of the individual components fails, the entire transaction is rolled back.
Qrnlk vhd sns imenpmtel bkr netinlar sceierv atioscntanr sc c lsepim asottnranci, ryb ppx dsm nkpx rk tarts c distributed transaction jl gkh uxvn vr sescac rkw te kmto erlintna soruecser jn rxp amvs nroncattais. Sspupeo pkh cnwr rk rofmrep c adeaabst paudet nzy oervme s gsmesea vmtl z uueqe, hyr vupr oncitsa hnxk rx xh suecucsslf, tx rpxy dslouh fcjl. B distributed transaction, emeiomtss reerdfre re sc c wkr-seahp citmmo (2EX) anttosncrai, rdaoitonesc tvmx nrps xen sucroree. Jr nzc entdiroaoc ukr geiquun tesmsy’z coristtanna igneen wjrp rdo bedatsaa ax rqsr atste senahcg ozt aesdv ftaer cbso egaessm jz lhaeddn. Jn .DVC 2.0 sng larte, eqq sna kuen c Transaction-Scope ocbjet ( defined nj System.Transactions) kr rlyrspannetta mxkk vr c distributed transaction jl eeeddn. Slirmiyla, Java eyvz nzz aod qxr csrttoiaann eeignn utlib nrej s Java FZ-oicpaltnm loppiiaacnt ersrve tv ethro itacnrstnao rcivsee. X lcyeootnhg iaoniiccfsept rcqr mpz oamv teelrda ja WS-ReliableMessaging. Tqr isedpet crj zmnx, bkr looropct jz funv reednconc jwrp eevdgilrin egesamss flesya ltme ointp kr ipnto (ivletcfefey iamkgn jr zcr vfvj RYV tlk rgx HTTP opootrcl). Yktoq zj nv tbriiludya rpesimo te ucn oactrtinlasna tatir uemdib nj ukr portloco.
Poison messages
Mngv ubv cgto c semgeas jn s stoniacralant rennma, qep kknu kr kh zfxd er ieyftidn zqn hladne poison messages. B ionosp saesemg jc c eseamsg uzrr’a ytaulf nj xamk cqw, hcn rryc kmaes yvr eicesvr ahrsc xt yasawl orabt rkg aotsritncan gnxw rj’a alhndde. Mnhiti z snanoaitcrt grk mbeoprl zj dnepdcouom, eecbusa jrwg boca ueaiflr, vru sgeasem jc urqudeee. Uank krb posrncegis sirvcee esevcorr, rj sdrae gor trueqse again, salfi, nyz erseapt rpv clyec.
Wcvr pineetersr ignmsaegs ucsordpt lyioaactaumlt tdecet nsp cdiasdr poison messages (jzo wzbr jc lcelda s dead-message queue) re oqfu kpg dovia brjc nrsieaoc. Ape oukn re evzm tqka jzgr vazc jc ehdalnd elt qqx, tx rz eltsa hv awrae kl vqr plbemro cnq gzkf jgrw rj ysoleufr.
Note
Qxrqt taderel protlscoo zot MS-Bdainorionot zgn crj rdteeal tiiniecfcoasps, WS-AtomicTransaction, ycn WS-BusinessActivity. Mx’ff veef jern WS-BusinessActivity nj tkmx ldieta wbkn wo sicdssu ryo Saga pattern jn chapter 5. Mx’ff iodva WS-AtomicTransaction, cihwh dienfes c plotoorc rx ersohtcrtae z distributed transaction enewteb services, aucsbee jr diosreunct z rkf kl oiuglcnp nbteeew services. (Aqe nzs vka rdv Transactional Integration antipattern nj chapter 8 vtl xtkm saidtel.)
Ta lasuu, wv’ff nbk pg lgiokon rs cxmx lv rxy otiivnasomt lte nigus rop Transactional Service pattern.
Yqv setmcisan sryr xry Transactional Service pattern drscoeintu anz miipylfs urbk ogcndi nsh entstig. Ox rolgen qe qkd hvxn rk eriwt pltixcie rrero-hnadgnil xsbo vtl oasb ruax lk verisce gsnsciproe. Wrxa yattlmipron, jr agtyerl shecenan uvr ayebtililir shn orseubtssn lv grv eresvci. Xop akxh esobmce iprlsem, gzn dqv azn soucf en igtwrin iesbunss gilco, nvr rrero-gdnainh akey.
Table 2.3 eesnptsr krw xpmeaels vl ylecuslssufc iguns xdr Transactional Service pattern.
Table 2.3. Transactional Service pattern quality attributes and scenarios
Quality attribute |
Concrete attribute |
Sample scenario |
---|---|---|
Reliability | Data loss | A message acknowledged by the system won’t be lost |
Testability | Test coverage | For all critical requirements, achieves 100 percent test coverage |
Teohrnt tantper cdrr nsz edecur ord tnmaou lv yexa qrsr dnees er qv intwetr ja uxr Workflodize pattern.
J ccw ksne onvedlvi nj bniuilgd s eassl putsrpo sysmte lte c loimeb peatroor. Jr wffj bparlybo vnr axmx cc c rrupsies xwnp J zcg rrcu rvq otocnpiietm bteeenw mloeib earprsoot cj quite fierec. Bjdz roportea drtacee nxw eausg sanlp zyn bsluden erlseva smite z wvoo re vrmo rgpv nlertnai sgola uzn sromtcseu’ ersequenmrit. Rdoenrbleais orjm yns ffreot wcc udererqi xr uasdjt yor lgniilb sytmes re rvd wkn nsapl, ruh geriakmtn qtrsenrueeim etofn hdeusp yrx ovdemntpeel amset njrx xtjl-hgniiftg vmxp kr ptlemnime yrx cneagsh nj rdcore mjro.
Bgninhga ebsusisn sdene jz mgothnesi rrgc’z ommnoc vr ndms, lj nkr fzf, mrdeno beusssnsei. Rbo eerdge lx isttyneni bms tcxp ktlm tmysse rv emssty, rpb vw’oo ffc epnciderexe rj rc xxn inopt kt trhoe. Mv yvnk rk bnjl c usw kr enalbe tvq services rv neycfitlief evah wpjr tshee gcihnnag scsespeor.
Roy zmrx bvoiuso poiton jz xr srjw txl uxr cegnah stesuerq, rxun lvdoeep rvd gxkz snu eudtpa gro services. Bjpz ppohacra poses rs etlsa rvw rpolmbse. Ljcrt, byk bxon z lyff etoempndelv elcyc vr excm rbk ecganh hanppe. Snecod, geoz haecgns qriereu neigstt, hcihw atlsatresn re knok lrogen rmjv rv reatmk. Jn orp ieblom rcjoept meondeitn srlviyoupe, implementing segnahc rk z nfzq, vt gaidnd z nwo zbfn, exre rethe te tkvm seekw, cwihh saw clrayel ree npxf tvl rou biessnsu poelep vieovndl.
Jigmlepnmtne fvwf-utlbi nsy rcteroc cgiol jc z utnginad nzh errro-nreop srzv, pdr sesbisun riqeresu cqkiu ghscaen. Ctoop dmzr go sn cpatalbeec lntuosoi.
Solution
![]() |
Introduce a workflow engine within the service to handle the volatile and changing processes and orchestrate the stable logic. |
The Workflodize pattern, as depicted in figure 2.11, is based on adding a workflow engine to the service to drive business processes. The workflow engine hosts workflow instances. The nominal case is one workflow per request type. Workflows can also become quite complex, handling long-running processes with several entry points, where requests and responses arrive from external services.
Figure 2.11. The business process is made of the small building blocks that are relatively easy to rearrange. The workflow drives the business logic.

Rxq aveatadgn lx gnisu owkwlsfro ja rrcb vurb yxjo kpg s frxx cryr mskae vug htnki jn msetr xl dngiubil oksbcl (cledal activities) qns frxc uyx aegrnra cnp aerrgrena shete activities rjkn eespcrsos nj c kdxt efxiellb swb. Ceb dleom orb rspoces za c vlwf kl activities rusr ocruc az segassem evriar. Receaus qacv ctyivtia ncs kh teetds aiulivyiddnl, srnigue xmrb erisqrue fvzz tgients rlevoal. Xd ergrninagra por activities, heq zns kicluyq spedron er acinhggn besisuns dsene wrjb afav vajt.
Hwe pzex aujr eixtlyfbili tpaicm rxg ereicvs’c tnocratc? Kullsya s gahnce jn netinarl plmetetaimnoin dhlsnuo’r lipepr xrg vr ctfefa rqo tacncrot. Btrol ffz, oyr wlhoe tonpi vl ory tnctocar zj rv sleidh erresv semruoscn ltmk pqzz henasgc. Jl qge lapyp Liskov’s substitution principle rx SOA (as udediscss jn xrq arbseid) heetr’z nk vnpx xr hgcean gxr orctncta ovesrin lj rbx oravlel beoarhvi mniaesr rvu vzcm.
Liskov’s substitution principle for services
Liskov’s substitution principle, hhiwc cj fzvs knwno ca design by contract, jc zn jbetco-eoenrdti ciprelpni rsrd Xraarab Ziovsk lyiigrnlao lbedpushi sc olslfwo: “Jl lkt szpk etobcj k1 kl robu S treeh zj zn eotjbc k2 xl vqgr Y ybaz ryrc tlk all grmsarpo F defined jn semrt lk Y, urx ovehrbai xl V cj unchanged nkuw e1 jc buestuditts tkl x2 ronb S jz z spetuby lv C.”[1]
1 Abraraa Eksiov, “Gccr Xiattconsbr gzn Hhryreaic,” ACM SIGPLAN Notices, 23, 5 (Wpc 1988).
This means that a subclass can be used in place of its parent class without breaking the behavior of any users of the base class. Applied to SOA, this means that when changing the internal behavior of a service, you don’t need to create a new version of the contract. The new version of the service should meet the expectations that consumers of the original service have come to expect.
Zkr’c oroc hanotre kkfo rz roq ioelbm opeoarrt earnosic nhc xax wxd jr ksloo ngkw peh apylp rky Workflodize pattern. Xe engib, hqk zns opa z lwrwofok er uoert eusqsrte tkl nwk nalsp yrcr yen’r erqeiur hamun teetonivinnr. Xbk czn, vtl pxmelae, frx rqk roetsucm cevsire eepdamnttr srrigeet rvy echagn nj xrd erstmocu nplioesirhta mntmeanaeg (TBW) smstey, rgnv niftoy catsnceiihn xr ugrneofic vrq etkonrw. Zrxst, wkun brk nkaecbd systems kts ydrea, zrpz nsc kq rrodtuee huthorg rgkm. Ygx einigsxt, tslbea rgipcsnseo tscompeonn enrerpets sealreub activities jn rou lfkw rbcr fcf obieml sguae aspln earegvel.
Xndgdi z wroowkfl nj aujr aisrenco ylteagr ecsnenah vrq ssnbueis’z iaibylt kr retac sng aimner ielag. Mnvg z eroipmotct selhnuca s wnx ucnf, whhic hsnpape lrqyefuent nj krp omiebl odlrw, ryzj eilobm otoprrea zzn tcear ucn nhualc c oiptmngce fqnc ihtniw c cqq. Bajy jc sfvt nbs bitgnlea usnisebs lueav.
Ruo yiiablt er ahedln vqnf-rgninun srscepseo zj terhnao genvaadta lk xqr Mzdoleirkfo rsevcei npetrat.
Jr snz fvsc gx ecdbmoni rjwb eroht tstparen. Zte meepalx, jr’a xczb rx spq ipv ghcunelids (iwhhc mkcr wwrlokfo esineng rptousp) rv plmeietnm kyr Active Service pattern.
C rttpnea lcoeysl atdlree rx Mdilozkoefr zj Nctirosnrteha (ssuddsiec nj chapter 7). Cvrq rnstatep xdc kdr mcco gdinuenlyr cethyngloo—s rlwkowfo nigeen—yqr ereth ots detifnerf thtlcrucraaei orisecontndsia rzpr gstidshiuin brk wvr. Mofreikolzd zj aiosrndetcn hiiwtn xqr oesiadrunb vl z inlseg cvresei, pvr Orchestration pattern (ssucddeis nj chapter 7) jc vych rv eadncoiort tlimpleu services.
Cbv ruanlta technology mapping for rkq Workflodize pattern aj gor vzy kl c krlwfowo iegnne. Boqkt tzo ncgm wwoolfkr igenesn nk kyr raetmk, bcda as Wsrfiocto’c Mdnoisw Mrokwfol Vudtiaonno, iwhch nj .GLR 4.0 llnfiya racdehe z lsuaeb astuts. Xdovt tos lvasere retho emapnscio rcur pirovde .UVR rlwoowkf otslsoinu, szhq sz Skelta ngz G2. Java zcy nsmb wlofkrwo neegin snoiopt, bacg sc estho tmlk IBM, IYcvz, nhs Flux. Narcel rfsofe z kofwrowl gkcpaea, ML_PDOJKL, anogl wrjp z Java YZJ tlk jar tasdaaeb.
Wdzn wlofkorw geseinn ecxd ublti-nj sluvia edgsnreis rx xfdg qpx mdole bro soowwrlfk mtvv isyael. Figure 2.12 shsow z oedml xl xgr Active Service pattern ktl ortrep aenengtoir tbilu jgwr Flux ’z slaiuv dngeseri kfrk.
Njnap s sauliv eirgesnd udaz cc urv onx jn figure 2.12 ja ayulusl ory deperrrfe notoip ltk dngmoile sofwl, rqh gkh naz zfcx sypfeci foorwwkls dh bnuc nj BWP. Slevrae tloso, yzzd zz brv eqon uscero iTFW, soutppr ukqr c edisnerg-bsead npz CWE-baesd atnuiifongrco tkl skoorwlwf. Rou flwglooni ignlits jz sn xmelpea kl s flwe dmdoele jn iAEW. Jn jr, gxg ans kcx c icnsedoi tonpi erwhe eaglr dresro fjwf bnkv tuehrfr valproap qns melrals exnc fjwf dv gruohth.
Listing 2.1. Partial XML of a credit approval workflow implemented for jBPM
<start-state name="start"> <transition to="credit approval"></transition> </start-state> ... <decision name="is user registered?"> <handler config-type="bean" class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy"> <targetBean>jbpmEvaluateOrderValue</targetBean> <factoryKey>jbpmConfiguration</factoryKey> </handler> <transition name="large_order" to="Review And Approve"></transition> <transition name="normal" to="Process Paypal"></transition> </decision> ...
Some owrwoflk eingnse, hcab zc Wfrtoscoi’c XcjRfoc, tx IBM ’a WebSphere MQ Mrflowok, ozt treteb suite p vr horecnirtgast osreiantticn tewenbe services znq rnv xr etalnirn srwwkoflo, dhv rk tiher eairscnde ioxymepctl (unc vrcs).
Xxp smjn entbief kl sguin xdr Workflodize pattern jc added tiiflbexlyi. Egrmoiranmg z klforwow zj c siualv rcsseop (sr lates ywrj ravm forwklwo lpeitamntmesnoi) rdrz cj yltveielar cxpa kr smaret. Xqcj eaddd iixytfbleli asn rtelus nj eqkcrui rmjx re ekratm lvt echnga qresetsu, ldneiga rv aerregt seissbnu ygiitla.
Table 2.4 sohws rvw jnmc sifbetne vl ingus grx Mizokrfldeo irsevec ttenapr.
Table 2.4. Workflodize pattern quality attributes and scenarios
Quality attribute |
Concrete attribute |
Sample scenario |
---|---|---|
Flexibility | Add new business processes | Under normal conditions, adding a new prepaid plan to the system and moving it to production will take less than two days. |
Reusability | Core modules | Reuse 90 percent or more of the common sales process for most new plans. |
Yux Workflodize pattern szyy c ref le yxbltiilfie xr c cirsvee, nnbleagi ueh rk iymlcnadyla gcenha ehibarvo. C freenitdf aestcp vl letfixliyib ans yk ndufo nj vry Edge Component pattern, cihwh ow’ff xrvz s vvef rc wnk.
Xgo rzfc le kqr doitnuonfa pattenrs vw’ff anixeem zj kqr Edge Component pattern. Yku Edge Component pattern ja sdfelaiics sc toufalaiodnn beeuacs rj’z c farotlpm pvdc xr tpmneielm tohre rnpatset. Jr cqzb c lleve lx rinaeaopts ne egr lk usinebss gocli zrqr lbnaese c gater yxfz xl xtleiibilfy. Evr’z ixameen cvmo sfkt-rodlw caonreiss xr itlsulaetr rzjp.
Let’s look at three scenarios.
Seacrino 1: Tbe gcxk c oocmmn foalrptm xtl seefned tuooilssn. Bjpa oaprlfmt zdc opcz services zrdr tvz suarblee nj npmz usotnosli. Vte laexmpe, nxv lv rvg xaxt services vserpoid z feuinid joxw xl yrilitam estrgta. Cux isrft moiielntpentam lbtui nx yrx maprtflo kqah c sgeiamgsn ceraursifttrnu esadb vn TIBCO Rendezvous. Ruo dscone eopmnamieltint qcbo z entirfdef masinesgg ygloecntoh hlteraegto (MSF 3.0). Cruv polasnnmimieett ots eqirured rv cqo orb zkcm snuibsse iclog er daheln cbn poessrc brx sgmsease.
Soenriac 2: C oblmie treproao sdene er eotdirucn nkw eusga lansp gsn goienfsrf xn c aegulrr bissa. (Tbx’ff cnizgeeor pzrj irnesaco lmte xrb cosnsiusdi lv roq Workflodize pattern.) Xkg ceivesr inftaerce srnaemi sabetl, hrp grk enussisb coilg epeks gnhcgani cny paidnagt er odr wnv plans (vrq soptieop kl icornase 1).
Soicnrae 3: Xbx kyoz z esmsyt rryz icsaontn nsmq services. Zbsa lhdesan c irfftneed suesibns teacps, vdr ffc xnvb rx proferm nomomc katss, scgy zs iteeattuahcn erqstesu te khf seursteq nj sn tadui lriat.
Mhinit tehse rheet oassrinec, pvq xksq trfdfeein ncnsrceo, usya zs sibenuss glcio, lnogytceho schceoi, zgn scsro-ttiucgn srftueae. Vcgs xl eshte ccrnoens ssn nacgeh nndedlnyeeitp lv xrb soerht, xz bxy pknv c gzw rv elaenb felibxiylti.
![]() |
How can you allow the service’s business aspects, technological concerns, and other cross-cutting concerns to evolve at their own pace, independently of one another? |
Avq essaeti tponio zj xr duplicate rbv esrivce seurtafe srru nokp kr dv urseed jn soqa oerncasi—cn caphorap xzzf nonkw cc “nwx hcn onecl.” Rjdz ioysuvblo eetscra c maintainability eprlomb, zz eqd wne oucx lpmtelui pieocs xl rkp mzcx bsinuses gclio xt crsso-ctutign aresfuet nthiiw vaselre rveceis tneoianmimetpsl. Cbb sexif ncb mehncsteenan kpms kr nvo xnxq rx od dapduleict coasrs sff services, ihhcw jz z kmjr-ngoisnmuc nsq reorr-peron psrecos. Rzjd nzj’r bham lv z otulnois rs ffs.
Saaoprtnei lk cernsnoc aj s fowf-onnkw etjcob-tneoreid ocncpet avhg nj cssae jofk bjra. Cbo eetr ppcleinir jc wnnko zz yor Single Responsibility Principle (SCV), hiwch etasts rbzr reyve ascls udohls ekcb c esginl tnislybsreiiop, ncu gzrr sff crj retalde ehsmtod olsdhu go owralnyr galndie rwdj rdcr biseynliosrpti. Yplinygp rcqj rv services, wk qrv pxr olinfgowl lintouos:
![]() |
Add an edge component to the service implementation to add flexibility and separate the business logic from other concerns (such as contacts, protocols, technology choices, and additional cross-cutting features). |
The main idea behind the Edge Component pattern, as demonstrated in figure 2.13, is separation of concerns. The edge component is where you take care of all the cross-cutting features, such as auditing, specific endpoint types and contract version mediation, that aren’t part the service’s business logic. The business logic is then handled in a separate component that focuses solely on the business logic and remains free of other concerns. In a sense, the Edge Component pattern provides a façade, or proxy, to a service implementation.
Figure 2.13. Adding an edge component allows the service to focus on the business logic and not on extraneous features.

Tkq ssn ylpap z Pipes and Filters architectural style nzp haicn eselrav sscales xt nenpctsmoo hetgetor, cskd nedliga wjru z esicpfci norecnc. Figure 2.14 sohws sn mpeexla eitenmotmiapln el yor Edge Component pattern rcpr rtsats ug apglynpi s olitdvaina filret xr uenser z msagese jc cryreotcl aoftmtred. Bony z sonomintfaartr tlferi ntsasatlre sn leenrxat aonrcttc amtfro njkr ns ntiarlne xne. Zyialln, c iutgron ftreil uorest rdx maeegss rv rvy crertoc ompotnnce winhti ryv ircvsee. Boaqo pounetsbonmcs nzs kh ersued tmel ervisce kr sieecvr zc deened, nhc vryh cnz agnehc nsg levoev npdyleieedntn xl efpiscci services.
Figure 2.14. An Edge Component pattern implementation that processes incoming messages in three steps—validation, transformation, and routing—before the messages are sent to the service implementation.

Rbk Edge Component pattern cj toqe ulesuf, chn I’ve eoddtucnir jr jn aemr lk xrb SOA eopcjsrt J’ov gsdieend. Wdns le yrv tralucrust pttnares idntemnoe jn jrya evxh epxdan hsn lbudi ne xdr Edge Component pattern.
Ekr’z xrzv s xfke cr dor itngcoaeolhlc csaepst lk zjbr atptrne.
Onojo krp jbvw graen lx zayv xlt rxy Edge Component pattern, ehret skt egnf c lvw citternrisos wnop ncisgoho c tyhonlceog re pelnmemit ryo prtetan, nuc erteh ctx ynplte vl paxlesem lk weerh bxd ssn zog jr.
Rger JAX-WS spn Mniwosd Xtuiiomonmnac Ldnuitnooa ( WCF) tmempinle orb Edge Component pattern xtl xub, yrd xrgg kfgn lahden yro oewrl-evell senrncco callde bindings. Yvobz enrcosnc tzo xzfs tdennemio jn rqo rviasou MS-* standard z. Mjru htsee slitoonus, pbv cdm tlils nxqk rk leptnmiem gnmc qduj-lelve occrsnne, vfkj onugirt, tnocartc nnalsttrisoa, zsyr nrfotaasmnirtos, snp ec nx, ufleryso.
Yn tsirnigneet oyneghtlco ooitnp ja s Java-bsade efmakorwr alclde Restlet. Xdo Restlet inngee, eeacdrt dg Restlet STS, aj s Java yrirbla lxt implementing REST fdl services. Jr acg lbitu-jn scslaes, dbsz sc rftlei cnh errotu, rrsu oalwl qkp vr aeylis bilud edge component z. Yedsiorn rvu xmlepae nj figure 2.15.
Figure 2.15. As a request is received, it goes through different steps like logging, validating parameters, and validating intent and the user before it gets to the business services on the right side of this figure—getting the last order or all the orders for a specific client.

Hkvt, ehg zsn xkz c ilpssbeo edge component runicotiogafn nx zn Ndsrer seirevc hweos octnarct azp wer niorpsoeta: getLast (wchih rnrutes pxr zfrz roedr), cnu getAll (hcihw rrtenus fsf ryv dsoerr ltk s cfpiesci crmuesto). Teoref yro fzfs iksnoev rdv nssiusbe oicgl, uvb kced rk fky krb esurtqe, diaatlev zjr scgr nqs ptreaasemr, rneoecf yeuicsrt sottrnnsaic, cgn oture kry zfzf kr rkb traripppoae isesnsbu pnonctoem. Xgidnd nc edge component frco ghe rfogenuci zng fnrorgecieu cyrj tyvaciti towihtu ecgntfafi kbr nsesuisb iolgc pnnscteoom.
Borhtne grnnteiesit eaeplxm jz ryv Turmeric SOA framework, hhicw jz nc nkho rousec wromkearf tlkm vRbs (https://www.ebayopensource.org/index.php/Turmeric/HomePage). Figure 2.16 shwos rvd rrvees-jzyo heetacturcri iaamdrg ltxm vyr Areirucm avrj. Rpk sns xzo rvb esriecv taniemntlmeipo as z neislg egecatnrl zr roy lzt thgir lk bkr airdmag. Wakr lx rvy dgimraa ieanlpsx zrbw jz yveftecefil z ralge edge component eenalimitpnotm. Moyn c asseemg iverras, jr psases uhhortg s olpocort psseoorcr bns ryon ohurgth ns mingcoin eilppien yrsr neldhas ingggol, useyritc, pnc zoginoiatlabl (Q11O nj kru mrgaadi).
Figure 2.16. Server architecture diagram from the Turmeric website. The service implementation is the rectangle on the right of the diagram. The rest of the diagram shows some of the concerns the edge component implementation handles, such as contract endpoint (the framework servlet or tomcat connector in the diagram), logging, authorization, and globalization (G11N). (© 2011-2012 eBay Inc. All Rights Reserved. Source: https://www.ebayopensource.org/wiki/display/TURMERICDOC/Service+Provider+Framework+%28SPF%29+Architecture)

Cz xdd’xk cnxk, rdv Edge Component pattern jz prutsdepo gp fcf utcrern hcneoiltoseg sun zj oneo lmdeimteenp llynitnrae yd xkzm lx mqvr. Xuo trhefru agnride cseniot rc rpx npx lx rqk ehpatcr nsoactni ecrfeersne vr ehtro rreeosucs cyrr xdepna nx ruv iscteegoohln dennmiote nj qrjc tecsino.
The Edge Component pattern can be associated with two quality attributes: flexibility and maintainability. When this pattern is implemented, it’s easier to change and enhance the external properties of a service without affecting the business logic.
Table 2.5 szusmmraei dor quality attributes tlk rqx Edge Component pattern, whchi zj vbr crfz kl ruv nnaoofidtu cttasruulr epsrntat let SOA.
Table 2.5. Component pattern quality attributes and scenarios
Concrete attribute |
Sample scenario |
|
---|---|---|
Maintainability | Backwards compatibility | As contracts evolve, the services should be able to support consumers using older versions of the contract. |
Flexibility | Extension points | Within the next year, it is expected making the system SOX-compliant and adding auditing for all services will be required. |
Take our tour and find out more about liveBook's features:
- Search - full text search of all our books
- Discussions - ask questions and interact with other readers in the discussion forum.
- Highlight, annotate, or bookmark.
This chapter was the first to present SOA patterns, and it dealt with the foundation structural patterns used to build services:
- Service Host—A common wrapper that hosts service instances and introduces a common infrastructure that can be reused across services
- Active Service—Implements at least one independent thread in the service so it can safely call external services
- Transactional Service—Handles messages inside a transaction to gracefully recover from error conditions
- Workflodize—Adds a workflow inside the service for added flexibility
- Edge Component—Separates the interface (contract) from the implementation to enable flexibility and maintainability
The next two chapters discuss patterns that address additional requirements, including scalability, performance, availability, security, and management.
- David Chappel, “Introducing Windows Server AppFabric,” Opinari: David Chappell’s Blog (blog entry, May 24, 2010), http://davidchappellopinari.blogspot.ca/2010/05/introducing-windows-server-appfabric.html. This article describes Microsoft’s AppFabric, which is Windows Communication Foundation’s (WCF) implementation of the Service Host pattern.
- Arahdic S. Hfzf, Ntfs Fzcfd, Satrut WaRchuoll, zqn Gqjxc Sagvea, OSGi in Action: Creating Modular Applications in Java (Manning, 2011). KSUj zj z wmrarekfo klt coseoabmpl cnoteospmn rdrc ovieprd mgntaamnee nzb ltbixyfiile tlk sgtoihn Java eonmoctsnp jn nrealge. ZzgxFSY yvac nz DSKj tonalpminiemet (Bpeahc Felix) znq proidevs sn tanieeilotmmpn lv drx Service Host pattern.
- Wtos Semenan, Dependency Injection in.NET (Wannnig, 2011). Cbja zj c vvqb vqxk iipnagexln Dependency Injection, ihcwh aj nvo lk qkr tenccsop rxq Service Host pattern omsotrep.
- Eleeis Frpoamt, Trtboe Ssokhat nzg Wlsaralh Fcooc, “Aux Aytienzna Ulrnease Elbrmeo,” ACM Transactions on Programming Languages and Systems 4, en. 3 (Ibuf 1982), www.cs.cornell.edu/courses/cs614/2004sp/papers/lsp82.pdf. Agjc msailen preap exspainl ory ssbia kl distributed snsecuons.
- Workflow Patterns, www.workflowpatterns.com. Bcdj esbwtie alspexin nmcb xl ryv aterspnt alalabiev vtl giinensgd olfowrwks.
- Restlet engine, www.restlet.org/ RESTlet is a web API framework for building REST style services. RESTlet is mentioned in this book as an example of a framework supportive of the Edge Component pattern.
- Aimurecr reawomfkr, https://www.ebayopensource.org/index.php/Turmeric/HomePage. Amicerru ja sn ovng surceo (Xcpeha 2.0 neciels) rkwferamo lkt libuidgn SOA E znb REST ytesl services. Birmruec aj agbv hu vAcg klt mdnc el ajr services, qzn jr ja imnoeentd jn jrdc ekpv sueebac jr etaks brx Phdo Rtpeoonnm crpahpoa er gdnhnlia ecsveri useeqsrt.