使用 bitronox 管理器,XA 无法与我的自定义开发工具包适配器一起使用

Using bitronox manager, XA not working with my custom dev-kit adapter

我用 dev-kit 开发了我的自定义连接器,我的连接器作为一个源连接到 ejb 并提取数据,然后发送到另一个端点。

我正在使用 bitronix 作为事务管理器。

我使用下面的代码在 mule 事务上下文中注册了我的 ejb。

public static void registerXaResource(MuleContext muleContext) {
    EJBClientTransactionContext txContext = EJBClientTransactionContext.create(muleContext.getTransactionManager(),
            getSynchronizationRegistry());
    EJBClientTransactionContext.setGlobalContext(txContext);
    XaResourceProducer.registerXAResource("dummyResource", new DummyXaResource());
}

/**
 * @return
 */
private static TransactionSynchronizationRegistry getSynchronizationRegistry() {
    return TransactionManagerServices.getTransactionSynchronizationRegistry();
}

之后我将下一个端点用作 JMS 并配置了 XA,始终加入。 但它不像 XA。 看起来 bitronix 正在删除 JMS 资源。

2019-12-11 16:59:48,398 [Receiving Thread] DEBUG 

bitronix.tm.resource.jms.DualSessionWrapper - choosing XA session
2019-12-11 16:59:48,410 [Receiving Thread] DEBUG bitronix.tm.resource.jms.DualSessionWrapper - looking for producer based on a MessageProducerConsumerKey on ActiveMQQueue[sampleReplyQueue]
2019-12-11 16:59:48,410 [Receiving Thread] DEBUG bitronix.tm.resource.jms.DualSessionWrapper - found no producer based on a MessageProducerConsumerKey on ActiveMQQueue[sampleReplyQueue], creating it
2019-12-11 16:59:48,411 [Receiving Thread] DEBUG bitronix.tm.resource.jms.DualSessionWrapper - choosing XA session
2019-12-11 16:59:48,447 [Receiving Thread] DEBUG bitronix.tm.resource.jms.DualSessionWrapper - closing a DualSessionWrapper in state ACCESSIBLE of a JmsPooledConnection of pool 1605822565-inboundtest-JMS in state ACCESSIBLE with underlying connection org.apache.activemq.artemis.jms.client.ActiveMQXAConnection@207dd1b7
2019-12-11 16:59:48,447 [Receiving Thread] DEBUG bitronix.tm.resource.common.TransactionContextHelper - delisting a DualSessionWrapper in state ACCESSIBLE of a JmsPooledConnection of pool 1605822565-inboundtest-JMS in state ACCESSIBLE with underlying connection org.apache.activemq.artemis.jms.client.ActiveMQXAConnection@207dd1b7 from a Bitronix Transaction with GTRID [31363035383232353635000000002582E13C00000001], status=ACTIVE, 1 resource(s) enlisted (started Thu Jan 08 12:18:54 IST 1970)
2019-12-11 16:59:48,447 [Receiving Thread] DEBUG bitronix.tm.resource.common.TransactionContextHelper - resource is not in enlisting global transaction context: a DualSessionWrapper in state ACCESSIBLE of a JmsPooledConnection of pool 1605822565-inboundtest-JMS in state ACCESSIBLE with underlying connection org.apache.activemq.artemis.jms.client.ActiveMQXAConnection@207dd1b7
2019-12-11 16:59:48,447 [Receiving Thread] DEBUG bitronix.tm.resource.common.TransactionContextHelper - requeuing a DualSessionWrapper in state ACCESSIBLE of a JmsPooledConnection of pool 1605822565-inboundtest-JMS in state ACCESSIBLE with underlying connection org.apache.activemq.artemis.jms.client.ActiveMQXAConnection@207dd1b7 from a Bitronix Transaction with GTRID [31363035383232353635000000002582E13C00000001], status=ACTIVE, 1 resource(s) enlisted (started Thu Jan 08 12:18:54 IST 1970)
2019-12-11 16:59:48,447 [Receiving Thread] DEBUG bitronix.tm.resource.common.TransactionContextHelper - resource is not in enlisting global transaction context: a DualSessionWrapper in state ACCESSIBLE of a JmsPooledConnection of pool 1605822565-inboundtest-JMS in state ACCESSIBLE with underlying connection org.apache.activemq.artemis.jms.client.ActiveMQXAConnection@207dd1b7

根据日志,JMS 不属于我开始的事务。

或者实现 XA Mule 自定义连接器的正确方法。

Devkit 不支持事务。可能仅以这种方式注册资源不足以完全实现 XA 事务。

Mule 4 的 SDK 确实支持 transactions 虽然我知道这不是您感兴趣的版本。