Search in sources :

Example 1 with ExternalXaTransaction

use of org.mule.runtime.core.internal.transaction.ExternalXaTransaction in project mule by mulesoft.

the class XaTransactionFactory method joinExternalTransaction.

/**
 * Create a Mule transaction that represents a transaction started outside of Mule
 */
public Transaction joinExternalTransaction(MuleContext muleContext) throws TransactionException {
    try {
        TransactionManager txManager = muleContext.getTransactionManager();
        if (txManager.getTransaction() == null) {
            return null;
        }
        XaTransaction xat = new ExternalXaTransaction(muleContext);
        xat.begin();
        return xat;
    } catch (Exception e) {
        throw new TransactionException(CoreMessages.cannotStartTransaction("XA"), e);
    }
}
Also used : ExternalXaTransaction(org.mule.runtime.core.internal.transaction.ExternalXaTransaction) XaTransaction(org.mule.runtime.core.privileged.transaction.XaTransaction) TransactionException(org.mule.runtime.api.tx.TransactionException) TransactionManager(javax.transaction.TransactionManager) ExternalXaTransaction(org.mule.runtime.core.internal.transaction.ExternalXaTransaction) TransactionException(org.mule.runtime.api.tx.TransactionException)

Aggregations

TransactionManager (javax.transaction.TransactionManager)1 TransactionException (org.mule.runtime.api.tx.TransactionException)1 ExternalXaTransaction (org.mule.runtime.core.internal.transaction.ExternalXaTransaction)1 XaTransaction (org.mule.runtime.core.privileged.transaction.XaTransaction)1