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
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
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
We will now cover each component constituting the Spring JMS architecture in detail in the following sections.
Page Visitors: 14840