Spring provides a JMS integration framework that simplifies the use of the JMS API much like Spring’s integration does for the JDBC API.
JMS can be roughly divided into two areas of functionality, namely the production and consumption of messages. The
JmsTemplate class is used for message production and synchronous message reception. For asynchronous reception similar to Java EE’s message-driven bean style, Spring provides a number of message listener containers that are used to create Message-Driven POJOs (MDPs).
org.springframework.jms.core provides the core functionality for using JMS. It contains JMS template classes that simplify the use of the JMS by handling the creation and release of resources, much like the
JdbcTemplate does for JDBC. The design principle common to Spring template classes is to provide helper methods to perform common operations and for more sophisticated usage, delegate the essence of the processing task to user implemented callback interfaces. The JMS template follows the same design. The classes offer various convenience methods for the sending of messages, consuming a message synchronously, and exposing the JMS session and message producer to the user.
JMSException translation functionality. The translation converts the checked
JMSException hierarchy to a mirrored hierarchy of unchecked exceptions. If there are any provider specific subclasses of the checked
javax.jms.JMSException, this exception is wrapped in the unchecked
org.springframework.jms.support.converter provides a
MessageConverter abstraction to convert between Java objects and JMS messages.
org.springframework.jms.support.destination provides various strategies for managing JMS destinations, such as providing a service locator for destinations stored in JNDI.
Finally, the package
org.springframework.jms.connection provides an implementation of the
ConnectionFactory suitable for use in standalone applications. It also contains an implementation of Spring’s
PlatformTransactionManager for JMS (the cunningly named
JmsTransactionManager). This allows for seamless integration of JMS as a transactional resource into Spring’s transaction management mechanisms.
It provided a few useful feature that can facilitate us to develop JMS based applocation
1) provider CachingConnectionFactory
that cache of Sessions, MessageProducers, and MessageConsumers. The initial cache size is set to 1, use the property SessionCacheSize to increase the number of cached sessions.
2) Destination Management
That can separate the destination and processing logic ,we can configure it easily in xml.
3) provider Message Listener Containers
that can support concurrency when receive message .
<jms:listener-container connection-factory="myConnectionFactory" task-executor="myTaskExecutor" destination-resolver="myDestinationResolver" transaction-manager="myTransactionManager" concurrency="10"> <jms:listener destination="queue.orders" ref="orderService" method="placeOrder"/> <jms:listener destination="queue.confirmations" ref="confirmationLogger" method="log"/> </jms:listener-container>
4) Processing messages within transactions
5) Support for JCA Message Endpoints