The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

kalyanwsl (5) [Avatar] Offline

I am trying to implement XA transactions on JDBC Connectors. It is not working as I expected. Please see the below use case: (I referred
1) Mule application has two JDBC Endpoints.
2) First JDBC endpoint inserts a record into a database.
3) Second JDBC endpoint inserts a record into another database.
4) Both above JDBC endpoint have to be in a XA transaction.
5) If second JDBC endpoint transaction fails, then first JDBC endpoint transaction has to be rolled back.

But in my application the first JDBC endpoint transaction is not being rolled back.

Please see below mule application configuration xml file.

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="" xmlns:jdbc-ee="" xmlns:http="" xmlns:jbossts="" xmlns="" xmlns:doc="" xmlns:spring="" version="EE-3.4.0" xmlnssmiliesi="" xsi:schemaLocation=" <br /> <br /> <br /> <br /> <br />">

<spring:bean id="LocalDBBean" name="LocalDBBean" class="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource">
<spring:property name="url" value="jdbc:mysql://localhost:3306/demo"/>
<spring:property name="user" value="root"/>
<spring:bean id="RemoteDBBean" name="RemoteDBBean" class="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource">
<spring:property name="url" value="jdbc:mysql://"/>
<spring:property name="user" value="root"/>
<spring:property name="password" value="root"/>
<jdbc-ee:connector name="LocalDBBeanConnector" dataSource-ref="LocalDBBean" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database"/>
<jdbc-ee:connector name="RemoteDBBeanConnector" dataSource-ref="RemoteDBBean" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database"/>
<jbossts:transaction-manager doc:name="Transaction Manager"/>
<flow name="XATransactions2Flow1" doc:name="XATransactions2Flow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8085" path="insertQry" doc:name="HTTP"/>
<eesmiliea-transactional action="ALWAYS_BEGIN" doc:name="Transactional">
<jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="insertQry" queryTimeout="-1" connector-ref="RemoteDBBeanConnector" doc:name="RemoteDatabaseEndpoint">
<xa-transaction action="ALWAYS_BEGIN"/>
<jdbc-ee:query key="insertQry" value="insert into test (name) values ('test2A')"/>
<jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="insertQry" queryTimeout="-1" connector-ref="LocalDBBeanConnector" doc:name="LocalDatabaseEndpoint">
<xa-transaction action="ALWAYS_JOIN"/>
<jdbc-ee:query key="insertQry" value="insert into demo1 (name) values ('test2')"/>
<rollback-exception-strategy doc:name="Rollback Exception Strategy"/>


Did I miss any other configurations for XA Transactions? Could you please direct me to best practice documentation.

David Dossot (233) [Avatar] Offline
Re: Unable to implement XA transactions using JDBC connectors
The first JDBC endpoint should use ALWAYS_JOIN to join the transaction started by eesmiliea-transactional.
kalyanwsl (5) [Avatar] Offline
Re: Unable to implement XA transactions using JDBC connectors
Thanks alot David,

It worked for me.