简体   繁体   中英

ActiveMQ and XA transactions with persistent messages where the jdbc persistence adapter uses a non-xa jdbc datasource

I am working on an application that sends JMS messages and requires exactly once delivery semantics, message listener code may interact with multiple databases and themselves send further messages so I'm using XA transactions. I have a network of ActiveMQ message brokers, a JDBC backed persistent message store and I'm using Bitronix for transaction management. Re-delivery is currently handled by the brokers rather than the consumers.

The application has multiple data sources, some of these are XA backed and others are non-xa. When reviewing the configuration I noticed that the JdbcPersistenceAdapter set on the broker service is using the non-xa version of the datasource. My instinct is that this configuration is incorrect and that the persistence adapter should be using an XA data source. However everything appears to be working correctly at the moment in terms of transaction semantics rollback / commit / redelivery of messages.

I'm trying to ascertain whether I'm correct in thinking I need to change the datasource to an XA version? If I'm right in thinking it needs to be changed, I'd also be interested in knowing why this seems to work correctly as is (though this is obviously of less importance than having the correct configuration)?

When a JMS client uses XA transactions with ActiveMQ the javax.transaction.xa.XAResource is provided by the ActiveMQ client and the resource manager that the transaction manager works with is implemented by the broker itself. Whether or not the underlying JDBC datasource used by the broker implements XA is not relevant (or necessary).

In other words, your current configuration is fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM