Enterprise Integration Zone is brought to you in partnership with:

Mainak is an experienced Technology Consultant specializing in JEE, Web Development and Open source technologies. He is currently based out of United Kingdom. He is die hard technology enthusiast trying to explore the latest in the world of technology. In past time he loves blogging on his website: http://idiotechie.com. Mainak is a DZone MVB and is not an employee of DZone and has posted 11 posts at DZone. You can read more from them at their website. View Full User Profile

Introduction to JMS

  • submit to reddit


What is JMS?

Java Message Service (JMS) API is a part of the Java Enterprise Edition (JEE) specification. JMS is all about sending and receiving messages between two or more clients. It is a specification that describes a method by which Java programs to create, send and receive messages.
JMS API enables communication that is loosely coupled and messaging that is asynchronous in nature.

What is Messages?
A message has been described in various ways by different specification. However it is an entity of the communication. It is bytes of data that is meaningful between the applications which use it. Messages are used to transfer information from one application to other ones which may or may not run in same platforms.
What is Messaging?
Messaging is communication between system components or different applications (in a distributed environment) which are loosely coupled unlike its peers like TCP sockets, CORBA or RMI.Advantage of messaging:
The advantages of messaging include the ability to integrate different platforms, reduce system bottlenecks, increase scalability and reliability of message delivery.

A JMS Application consists of the following components:
JMS Provider: A messaging system that implements the JMS specification.

Messaging using MOM in JMS

Messaging using MOM in JMS

In JMS Message Oriented Middleware (MOM) plays a vital role which differentiates messaging from its peers. MOM is a component that helps in message communication between two systems connected across network.  MOM ensures asynchronous form of communication, supports reliable message delivery and transaction control. The Middleware creates a distributed communications layer that insulates the application developer from the details of the various operating system and network interfaces.

List of some of the MOM Service Providers:

MOM Service Provider Products Company
Weblogic Oracle
MQSeries IBM
SoniqMQ Progress
ActiveMQ Apache

JMS clients: Java applications that produce or receive messages.

  • JMS Producer / Publisher: A JMS client that creates and sends messages.
  • JMS Consumer/ Subscriber: A JMS client that receives messages.

Messages: Objects that are used to communicate information between JMS clients.

Administered objects: Pre-configured JMS objects that are created by an administrator for the use of JMS clients. These objects are isolated from the proprietary technology providers. This helps in JMS client’s portability.

Types of Messaging model:

Types of messaging domain model

Types of messaging domain model

As we discussed earlier a JMS application will have one or more JMS clients that exchange message asynchronously with the help of MOM.
There are two types of messaging model in JMS:

Point to Point Messaging in JMS

Point to Point Messaging in JMS

a) Point to Point (PTP): In the PTP diagram the point-to-point (PTP) domain or application has three primary components like message queues, senders, and receivers. Each message is addressed to a specific queue, and receiving clients extract messages from the queues established to hold their messages. Queues retain all messages sent to them until the messages are consumed or until the messages timeouts.

Pub/Sub Messaging Model

Pub/Sub Messaging Model

b) Publisher/ Subscriber (Pub/Sub): In the Pub/Sub diagram clients address messages to a topic. Publishers and subscribers are generally anonymous and can dynamically publish or subscribe to the content hierarchy. Topics retain messages only as long as it takes to distribute them to current subscribers.

Point to Point Publisher/ Subscriber
Each message has only one consumer Each message can have multiple consumers.
Messages are first sent to the destination named Queue. Messages are first published in the destination called Topic.
A sender and a receiver of a message have no timing dependencies. The receiver can fetch the message whether or not it was running when the client sent the message. Publishers and subscribers have a timing dependency. A client that subscribes to a topic can consume only messages published after the client has created a subscription, and the subscriber must continue to be active in order for it to consume messages.
The receiver acknowledges the successful processing of a message. Does not provide acknowledgement

Typical use of JMS in enterprise solutions:
a)JMS is useful where there might be requirement for pushing data to the consumers e.g. Bulletin board, News updates, Stock quotes, Auction websites etc.
b)Today the whole world is al about collaboration. Businesses and applications can interact with each other via messaging as JMS will allow them to integrate with each other without tight coupling.

In the next blogs we will explain more details on the implementation so keep watching this space. Please provide your feedback and comments on this article.

Published at DZone with permission of Mainak Goswami, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Mainak Goswami replied on Sat, 2012/11/17 - 4:42pm

Thanks to all my readers. Hope you have enjoyed the article.

Ram Krishnan replied on Mon, 2012/11/19 - 8:48am

Its very intro. please provide with java code and setup the environment. Its really helpful

Ram Krishnan replied on Mon, 2012/11/19 - 8:48am

Its very good intro. please provide with java code and setup the environment. Its really helpful

Mainak Goswami replied on Mon, 2012/11/19 - 2:38pm in response to: Ram Krishnan

@Ram. You can refer to my article How to implement a JMS PTP application  which consist of Java code and configuration. I have tried to use Weblogic server for configuration and implementation. Please get back to me in case of any query.

Ram Krishnan replied on Tue, 2012/11/20 - 12:15am in response to: Mainak Goswami

Hi thanks man.

John Ament replied on Wed, 2012/11/21 - 9:26am

JBossMQ is long since retired and replaced with HornetQ.  Also, Pub/Sub does support acknowledgement.  Your Pub/Sub column seems to be describing more about durable subscriptions than it is describing Pub/Sub.

Mainak Goswami replied on Wed, 2012/11/21 - 4:51pm in response to: John Ament

Thanks John for your feedback. I am using Weblogic Server to implement a PTP model. You can refer this article here - Create and Configure JMS Administered Objects  or http://idiotechie.com/?p=301 ..

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.