简体   繁体   English

具有持久性消息的 ActiveMQ 和 XA 事务,其中 jdbc 持久性适配器使用非 xa jdbc 数据源

[英]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.我正在开发一个发送 JMS 消息并且只需要一次传递语义的应用程序,消息侦听器代码可能与多个数据库进行交互,并且它们本身会发送更多消息,因此我正在使用 XA 事务。 I have a network of ActiveMQ message brokers, a JDBC backed persistent message store and I'm using Bitronix for transaction management.我有一个 ActiveMQ 消息代理网络,一个 JDBC 支持的持久消息存储,我正在使用 Bitronix 进行事务管理。 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.该应用程序有多个数据源,其中一些是 XA 支持的,而另一些是非 XA 的。 When reviewing the configuration I noticed that the JdbcPersistenceAdapter set on the broker service is using the non-xa version of the datasource.在查看配置时,我注意到代理服务上设置的 JdbcPersistenceAdapter 使用的是非 xa 版本的数据源。 My instinct is that this configuration is incorrect and that the persistence adapter should be using an XA data source.我的直觉是这种配置不正确,并且持久性适配器应该使用 XA 数据源。 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?我试图确定我是否正确地认为我需要将数据源更改为 XA 版本? 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.当 JMS 客户端通过 ActiveMQ 使用 XA 事务时, javax.transaction.xa.XAResource由 ActiveMQ 客户端提供,事务管理器使用的资源管理器由代理本身实现。 Whether or not the underlying JDBC datasource used by the broker implements XA is not relevant (or necessary).代理使用的底层 JDBC 数据源是否实现 XA 无关(或必要)。

In other words, your current configuration is fine.换句话说,您当前的配置很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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