Is it possible to attach a TransactionSynchronizationFactory to an outbound JMS Outbound Adapter?
We are trying to send a message to a JMS queue and want to update a database once the JMS send is successful. The idea is that we will start a transaction when a message comes in on our queue and then once we send the outbound message, we "commit" both the read and the write to JMS and update a database. The TransactionSynchronizationProcessor
seem like the correct interface for this, but we are unable to figure out how to attach it to the outbound adapters transaction.
handle(Jms.outboundAdapter(connectionFactory)
.destination("outputqueue")
.configureJmsTemplate(jmsTemplateSpec -> jmsTemplateSpec.id("jmsTemplateOutbound")
.sessionTransacted(true)
))
Is it possible to attach a TransactionSynchronizationFactory to an outbound JMS Outbound Adapter?
We are trying to send a message to a JMS queue and want to update a database once the JMS send is successful. The idea is that we will start a transaction when a message comes in on our queue and then once we send the outbound message, we "commit" both the read and the write to JMS and update a database. The TransactionSynchronizationProcessor
seem like the correct interface for this, but we are unable to figure out how to attach it to the outbound adapters transaction.
handle(Jms.outboundAdapter(connectionFactory)
.destination("outputqueue")
.configureJmsTemplate(jmsTemplateSpec -> jmsTemplateSpec.id("jmsTemplateOutbound")
.sessionTransacted(true)
))
Share
Improve this question
asked Feb 4 at 21:26
VPN236VPN236
273 bronze badges
1 Answer
Reset to default 0start a transaction when a message comes in on our queue
So, you start transaction far before this Jms.outboundAdapter()
, but you somehow think that TransactionSynchronizationProcessor
would make sense only on this Jms.outboundAdapter()
, which is not correct because transaction management is not here.
Consider to use this processor exactly at the place where you start transactions.
See DefaultTransactionSynchronizationFactory
and TransactionSynchronizationManager.registerSynchronization(synchronization)
API.