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 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.
An Enterprise Application may have ‘n’ number of components and they are exchanging messages by using one of the Messaging System as shown below.
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.
- 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.
A typical JMS system contains the following components:
- 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.
- 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.
- 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.
- JMS Message: an object that contains the data being transferred between JMS clients.
Most popular JMS Providers
|S.No.||JMS Provider Software||Organization|
|2.||Weblogic Messaging||Oracle Corporation|
|3.||Active MQ||Apache Foundation|
|4.||Rabbit MQ||Rabbit Technologies(acquired by Spring Source)|
|6.||Sonic MQ||Progress Software|
|8.||Open MQ||Oracle Corporation|
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|
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