title: Transaction Management in Spring JMS listener
body: <p>I have a spring JMS listener which is listening to queue . Once the message arrives at the input queue , it does certain processing on the message and puts the messages to multiple other queues for further processing (we may call these other queues as output queues) . While its posting to other output queues, in case posting the message to one of the output queues may fail due to any reason , I want to make sure that other posts to output queues which are done prior to failure gets rolled back. Basically I want to ensure it as atomic operation . 
  is there any annotation/configuration on the listener/container that I can use to achieve this in single transaction.?</p>
  
  <p>Here Is the configuration that I am using </p>
  
  <pre><code>&lt;jms:listener-container acknowledge="transacted" cache="session" connection-factory="jmsSecurityFactory" concurrency="1" container-type="default" container-class="abc.xyz"&gt;
  &lt;jms:listener id="listenerId" destination="inputQueue" ref="" /&gt;
  &lt;/jms:listener-container&gt;
  &lt;beans:bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"&gt;
  &lt;beans:property name="sessionTransacted" value="true"&gt;&lt;/beans:property&gt;
  &lt;beans:property name="connectionFactory" ref="inCachingConnectionFactory"&gt;&lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  &lt;beans:bean id="inCachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory"&gt;
      &lt;beans:property name="targetConnectionFactory" ref="jmsSecurityFactory" /&gt;
  &lt;/beans:bean&gt;
  &lt;beans:bean id="jmsSecurityFactory"
      class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter"&gt;
      &lt;beans:property name="targetConnectionFactory" ref="jmsConnectionFactory" /&gt;
      &lt;beans:property name="username" value=" " /&gt;
      &lt;beans:property name="password" value=" " /&gt;
  &lt;/beans:bean&gt;
  &lt;beans:bean id="jmsConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory"&gt;
      &lt;beans:property name="hostName" value="${mq.conn.hostName}" /&gt;
      &lt;beans:property name="port" value="${mq.conn.hostPort}" /&gt;
      &lt;beans:property name="queueManager" value="${mq.conn.queueManager}" /&gt;
      &lt;beans:property name="channel" value="${mq.conn.channel}" /&gt;
      &lt;beans:property name="transportType" value="${mq.conn.transportType}" /&gt;
      &lt;beans:property name="useConnectionPooling" value="true"&gt;&lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  </code></pre>
  
  <p>it looks like JMS template and listener container both refer to same connection factory bean (jmsConnectionFactory)</p>