Overview of JMS (Java Messaging Service)
JMS is like a JDBC(Java Database connectivity) API, JDBC API can be used to access different relational databases, similarly JMS API can be used to access different enterprise messaging systems (3rd party JMS providers) like JBoss Messaging, WebSphereMQ, BEA Weblogic, Active MQ, Rabbit MQ, HornetQ, Sonic Q, TIBCO EMS, Open MQ etc...
These messaging systems would handle routing and delivery of messages(objects).
The JMS API will be implemented by the JMS providers
other names for the JMS provider: MOM(Message oriented Middleware), Message Broker, JMS server, Messaging server.
The JMS code is not gonna change if we change the JMS provider, i.e. the same JMS code fits a JBoss messaging system or a WebSphere MQ system or a BEA Weblogic system
Connection Factory and Destinations are two types of JMS administered objects which are preconfigured by the administartor. Connection factory objects are used for connecting the JMS client with the JMS provider, Destinations(Queues and Topics) are used by a JMS client to specify the source / destination of the messages it receives / sends respectively.
Different actors in a JMS application
producer or consumer is a java application or a component in a java application
producer sends messages through the JMS provider
consumer receives messages through the JMS provider
a java application using jms(jms client) can also act as both producer/consumer
it could subscribe to topics to receive messages from those topics, it can also publish to some other topics
all these components together(3 clients and one provider as in the example above) comprise of a single JMS application. a JMS application is a business system composed of many jms clients and typically one jms provider
2 JMS models are available - point to point (one-to-many) queues model and publish/subscribe(one-to-one) topics model
Publish/Subscriber model: one publisher, many subscribers, the publisher publishes messages to a topic and many subscribers can receive messages that are published by the publisher to the subscribed topic
Publishers are Subscribers are generally anonymous
Topics are like bulletin boards and are responsible to hold and deliver messages. Topics are defined in the JMS provider system by administering it through the UI. Topics would retain the messages until they are distributed to the present clients.
The subscribers would both consume the message and subsequently acknowledge it.
There is timing dependency, the subscriber must continue to be active in order for it to consume messages.
Point-to-Point model:
sender sends message to a queue, that message is gonna be picked by only one of the many possible receivers, once its picked by one receiver, other receivers are not gonna get that message
Queue would retain messages until its consumed or expired
In the above example, only receiver 2 receives the message from the sender. The receiver would both consume the message and subsequently acknowledge it.
There is no timing dependency, the receiver can fetch a message either it's active or not when the sender sends the message
--end-of-post--