Вы находитесь на странице: 1из 10

TIBCO EMS Routing Design Patterns

Table of Contents
1 Introduction 4
2 Overview 5
2.1 JMS Queues 5
2.2 JMS Toics 5
2.! "estination #rid$in$ 5
2.4 %MS &outin$ '
! (oint to (oint &outin$ "esi$n (attern ..)
4 (ublis*+Subscribe &outin$ "esi$n (attern ,
5 S-nc*ronous &e.uest+&el- &outin$ "esi$n (attern 11
' /s-nc*ronous &e.uest+&el- &outin$ "esi$n (attern ..1!
Table of 0i$ures
0i$ure 1. %MS "estination #rid$in$ ..'
0i$ure 2. (oint1to1(oint &outin$ ....)
0i$ure !. (ublis*+Subscribe &outin$ ..,
0i$ure 4. (ublis*+Subscribe &outin$ wit* 2i$* 0an1out .13
0i$ure 5. S-nc*ronous &e.uest+&el- &outin$ .11
0i$ure '. /s-nc*ronous &e.uest+&el- &outin$ ..1!
1 Introduction
T*e urose of t*is docu4ent is to rovide so4e desi$n atterns for t*e routin$ of
4essa$es between %MS 5%nterrise Messa$e Service6 servers. T*is docu4ent s*ould not
be ta7en as a co4lete set of desi$n atterns8 and li7e all docu4ents of t*is t-e s*ould
be considered a wor7 in ro$ress. 2oefull-8 additional atterns will be added to t*is
docu4ent over ti4e.
Secificall-8 t*is docu4ent addresses routin$ desi$ns for t*e followin$ 4essa$e
e9c*an$e atterns:
; (oint to (oint
; (ublis*+Subscribe
; S-nc*ronous &e.uest+&el-
; /s-nc*ronous &e.uest+&el-
2 Overview
2.1 JMS Queues
In oint1to1oint 4essa$in$8 eac* 4essa$e *as one roducer and one consu4er. In JMS8
t*is st-le of 4essa$in$ uses a .ueue to store 4essa$es until t*e- are received. <nder
nor4al conditions8 t*e 4essa$e roducer sends t*e 4essa$e to t*e .ueue and receives an
ac7nowled$e4ent fro4 t*e %MS server of its successful lace4ent on t*e .ueue= t*e
4essa$e consu4er retrieves t*e 4essa$e fro4 t*e .ueue and sends an ac7nowled$e4ent
to t*e %MS server t*at t*e 4essa$e was received. #- default8 t*e 4essa$e will re4ain in
t*e %MS server>s .ueue until its receit *as been ac7nowled$ed.
2.2 JMS Toics
In t*e ublis*1subscribe 4essa$e st-le8 eac* 4essa$e is delivered to all t*e reciients
interested in t*e 4essa$e. T*is is acco4lis*ed t*rou$* t*e %MS server 4ec*anis4
7nown as a toic. T*e roducer sends t*e 4essa$e to t*e toic and receives an
ac7nowled$e4ent fro4 t*e %MS server after t*e 4essa$e *as been successfull- laced in
t*e toic. T*e consu4er retrieves t*e 4essa$e fro4 t*e toic and sends an
ac7nowled$e4ent to t*e %MS server t*at t*e 4essa$e was received. In contrast to a JMS
.ueue8 *owever8 t*e 4essa$e re4ains eli$ible for deliver- to ot*er subscribers. T*e
4essa$e will re4ain in t*e toic until all subscribers *ave received and ac7nowled$ed
t*e 4essa$e.
2.! Destination Bridging
%MS rovides a feature to send 4essa$es to 4ultile destinations called destination
brid$in$. / brid$e between destinations causes 4essa$es t*at are sent to one destination
to also be delivered to t*e brid$ed destination at t*e sa4e ti4e. #rid$es can be created
between one destination and one or 4ore ot*er destinations of t*e eit*er t*e sa4e or
different t-e. T*at is8 a brid$e can be created fro4 a toic to a toic8 a toic to a .ueue8
a .ueue to a toic8 or a .ueue to a .ueue.
In addition8 t*e %MS can e9ort JMS 4essa$es to &ende?vous and i4ort 4essa$es fro4
&ende?vous. &ende?vous 4essa$es can be i4orted into JMS toics and .ueues8 and
JMS toics can be e9orted to &ende?vous 4essa$es. %9ort of JMS .ueues is not
ossible.
0i$ure 1. %MS "estination #rid$in$
@*en a 4essa$e roducer sends a 4essa$e wit*in a transaction8 all 4essa$es sent across
a brid$e are art of t*e transaction. T*erefore8 if t*e transaction succeeds8 all 4essa$es
are delivered to all brid$ed destinations. If t*e transaction fails8 no consu4ers for brid$ed
destinations receive t*e 4essa$es.
2.4 %MS &outin$
%MS rovides t*e abilit- to route 4essa$es between servers.
/ route is a na4ed bi1directional connection between two %MS servers. %ac* route
forwards 4essa$es between corresondin$ destinations in t*e two servers. "estinations
corresond if t*e- are of t*e sa4e t-e and *ave t*e sa4e na4e in bot* servers. &outes
are secified via t*e %MS server ad4inistrative interfaces.
Once a route between %MS servers is confi$ured8 4essa$es are onl- eli$ible for routin$
between servers if all of t*e followin$ conditions are 4et:
; #ot* destinations *ave t*e sa4e na4e
; #ot* destinations are of t*e sa4e t-e 5i.e. bot* toics or bot* .ueues6
; #ot* destinations *ave t*e $lobal roert- is set to true. T*is indicates t*at
4essa$es sent to t*is destination are to be also sent alon$ an- confi$ured routes.
Message
Publisher
Message
Subscriber
EMS Server
Message
Message
Subscriber
Message
Message
Queue C
Message Message
Message Message
Message
Subscriber
Message
Consumer
TIBRV
Transport
Message
Message
Topic A
Topic B
Rendevous Bus
/ ?one is a set of na4ed routes8 and eac* route belon$s to a ?one. T*e ?one and its
roerties deter4ine t*e 4essa$e forwardin$ be*aviour between routes. T*ere are two
t-es of ?ones: one1*o and 4ulti1*o. In a one1*o ?one8 4essa$es will onl- be
forwarded once8 fro4 one server to anot*er: no furt*er roa$ation of t*e 4essa$e will
occur. In a 4ulti1*o ?one8 4essa$es can be forwarded across as 4an- routes as
necessar- to reac* all destinations.
/ server can *ave routes t*at belon$ to several ?ones. @*en ?ones overla at a server8 t*e
routin$ be*aviour wit*in eac* ?one does not li4it routin$ in ot*er ?ones. T*at is8 w*en a
forwarded 4essa$e reac*es a server wit* routes in several ?ones8 t*e 4essa$e crosses
?one boundaries8 and its *o count is reset to ?ero.
0or toic1based 4essa$es to be routed between servers8 t*e eli$ibilit- criteria for routin$
5above6 4ust first be 4et. @*et*er or not 4essa$es are actuall- forwarded to a toic on
anot*er server deends on w*et*er or not t*at server is on t*e at* to a 7nown subscriber
to t*e toic. <nless selectors *ave been secified8 all 4essa$es sent to a $lobal toic are
forwarded to all routed servers t*at *ave subscribers for t*at toic 5and8 of necessit-8 an-
servers on t*e route in between6.
Confi$urin$ .ueues for routin$ is so4ew*at different t*an for toics. In routin$ toics8
t*e declaration of t*e toic is identical on all servers 5wit* t*e ossible e9cetion of a
4essa$e selector6. Queue declarations8 on t*e ot*er *and8 4a7e a distinction between t*e
server t*at owns t*e .ueue and ot*er servers wit* routed .ueues t*at reference bot* t*e
.ueue na4e and t*e ownin$ server.
&outed .ueues serve as ro9ies for t*e real .ueue. Messa$es t*at are ublis*ed to t*e
ro9- .ueue are forwarded to t*e real .ueue8 and are not eli$ible for deliver- until t*e-
reac* t*e real .ueue. If t*e route fro4 t*e ro9- .ueue to t*e real .ueue is bro7en8 t*e
4essa$e will re4ain in t*e ro9- .ueue until suc* ti4e as t*e route is restored.
Meanw*ile8 t*e 4essa$e is not eli$ible for deliver- w*ile it sits in t*e ro9- .ueue. @*ile
clients can connect to t*e ro9- .ueue to receive 4essa$es8 t*e 4essa$e re4ains in t*e
real .ueue until t*e client re.uests a 4essa$e. T*e conse.uence is t*at if t*e route fro4
t*e ro9- .ueue to t*e real .ueue is bro7en8 no clients attac*ed to t*e ro9- .ueues can
receive 4essa$es until t*e route is restored. Aote t*at active and assive routes do not
i4act t*e forwardin$ of 4essa$es for .ueues.
Queue 4essa$es can be routed at 4ost one *o fro4 t*e server t*at owns t*e .ueue.
So4eti4es alications on different servers are onl- interested in a subset of t*e
4essa$es bein$ ublis*ed on a toic. &outin$ t*ese 4essa$es to all alications can be
e9ensive in ter4s of networ7 bandwidt* between t*e %MS servers8 articularl- if t*is is
a @/A connection. In t*ese circu4stances it is reasonable to consider t*e use of a
4essa$e selector to filter t*e 4essa$es bein$ routed fro4 one server to anot*er. 2owever8
it s*ould be reco$ni?ed t*at t*e use of selectors will *ave a erfor4ance i4act on t*e
%MS server8 as t*e selector e9ression will *ave to be evaluated for ever- 4essa$e on t*e
toic.
! Point to Point Routing Design Pattern
T*e dia$ra4 below s*ows *ow a si4le oint1to1oint .ueue attern 4a- be e9tended
across 4ultile %MS servers. / $lobal toic would be created to route 4essa$es between
%MS servers and destination brid$es confi$ured to connect t*e toic and .ueue to$et*er.
T*e use of routed toics is referred since t*e advanced routin$ caabilities of toics
allow scalin$ t*e nu4ber of servers be-ond t*e one1*o restriction wit* .ueues.
T*e roducer could still send 4essa$es to t*e sa4e .ueue8 w*ic* would e9ist on t*e
roducer>s server8 *owever since 4essa$es are coied and not 4oved across a brid$e t*e
.ueue 4ust be confi$ured aroriatel- to revent 4essa$e build u.
/lternativel- t*e roducer 4a- be c*an$ed to ublis* directl- to t*e routed toic8 t*ereb-
ne$atin$ t*e need for t*e roducer side .ueue.
0i$ure 2. (oint1to1(oint &outin$
Topic!
T"#$
Queue!
Q"#$
EMS Server
Message
Persistence
Topic!
T"#$
Message
Persistence
Producer
Consumer
Routed Topic
Queue!
Q"#$
EMS Server
&e.uired roert- confi$uration for roducer1side .ueue:
; 4a94s$s B 1
; overflow(olic- B discardOld
&e.uired roert- confi$uration for routed toic 5bot* roducer1side and consu4er1side6:
; $lobal
Aote= if aut*entication and er4issions are enabled8 it is not necessar- to $rant t*e
roducer or consu4er user er4ission to access t*e routed toic. T*e secure roert-
4a- be enabled on t*e routed toic to revent an- direct user access8 *owever access
4ust be $ranted for t*e %MS server user t*at t*e route is connected to.
4 (ublis*+Subscribe &outin$ "esi$n (attern
In a ublis*+subscribe scenario it is $enerall- referred for consu4ers to read fro4
.ueues rat*er t*an use durable toic subscribers8 because:
; Queues are easier to 4ana$e8 for e9a4le8 .ueues can be browsed and 4essa$es
ur$ed for one consu4er wit*out affectin$ ot*er consu4ers.
; Queues suort load1balancin$ across 4ultile consu4ers
; (ro9- 5or re4ote6 .ueues can be used for *i$* fan1out scenarios.
T*e dia$ra4 below s*ows an e9a4le ublis*+subscribe routin$ attern w*ere eac*
consu4er *as a dedicated .ueue to receive 4essa$es. Selectors 4a- be secified on t*e
toic to .ueue brid$es for filterin$8 so consu4ers onl- receive 4essa$es of interest. T*is
is referable t*an use of selectors at t*e consu4er1side.
0i$ure !. (ublis*+Subscribe &outin$
&e.uired roert- confi$uration for routed toic 5bot* roducer1side and consu4er1side6:
; $lobal
0or *i$* fan1out scenarios across 4an- consu4ers8 clients can connect to a far4 of %MS
servers8 as s*own in t*e dia$ra4 below.
T*e %MS servers in t*e server far4 *ave ro9ies for t*e ri4ar- .ueues8 eac* %MS
server in t*e far4 will *ave t*e sa4e confi$uration of ro9- .ueues and clients 4a-
connect to an- %MS server in t*e far4.
Topic!
T"#$
Queue!
Q"#$C"
Queue!
Q"#$C#
Message
Persistence
Topic!
T"#$
Message
Persistence
Producer
Consumer"
Consumer#
Routed Topic
EMS Server EMS Server
T*e ro9ies do not actuall- contain t*e 4essa$es8 and no 4essa$es are ever stored in t*e
server far4. T*e ro9- .ueue retrieves 4essa$es fro4 t*e ri4ar- .ueue on de4and and
delivers t*e4 to t*e client8 s*ould a client receive a 4essa$e but not ac7nowled$e t*e
4essa$e t*e 4essa$e would re4ain ersisted on t*e %MS server *ostin$ t*e ri4ar-
.ueue.
0i$ure 4. (ublis*+Subscribe &outin$ wit* 2i$* 0an1out
&e.uired roert- confi$uration for ri4ar- 5*o4e6 .ueue:
; $lobal
&e.uired roert- confi$uration for ro9- 5re4ote6 .ueue:
; confi$uration na4e B .ueueCna4eDri4ar-CserverCna4e
; $lobal
Topic!
T"#$
Queue!
Q"#$C"
SA%
Queue!
Q"#$C#
Message
Persistence
Consumer"
Consumer#
EMS Server
&in 'A (arm)
Pro*+ Queue!
Q"#$C"
Pro*+ Queue!
Q"#$C#
,

,

,
EMS Server
&in 'A (arm)
Pro*+ Queue!
Q"#$C"
Pro*+ Queue!
Q"#$C#
EMS Server
&in 'A (arm)
Pro*+ Queue!
Q"#$C"
Pro*+ Queue!
Q"#$C#
Routed Topic
EMS Server
Consumer%
,

,

,
5 S-nc*ronous &e.uest+&el- &outin$ "esi$n (attern
T*e dia$ra4 below s*ows an e9a4le s-nc*ronous re.uest+rel- routin$ attern. /$ain
toics are used for routin$ re.uest and rel- 4essa$es8 for t*e sa4e reasons as described
above.
/ te4orar- toic is created for t*e rel- 4essa$e8 t*e lifeti4e of t*e te4orar- toic is
onl- for t*is re.uest+rel- oeration8 and it will auto4aticall- be deleted once t*e rel-
4essa$e *as been consu4ed. It is i4ortant t*at t*e receiver s*ould set an e9ir- ti4e on
t*e rel- 4essa$e to ensure t*e te4orar- is deleted in case t*at re.uester s*ould ti4eout
waitin$ for t*e rel-.
0i$ure 5. S-nc*ronous &e.uest+&el- &outin$
&e.uired roert- confi$uration for routed toic 5bot* roducer1side and consu4er1side6:
; $lobal
Aote: Te4orar- toics are auto4aticall- routed and no secial confi$uration is re.uired.
&e.uestor1side rocessin$:
1. Create re.uest toic ublis*er
2. Create re.uest 4essa$e
!. Create a new te4orar- rel- toic
4. Create subscriber to t*e te4orar- rel- toic
5. Set JMS&el-To roert- in re.uest 4essa$e to te4orar- rel- toic
'. (ublis* re.uest 4essa$e to re.uest toic
E. &eceive rel- fro4 te4orar- rel- toic wit* ti4eout secified
Aote= t*e subscriber to t*e te4orar- rel- toic 4ust be created before t*e re.uest
4essa$e is sent.
/ $eneric receiver can be desi$ned for bot* s-nc*ronous and as-nc*ronous 4essa$e
atterns. In fact t*e receiver s*ould not need to 7now8 or care w*ic* attern t*e roducer
client is usin$. T*e followin$ stes describe an e9a4le of receiver1side rocessin$ for
bot* s-nc*ronous and as-nc*ronous 4essa$e atterns.
&eceiver1side rocessin$:
1. Create re.uest .ueue consu4er
2. Create $eneric roducer
!. &eceive 4essa$e fro4 re.uest .ueue
Topic!
T"#$
Queue!
Q"#$
Message
Persistence
Topic!
T"#$
Message
Persistence
Re-uestor
Receiver
Routed Topics
Topic!
.TMP///
Topic!
.TMP///
EMS Server EMS Server
4. (rocess re.uest
5. Create rel- 4essa$e
'. &etrieve t*e JMSCorrelationI" roert- fro4 re.uest 4essa$e
E. (roa$ate t*e JMSCorrelationI" roert- fro4 re.uest 4essa$e to t*e
JMSCorrelationI" roert- in t*e rel- 4essa$e
). &etrieve t*e JMS&el-To roert- fro4 re.uest 4essa$e
,. If rel- destination na4e starts wit* FGTM(.H set e9ir- ti4e on rel- 4essa$e
13. "eter4ine deliver- 4ode for resonse 5e.$. if deliver- 4ode of re.uest B
(%&SIST%AT and rel- destination na4e does not start wit* GTM( t*en use
(%&SIST%AT else use AOAC(%&SIST%AT6
11. Send rel- 4essa$e to destination secified in JMS&el-To
Aote= te4orar- toics will not survive a server restart. If durabilit- is re.uired a non1
te4orar- toic and a correlation id s*ould be used8 as described in t*e ne9t section for
as-nc*ronous re.uest+rel-. T*e re.uester can s-nc*ronousl- wait for t*e correct rel-
b- secif-in$ a selector on t*e JMSCorrelationI" roert-.
' /s-nc*ronous &e.uest+&el- &outin$ "esi$n (attern
T*e dia$ra4 below s*ows an e9a4le as-nc*ronous re.uest+rel- routin$ attern. /$ain
toics are used for routin$ re.uest and rel- 4essa$es8 for t*e sa4e reasons as described
above.
/ non1te4orar- toic is created for t*e rel- 4essa$e. T*e lifeti4e of t*e rel- toic is
onl- for t*is re.uestor and it will be used for receivin$ 4ultile relies8 ossibl- fro4
different receivers. &e.uests and relies are correlated to$et*er usin$ t*e standard
JMSCorrelationI" *eader roert-. T*e re.uestor 4ust create and set t*e
JMSCorrelationI" roert- in t*e re.uest8 and t*e receiver 4ust co- t*is into t*e rel-.
0or durabilit- of relies a durable toic subscriber 4a- be used or t*e rel- toic can be
brid$ed to a rel- .ueue at t*e re.uestor side.
Topic!
T"#$
Queue!
Q"#$
Message
Persistence
Re-uestor"
Receiver
Routed Topics
Topic!
T"#$
Message
Persistence
Topic!
T"#$R"
Topic!
T"#$R"
EMS Server EMS Server

0i$ure '. /s-nc*ronous &e.uest+&el- &outin$
&e.uired roert- confi$uration for routed toic 5bot* roducer1side and consu4er1side6:
; $lobal
; e9ir- override 4a- be set on rel- toic if re.uired
Toics 4a- be created d-na4icall-8 as lon$ as t*e na4e confor4s to a well1defined
na4in$ standard8 suc* t*at t*e toic in*erits t*e $lobal roert- settin$. T*is is
articularl- desirable on t*e receiver1side8 since it would be cu4berso4e to confi$ure
rel- toics for ever- otential re.uestor.
&e.uestor1side rocessin$:
1. Create re.uest toic ublis*er
2. Create resonse toic subscriber
!. Create re.uest 4essa$e
4. Set JMS&el-To roert- in re.uest 4essa$e to rel- toic
5. Ienerate a uni.ue identifier for t*is re.uestor
'. Set JMSCorrelationI" roert- in t*e re.uest to t*e uni.ue identifier for re.uest
E. (ublis* re.uest 4essa$e to t*e re.uest toic
). &eceive rel- fro4 rel- toic via 4essa$e listener
,. <se JMSCorrelationI" roert- in rel- 4essa$e to correlated t*e rel- wit* a
revious re.uest.
/ $eneric receiver can be desi$ned for bot* s-nc*ronous and as-nc*ronous 4essa$e
atterns. In fact t*e receiver s*ould not need to 7now8 or care w*ic* attern t*e roducer
client is usin$. T*e followin$ stes describe an e9a4le of receiver1side rocessin$ for
bot* s-nc*ronous and as-nc*ronous 4essa$e atterns.
&eceiver1side rocessin$:
1. Create re.uest .ueue consu4er
2. Create $eneric roducer
!. &eceive 4essa$e fro4 re.uest .ueue
4. (rocess re.uest
5. Create rel- 4essa$e
'. &etrieve t*e JMSCorrelationI" roert- fro4 re.uest 4essa$e
E. (roa$ate t*e JMSCorrelationI" roert- fro4 re.uest 4essa$e to t*e
JMSCorrelationI" roert- in t*e rel- 4essa$e
). &etrieve t*e JMS&el-To roert- fro4 re.uest 4essa$e
,. If rel- destination na4e starts wit* FGTM(.H set e9ir- ti4e on rel- 4essa$e
13. "eter4ine deliver- 4ode for resonse 5e.$. if deliver- 4ode of re.uest B
(%&SIST%AT and rel- destination na4e does not start wit* GTM( t*en use
(%&SIST%AT else use AOAC(%&SIST%AT6
11. Send rel- 4essa$e to destination secified in JMS&el-To

Вам также может понравиться