use of org.mule.runtime.core.api.transaction.ExternalTransactionAwareTransactionFactory 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);
}
}
}
Aggregations