Java tips, observations, bugs and problems from the world of Spring, Weblogic, Oracle, MySQL and many other technologies...

Thursday, 14 April 2011

Using Spring JmsTemplate

One very useful reoccurring Spring pattern is the use of template helpers that take hard work out of some very boring day to day stuff. The guys are Spring have provided a considerable number of template classes including JdbcTemplate, JdoTemplate and SqlMapClientTemplate. One of the most useful is the JmsTemplate, which is a way of managing JMS connections. It is incredibly flexible as it works in collaboration with several other helper classes including JndiTemplate, JndiObjectFactoryBean and JndiDestinationResolver.

This example demonstrates the strategy for setting up JmsTemplate and the first step is to configure the JndiTemplate: