JMS and ESB - how they are related?

afrish picture afrish · Mar 16, 2011 · Viewed 17k times · Source

For me JMS and ESB seem to be very related things and I'm trying to understand how exactly they are related.

I've seen a sentence that JMS can be used as a transport for ESB - then what else except the transport should be present in such an ESB? Is JMS a simple ESB or if not, then what it lacks from the real ESB?

Answer

djna picture djna · Mar 16, 2011

JMS offers a set of APIs for messaging: put a message on a queue, someone else, sometime later, perhaps geographically far away takes the message off the queue and processes it. We have decoupled in time and location of the message provider and consumer. Even if the message consumer happens to be down for a time we can keep producing messages.

JMS also offers a publish/subscribe capability where the producer puts the message to a "topic" and any interested parties can subscribe to that topic, receiving messages as and when they are produced, but for the moment focus just on the queue capabilty.

We have decoupled some aspects of the relationship between provider and consumer. However some coupling remains. First, as things stand every message is processed in the same way. Suppose we want to introduce different kinds of processing for different kinds of messages:

 if ( message.customer.type == Platinum )
      do something special

Obviously we can write code like that, but an alternative would be to have a messaging system that can send different messages to different places we set up three queues:

 Request Queue, the producer(s) puts their requests here
 Platinum Queue, platinum consumer processing reads from here
 Standard Queue, a standard consumer reads messages from here

And then all we need is a little bit of cleverness in the queue system itself to transfer then messsage from the Request Queue to the Platinum Queue or Standard Queue.

So this is a Content-Based Routing capability, and is something that an ESB provides. Note that the ESB uses the fundamental Queueing capabilities offered by JMS.

A second kind of couppling is that the consumer and producer must agree about the message format. In simple cases that's fine. But when you start to have many producers all putting message to the same queue you start to hit versioning problems. New message formats are introduced but you don't want to change all the existing providers.

  Request Version 1 Queue  Existing providers write here
  Request Version 2 Queue  New provider write here, New Consumer Reads here

And the ESB picks up the Version 1 Queue messages and transforms them into Version 2 messages and puts them onto the Version 2 queue.

Message transformation is another possible ESB capability.

Have a look at ESB products, see what they can do. As I work for IBM, I'm most familiar with WebSphere ESB