Java Reference
In-Depth Information
Managing JMS Transactions
As mentioned before, SimpleMessageListenerContainer doesn't support transactions. So,
if you need transaction management for your message listener method, you have to use
DefaultMessageListenerContainer instead. For local JMS transactions, you can simply enable its
sessionTransacted property, and your listener method will run within a local JMS transaction (as
opposed to XA transactions).
<property name="connectionFactory" ref="connectionFactory" />
<property name="destinationName" value="mail.queue" />
<property name="messageListener" ref="mailListenerAdapter" />
<property name="sessionTransacted" value="true" />
However, if you want your listener to participate in a JTA transaction, you need to declare a
JtaTransactionManager instance and inject it into your listener container.
Using Spring's JMS Schema
Spring, from 2.5 and onward, offers a new JMS schema to simplify your JMS listener and listener
container configuration. You must add the jms schema definition to the <beans> root element
<beans xmlns=""
<bean id="connectionFactory"
<property name="brokerURL" value=" tcp://localhost:61616" />
<bean id="transactionManager"
<property name="connectionFactory">
<ref bean="connectionFactory" />
<bean id="mailMessageConverter"
class="" />
Search WWH ::

Custom Search