1

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.

aled
  • 21,330
  • 3
  • 27
  • 34

1 Answers1

3

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.

aled
  • 21,330
  • 3
  • 27
  • 34
  • Thanks for your reply, Yes we are using dev-kit, give some sample to implement in Mule 4 SDK. @aled – Ponmanikandan Boothalingam Dec 17 '19 at 05:24
  • I'm sorry don't have an example of a connector with transactions for Mule SDK. You can follow Mule SDK docs to create one: https://docs.mulesoft.com/mule-sdk/1.1/ Note that Mule SDK is for Mule 4 only, and DevKit is for Mule 3 only, and they are incompatible, however there is a how to migrate from DevKit to Mule SDK page in the docs: https://docs.mulesoft.com/mule-sdk/1.1/dmt – aled Dec 17 '19 at 13:15
  • i tried with AMQ and JMS queue its working as XA fine. How? the flow screen shot is attached. – Ponmanikandan Boothalingam Dec 18 '19 at 07:00
  • In Mule 3 JMS is not a connector created with DevKit. They are transports, implemented internally in the runtime by the Mule developers. – aled Dec 18 '19 at 16:43
  • ok Thanks @aled, but i tired by add below lines. Its working fine. ExternalXaTransactionextenaXATransaction = new ExternalXaTransaction(super.muleContext); TransactionCoordination.getInstance().bindTransaction(extenaXATransaction); – Ponmanikandan Boothalingam Dec 20 '19 at 16:23
  • It might work, I'm just pointing out that DevKit doesn't provide any support for it. – aled Dec 20 '19 at 17:52
  • yes your are rite. Thanks for your quick response for all my queries. – Ponmanikandan Boothalingam Dec 23 '19 at 05:22