I have a JMS spring listener that listens for a queue. As soon as the message enters the input queue, it performs certain processing of the message and places the messages in several other queues for further processing (we can call these other queues as output queues). While publishing it to other output queues if sending a message to one of the output queues may fail for some reason, I want to make sure that other messages for outputting the queues that run to failure are rolled back. Basically I want to provide it as an atomic operation. Is there any annotation / configuration in the listener / container that I can use to achieve this in one transaction.?
Here is the configuration I'm using
<jms:listener-container acknowledge="transacted" cache="session" connection-factory="jmsSecurityFactory" concurrency="1" container-type="default" container-class="abc.xyz"> <jms:listener id="listenerId" destination="inputQueue" ref="" /> </jms:listener-container> <beans:bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> <beans:property name="sessionTransacted" value="true"></beans:property> <beans:property name="connectionFactory" ref="inCachingConnectionFactory"></beans:property> </beans:bean> <beans:bean id="inCachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory"> <beans:property name="targetConnectionFactory" ref="jmsSecurityFactory" /> </beans:bean> <beans:bean id="jmsSecurityFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter"> <beans:property name="targetConnectionFactory" ref="jmsConnectionFactory" /> <beans:property name="username" value=" " /> <beans:property name="password" value=" " /> </beans:bean> <beans:bean id="jmsConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory"> <beans:property name="hostName" value="${mq.conn.hostName}" /> <beans:property name="port" value="${mq.conn.hostPort}" /> <beans:property name="queueManager" value="${mq.conn.queueManager}" /> <beans:property name="channel" value="${mq.conn.channel}" /> <beans:property name="transportType" value="${mq.conn.transportType}" /> <beans:property name="useConnectionPooling" value="true"></beans:property> </beans:bean>
it looks like the JMS template and the listener container are referring to the same factory bean connection (jmsConnectionFactory)
source share