Friday, February 18, 2011

Why do we need JMS?

What is JMS(Java Message Service)?

A specification (API)  that describes a common way for Java programs to create, send, receive and read distributed enterprise messages. Its basically meant for object communication in multithreaded & heterogeneous environment.

It enables
  • loosely coupled communication (not like RMI or CORBA)
  • Asynchronous messaging
  • Reliable delivery (a message is guaranteed to be delivered once and only once)

Best examples where we can use JMS are “Enterprise Chat Application” & “Stock Trading Application”.

All the major vendor (IBM, Oracle, Apache, Google etc) has given its implementation. Its also available as a add-on of application server like Oracle Weblogic Server, JBOSS etc.

Why do we need it?

It will be useful when you are writing some event based applications like Chat Server which needs a publish kind of event mechanism to send messages between the server to the clients who got connected with the server.

Its different from RMI, in JMS there is no need for the destination object to be available online while sending a message from the client to the server. But in RMI it is necessary. So we can use JMS in place of RMI where we need to have loosely-coupled mechanism.


JMS is the distributed enterprise messaging API. You can use these API in order to develop your own application or you can 3rd party implementation like IBM MQServies.  We will choose JMS if there is a requirement of enterprise messaging application that requires to send/receive huge number of messages in reliable environment.