Monday, April 12, 2010

JMS - a quick walk-thru of concepts

Java Message Service is an asynchronous communication mechanism in the distributed system field. JMS  API is a Java Message Oriented Middleware (MOM) API for sending messages between two or more clients. It is very helpful in the situation where the distributed components are loosely coupled. Another popular distributed communication technology is Remote Method Invocation (RMI), which is tightly coupled and requires an application to know a remote application's methods. Java Message Service Specification 

Characteristics of JMS
1. Messages can be consumes sync or async
2. Consumers can filter which message they receive
3. Messages are placed in Destination in sent order
4. Message consumption order cannot be guaranteed

Elements
·      Connection
·      Session
·      Message Producer & Message Consumer
·      Destination
·      Message


Message Models
  • Point-to-Point or P2P (Queuing Model) &
  • Publisher-Subscriber or Pub-Sub (eg: Topic)

 JMS queue




A staging area that contains messages that have been sent and are waiting to be read. Note that, contrary to what the name queue suggests, messages don't have to be delivered in the order sent. If the message driven bean pool contains more than one instance then messages can be processed concurrently and thus it is possible that a later message is processed sooner than an earlier one. A JMS queue only guarantees that each message is processed only once.

JMS topic





A distribution mechanism for publishing messages that are delivered to multiple subscribers. A good analogy for this is an anonymous bulletin board.


Programming

Queue vs Topic



JMS as Administered Object 
It is recommended to use JNDI lookups. This promotes loose-coupling - an important aspect of SOA.


 
Steps involved:



Reliable Messaging done thru use of:
  1. Persistent Message Store and
  2. Acknowledgement or Transaction

No comments:

Post a Comment