Monday, June 14, 2010

JMS-Messaging Models

Java Message Service (JMS) API allows Java applications to implement messaging using a standard API. The Java Message Service (JMS) has defined the standard for reliable Enterprise Messaging. JMS(API) is a part J2EE specifications and was developed by Sun Microsystems(Now Part of Oracle Corp.).

JMS API provides following advantages to enterprise applications:

a. Loose coupling
b. Scalability
c. Asynchronous messaging
d. Reliable message sending
e. Heterogeneity
f. Modularity

JMS is composed of following parts:

JMS provider:
it provides administrative and control features andimplements the JMS interfaces.
JMS clients: Components that produce and consume messages.
Messages: Object that carry information between JMS clients.
Administered objects: preconfigured JMS objects which are used by clients and are created by administrators.Eg. Destination and Connection Factories.
Native clients: Programs that uses some messaging product’s native client API instead of JMS API.

Messaging systems support following messaging models:

Publish-Subscribe Messaging
Point-to-Point Messaging

Publish-Subscribe Messaging

This model is used when several applications need to receive the same message. In Publish-Subscribe messaging system, multiple publisher can send messages to a Topic and all the Subscribers to that topic receive all the messages sent to that Topic. In a Publish Subscribe Messaging there may be multiple Senders and multiple Receivers. Publishers and subscribers are generally anonymous and may dynamically publish or subscribe to the content.


Point-to-Point Messaging


In this model, a producer sends messages to a particular queue and a consumer gets messages from the queue. Queues retain all messages sent to them until the messages are consumed or until the messages expire. Only one consumer will get the message and producer will know the consumer of the message.

Consumption of Messages

Messages sent using above two messaging models can be received /consumed in following two ways:

Synchronous: The message is fetched from destination by calling the receive method.
Asynchronous: By registering a message listener. When a message arrives at the destination, the JMS provider delivers the message by calling the listener's onMessage method.

No comments:

Post a Comment