JMS Tutorial – What is JMS

Filed Under: JMS

Nowadays, most of the enterprise applications are using messaging concept for asynchronous communication between heterogeneous applications using JMS or AMQP. I’m going to deliver a series of posts to discuss these concepts in detail with real-time examples in my coming posts.

JMS

  • JMS is the acronym for Java Messaging System.
  • JMS is part of Java EE.
  • JMS API is the implementation to handle the producer-consumer problem.
  • JMS API allows us to create, send, receive, and read messages.
  • Some o the benefits of using JMS are – loosely coupled application, reliability, and asynchronous communication.

What is Message?

The message is a piece of information. It can be a text, XML document, JSON data or an Entity (Java Object) etc. The message is very useful data to communicate between different systems.

What is Messaging?

Messaging means exchanging information between different components in the same system or different systems. It can happen in either a synchronous manner or an asynchronous manner.

What is JMS?

JMS stands for Java Message Service. JMS API is a Java API which contains a common set of interfaces to implement enterprise based messaging systems. JMS API is used to implement Messaging systems in Java-based applications only, it does not support other languages.

JMS API is used to create, send, receive and read messages or exchange messages between different systems. Once we develop a Java Messaging System with JMS API, then we can deploy the same application in any JMS Provider software.

JMS Architecture

JMS Architecture

An Enterprise Application may have ‘n’ number of components and they are exchanging messages by using one of the Messaging System as shown below.

JMS Messaging System

JMS Messaging System

Some Enterprise applications may have ‘n’ number systems and they exist in different locations. They use different platforms. If they want to exchange information in a loosely coupled manner, then we should use JMS Messaging system.

JMS in Distributed Systems

JMS in Distributed Systems

JMS Advantages

  • Loosely Coupled: We can develop loosely coupled applications very easily. That means JMS API is standard or specification that should be implemented by all JMS Providers so that we can change existing JMS Provider to new JMS Provider with little changes (that means only configurations) or without changing our JMS Application code.
  • Asynchronous: We can develop asynchronous messaging applications very easily. That means JMS Sender can send messages and continue on its own work. It does not wait for the completion of message consumption by JMS Receiver.
  • Robust and Reliable: JMS ensures that a message is delivered one and only once to the destination system. So we can develop reliable applications very easily.
  • Interoperability: JMS API allows Interoperability between other Java Platform languages like Scala and Groovy.

JMS Components

A typical JMS system contains the following components:

  1. JMS Client: Java program used to send (or produce or publish) or receive (or consume or subscribe) messages.
    • JMS Sender: JMS Client which is used to send messages to the destination system. JMS sender is also known as JMS Producer or JMS Publisher.
    • JMS Receiver: JMS Client which is used to receive messages from Source system. JMS Receiver is also known as JMS Consumer or JMS Subscriber.
  2. JMS Provider: JMS API is a set of common interfaces, which does not contain any implementation. JMS Provider is a third-party system who is responsible to implement the JMS API to provide messaging features to the clients.

    JMS Provider is also known as MOM (Message Oriented Middleware) software or Message Broker or JMS Server or Messaging Server. JMS Provider also provides some UI components to administrate and control this MOM software.

  3. JMS Administered Objects: JMS Objects which are preconfigured by an administrator for the use of JMS clients. They are ConnectionFactory and Destination Objects.
    • ConnectionFactory: ConnectionFactory object is used to create a connection between Java Application and JMS Provider. It is used by Application to communicate with JMS Provider.
    • Destination: Destinations are also JMS Objects used by a JMS Client to specify the destination of messages it is sending and the source of messages it receives. There are two types of Destinations: Queue and Topic.
  4. JMS Message: an object that contains the data being transferred between JMS clients.

Most popular JMS Providers

S.No. JMS Provider Software Organization
1. WebSphere MQ IBM
2. Weblogic Messaging Oracle Corporation
3. Active MQ Apache Foundation
4. Rabbit MQ Rabbit Technologies(acquired by Spring Source)
5. HornetQ JBoss
6. Sonic MQ Progress Software
7. TIBCO EMS TIBCO
8. Open MQ Oracle Corporation
9. SonicMQ Aurea Software

History of JMS API

S.No. JMS API Version Released Date
1. JMS 1.0.2 June 2001
2. JMS 1.1 March 2003
3. JMS 2.0 May 2013

Conclusion

JMS API is a robust way to implement a messaging system in our applications. There are various popular JMS providers including AMQP from Spring framework.

Reference: Wikipedia Article

Comments

  1. Mantu says:

    thank you so much. It is really a nice article to start with JMS.

  2. Raushan says:

    Indeed a nice article. I’m delighted.

  3. Vijay Rajgor says:

    short and sweet superb

  4. ADKaran says:

    I need to know how can implement JMS application in netbeans IDE with glassfish server .

  5. Pradeesh says:

    Wonderful introduction… superb

  6. shariq says:

    its a nice post ,explained very clearly

  7. JOHNYBASHA SHAIK says:

    Please correct the typos. Nice post and thanks for starting JMS series.

  8. Rahul Sathe says:

    nice article… well keep glued for the next ones… thanks for writing..

Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages