Spring Book – Chapter 17 – Messaging with Spring

JMS Providers

JMS is a part of the Java Platform, Enterprise Edition, and is defined by a specification developed under the Java Community Process as JSR 914. To use JMS, one must have a JMS provider that can manage the sessions and queues.

There are lots of JMS implementations both commercial and open-source. Some of the well known commercial JMS providers are:

  • Websphere MQ from IBM
  • Swift MQ
  • Sonic MQ from Progress Software

Some of the well known open source JMS providers are:

  • OpenJMS from OpenJMS Group
  • Apache ActiveMQ
  • JORAM from OW2 Consortium

Figure 18-7 shows typical JMS components along with the various JMS providers in market today. The JMS providers shown in the figure are just for examples and I don’t have any favoritism towards any of those.

 Figure 18-7. JMS components along with sample providers

Figure 18-7. JMS components along with sample providers

JMS Architecture

Having understood the various components in JMS, I think its ideal time to look into the architecture of the JMS. A typical JMS application consists of following components:

  • JMS Provider – messaging system which implements the JMS specification.
  • JMS Client (Producer and Consumer) – Java applications which sends and receives messages.
  • Message – objects used to communicate information between the Java clients.
  • Administered Objects – preconfigured objects maintainer by a container which are kept to be used by the Java clients.

Figure 18-8 shows the JMS components and overall architecture on which JMS specification is based.

 Figure 18-8. JMS architecture

Figure 18-8. JMS architecture

Spring JMS

The Spring Framework provides built-in support for JMS and provides a level of abstraction away from the developers which greatly simplifies the development of messaging-based applications.

Spring supports building application based both synchronous and asynchronous messages. It supports synchronous message sending and receiving by providing Spring’s conventional Template patter for JMS called as JmsTemplate. For supporting asynchronous message sending and receiving, any POJO can be turned into a message listener. These POJO based message listeners are called Message driven POJO (MDP). These are very much similar to EJB’s Message driven beans (MDB), but doesn’t need to have any knowledge of messaging API’s to make it a message listener.

Spring JMS Architecture

Spring by itself is not a JMS provider and for it to work with messaging it needs an external JMS provider like Apache ActiveMQ, JBoss Messaging etc. The two important components in Spring Framework to handle messaging requirements are JmsTemplate and the message listener container. The former one namely JmsTemplate being used for synchronous messaging activities and latter one namely message listener container being used for asynchronous messaging activities respectively.

These important components in Spring abstract most of the nitty-gritty’s involved with messaging away from the developer and makes it easy to have a message-oriented application developed in simple, easy and maintainable fashion.

Spring JMS architecture can be depicted as shown in Figure 18-9 below. It shows only the main components in the entire architecture to make it simpler to understand.

 Figure 18-9. Spring JMS architecture

Figure 18-9. Spring JMS architecture

We will now cover each component constituting the Spring JMS architecture in detail in the following sections.

Page Visitors: 16772

The following two tabs change content below.
Tomcy John

Tomcy John

Blogger & Author at javacodebook
He is an Enterprise Java Specialist holding a degree in Engineering (B-Tech) with over 10 years of experience in several industries. He's currently working as Principal Architect at Emirates Group IT since 2005. Prior to this he has worked with Oracle Corporation and Ernst & Young. His main specialization is on various web technologies and acts as chief mentor and Architect to facilitate incorporating Spring as Corporate Standard in the organization.
Tomcy John

Latest posts by Tomcy John (see all)

1 thought on “Spring Book – Chapter 17 – Messaging with Spring

  1. First of all I would like to say fantastic blog! I had a quick question which I’d like to ask if you don’t mind. I was interested to know how you center yourself and clear your head before writing. I have had difficulty clearing my mind in getting my ideas out there. I do enjoy writing but it just seems like the first 10 to 15 minutes are usually wasted just trying to figure out how to begin. Any recommendations or tips? Thank you!|

Leave a Reply

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