Java Reference
In-Depth Information
public void setDestination(Destination destination) {
this.destination = destination;
public Mail receiveMail() {
MapMessage message = (MapMessage) jmsTemplate.receive(destination);
try {
if (message == null) {
return null;
Mail mail = new Mail();
return mail;
} catch (JMSException e) {
throw JmsUtils.convertJmsAccessException(e);
However, when extracting information from the received MapMessage object, you still have to
handle the JMS API's JMSException . This is in stark contrast to the default behavior of the framework,
where it automatically maps exceptions for you when invoking methods on the JmsTemplate . To
make the type of the exception thrown by this method consistent, you have to make a call to
JmsUtils.convertJmsAccessException() to convert the JMS API's JMSException into Spring's
JmsException .
In the back office subsystem's bean configuration file, you declare a JMS template and inject it
together with the message destination into your back office bean.
<beans ...>
<bean id="connectionFactory"
<property name="brokerURL" value=" tcp://localhost:61616" />
<bean id="mailDestination"
<constructor-arg value="mail.queue" />
<bean id="jmsTemplate"
<property name="connectionFactory" ref="connectionFactory" />
<property name="receiveTimeout" value="10000" />
Search WWH ::

Custom Search