use of org.mule.runtime.core.api.transaction.Transaction in project mule by mulesoft.
the class ExternalTransactionInterceptor method execute.
@Override
public T execute(ExecutionCallback<T> callback, ExecutionContext executionContext) throws Exception {
Transaction joinedExternal = null;
Transaction tx = TransactionCoordination.getInstance().getTransaction();
try {
if (tx == null && muleContext != null && transactionConfig != null && transactionConfig.isInteractWithExternal()) {
TransactionFactory tmFactory = transactionConfig.getFactory();
if (tmFactory instanceof ExternalTransactionAwareTransactionFactory) {
ExternalTransactionAwareTransactionFactory externalTransactionFactory = (ExternalTransactionAwareTransactionFactory) tmFactory;
joinedExternal = externalTransactionFactory.joinExternalTransaction(muleContext);
}
}
return next.execute(callback, executionContext);
} finally {
if (joinedExternal != null) {
TransactionCoordination.getInstance().unbindTransaction(joinedExternal);
}
}
}
use of org.mule.runtime.core.api.transaction.Transaction in project mule by mulesoft.
the class IsolateCurrentTransactionInterceptor method execute.
@Override
public T execute(ExecutionCallback<T> muleEventProcessingCallback, ExecutionContext executionContext) throws Exception {
boolean transactionIsolated = false;
try {
if (transactionConfig.getAction() == TransactionConfig.ACTION_NOT_SUPPORTED) {
Transaction transaction = TransactionCoordination.getInstance().getTransaction();
if (transaction != null) {
TransactionCoordination.getInstance().isolateTransaction();
transactionIsolated = true;
}
}
return next.execute(muleEventProcessingCallback, executionContext);
} finally {
if (transactionIsolated) {
TransactionCoordination.getInstance().restoreIsolatedTransaction();
}
}
}
use of org.mule.runtime.core.api.transaction.Transaction in project mule by mulesoft.
the class SuspendXaTransactionInterceptor method execute.
@Override
public T execute(ExecutionCallback<T> callback, ExecutionContext executionContext) throws Exception {
Transaction suspendedXATx = null;
Transaction tx = TransactionCoordination.getInstance().getTransaction();
byte action = transactionConfig.getAction();
if ((action == TransactionConfig.ACTION_NONE || action == TransactionConfig.ACTION_ALWAYS_BEGIN) && tx != null && tx.isXA()) {
if (logger.isDebugEnabled()) {
logger.debug("suspending XA tx " + action + ", " + "current TX: " + tx);
}
suspendedXATx = tx;
suspendXATransaction(suspendedXATx);
}
try {
T result = next.execute(callback, executionContext);
resumeXaTransactionIfRequired(suspendedXATx);
return result;
} catch (MessagingException e) {
if (processOnException) {
TransactionCoordination.getInstance().resumeXaTransactionIfAvailable();
}
throw e;
}
}
use of org.mule.runtime.core.api.transaction.Transaction in project mule by mulesoft.
the class TestTransactionFactory method beginTransaction.
public Transaction beginTransaction(MuleContext muleContext) throws TransactionException {
Transaction testTransaction;
if (mockTransaction != null) {
testTransaction = mockTransaction;
} else {
testTransaction = new TestTransaction(muleContext);
}
testTransaction.begin();
return testTransaction;
}
use of org.mule.runtime.core.api.transaction.Transaction in project mule by mulesoft.
the class ExtensionTransactionFactory method beginTransaction.
/**
* {@inheritDoc}
*/
@Override
public Transaction beginTransaction(MuleContext muleContext) throws TransactionException {
Transaction transaction = new ExtensionTransaction(muleContext);
transaction.begin();
return transaction;
}
Aggregations