Search code examples
mulemule-esbbitronix

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


I developed my custom connector with dev-kit, my connector act as a source it connect to ejb and extract the data, and send to the another end point.

I am using bitronix for transaction manager.

I used the below code to register my ejb in the mule transaction context.

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();
}

After that am using next end point as JMS and configured with XA,always join. But it not behave as XA. It looks like bitronix delisting the JMS resource.

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

As per the logs the JMS not comes under the transaction which i begin.

Or else right way to implement XA Mule custom connector.


Solution

  • enter image description hereDevkit doesn't support transactions. Probably just registering the resource in that way is not enough to fully implement the XA transaction.

    The SDK for Mule 4 does support transactions though I understand this is not the version you are interested.