If you are using JMS as the back bone of your EDA, choose Topics (i.e., pub/sub) for 99% of your Destinations. I guess that is pretty obvious - I guess it is more applicable to the Messaging-Centric ESB world.
Exceptions where I think Queues are appropriate:
- Error Queues
- Existing integrations that have queues (I'd still route it through a Topic before it got there)
There are other times where Queues are appropriate, but just triple check that it is appropriate and if in doubt, use a Topic instead.
Topics have a lot of benefits over Queues:
- Facilitate event driven architecture
- Not Point-to-Point (you have a prayer against the n(n-1) problem (where n= # of systems to integrate)
- Very flexible if using in a event workflow - can fan out/fan in easily
- Ease of debugging (can snoop on a Topic)
- Can do 1:M Request/Reply (one request, get N responses)
Also, use hierarchical Topic names. Hierarchical Topic names are great because they:
- Help to avoid dependence on message selectors (slower)
- Organize things
- Enable listening to a pattern - for example:
If you have Topics in this pattern (several different "EVENTTYPE" values: COMPANYNAME.DIVISION.PRODUCTLINE.PRODUCT.NOUN.EVENTTYPE
Say you are interested in all of the event types ... you can listen to them like this: COMPANYNAME.DIVISION.PRODUCTLINE.PRODUCT.NOUN.*
Unless you don't need it, use durable subscriptions with your Topics - they work great and will bail you out of some hairy situations. While durable subscriptions were originally intended for momentary connection problems, they can be used to help bridge the EDA & batch world. You can register a durable subscription and then just connect to it at night for instance. You accumulate events all day on the durable subscription and then just drain it as part of the batch run.
To be fair on my Topic preference, I do take advantage of a SonicMQ feature that makes a Topic like a Queue in terms of the ability to have competing consumers (i.e., different connections (can be on different hosts) competing to drain the queue) (Shared Subscriptions). Other vendors do similar things. It is a pity really that Sonic's "Shared Subscriptions" isn't in the JMS spec.
No comments:
Post a Comment