What is JMS?
JMS Is the short form of Java Message Service. JMS is a Java API that permits different applications to create and transmit messages to each other using a communication protocol. This communication protocol is designed using J2EE technology and it offers an effective communication that is asynchronous, reliable and loosely coupled.
Java Message Service offers following messaging services:
- Creating a Message
- Sending the created Message
- Receiving the sent message
- Reading the received message
JMS Programming Model
Message transmission is achieved through JMS Programming Model that is depicted below:
As shown in the JMS Programming Model diagram, JMS application is encompassed of six building blocks:
(i) Administered Objects
JMS application offers two different types of administered objects namely:
Connection Factory – The connection factory is used to establish connection with the provider.
Destination – The Destination indicates where the produced messages are targeted to and the source of messages that are consumed.
The connection factory and destination are created in the JMI provider with the help of admin console of the application server. These objects will be stored in the JNDI directory of application server.
(ii) JMS Connection
JMS Connection refers to the virtual connection that is established with the provider.
(iii) JMS Session
JMS Session is used for creating the Message Producers (to produce messages) and Message Consumers (to consume messages).
(iv) JMS Message Producer
JMS Message Producer is an object that is intended to send messages to the corresponding Destination.
(v) JMS Message Consumer
JMS Message Consumer is an object that is intended to receive messages that are sent at a particular Destination.
(vi) JMS Message Listener
JMS Message Listener is an object which tends to behave as asynchronous event handler for the messages. When a message arrives at a destination, corresponding set of actions to be taken place is defined in the JMS Message Listener.