use of org.mule.runtime.core.api.transaction.TransactionRollbackException in project mule by mulesoft.
the class XaTransaction method doCommit.
protected synchronized void doCommit() throws TransactionException {
try {
/*
* JTA spec quotes (parts highlighted by AP), the same applies to both TransactionManager and UserTransaction:
*
* 3.2.2 Completing a Transaction The TransactionManager.commit method completes the transaction currently associated with
* the calling thread.
****
*
* After the commit method returns, the calling thread is not associated with a transaction.
****
*
* If the commit method is called when the thread is not associated with any transaction context, the TM throws an
* exception. In some implementations, the commit operation is restricted to the transaction originator only. If the calling
* thread is not allowed to commit the transaction, the TM throws an exception. The TransactionManager.rollback method rolls
* back the transaction associated with the current thread.
****
* After the rollback method completes, the thread is associated with no transaction.
****
*
* And the following block about Transaction (note there's no thread-tx disassociation clause)
*
* 3.3.3 Transaction Completion The Transaction.commit and Transaction.rollback methods allow the target object to be
* comitted or rolled back. The calling thread is not required to have the same transaction associated with the thread. If
* the calling thread is not allowed to commit the transaction, the transaction manager throws an exception.
*
*
* So what it meant was that one can't use Transaction.commit()/rollback(), as it doesn't properly disassociate the thread
* of execution from the current transaction. There's no JTA API-way to do that after the call, so the thread's transaction
* is subject to manual recovery process. Instead TransactionManager or UserTransaction must be used.
*/
delistResources();
txManager.commit();
} catch (RollbackException | HeuristicRollbackException e) {
throw new TransactionRollbackException(CoreMessages.transactionMarkedForRollback(), e);
} catch (Exception e) {
throw new IllegalTransactionStateException(CoreMessages.transactionCommitFailed(), e);
} finally {
/*
* MUST nullify XA ref here, otherwise Transaction.getStatus() doesn't match javax.transaction.Transaction.getStatus(). Must
* return STATUS_NO_TRANSACTION and not STATUS_COMMITTED.
*
* TransactionCoordination unbinds the association immediately on this method's exit.
*/
this.transaction = null;
closeResources();
}
}
use of org.mule.runtime.core.api.transaction.TransactionRollbackException in project mule by mulesoft.
the class XaTransaction method doRollback.
protected void doRollback() throws TransactionRollbackException {
try {
/*
* JTA spec quotes (parts highlighted by AP), the same applies to both TransactionManager and UserTransaction:
*
* 3.2.2 Completing a Transaction The TransactionManager.commit method completes the transaction currently associated with
* the calling thread.
****
*
* After the commit method returns, the calling thread is not associated with a transaction.
****
*
* If the commit method is called when the thread is not associated with any transaction context, the TM throws an
* exception. In some implementations, the commit operation is restricted to the transaction originator only. If the calling
* thread is not allowed to commit the transaction, the TM throws an exception. The TransactionManager.rollback method rolls
* back the transaction associated with the current thread.
****
* After the rollback method completes, the thread is associated with no transaction.
****
*
* And the following block about Transaction (note there's no thread-tx disassociation clause)
*
* 3.3.3 Transaction Completion The Transaction.commit and Transaction.rollback methods allow the target object to be
* comitted or rolled back. The calling thread is not required to have the same transaction associated with the thread. If
* the calling thread is not allowed to commit the transaction, the transaction manager throws an exception.
*
*
* So what it meant was that one can't use Transaction.commit()/rollback(), as it doesn't properly disassociate the thread
* of execution from the current transaction. There's no JTA API-way to do that after the call, so the thread's transaction
* is subject to manual recovery process. Instead TransactionManager or UserTransaction must be used.
*/
// delistResources();
txManager.rollback();
} catch (Exception e) {
throw new TransactionRollbackException(e);
} finally {
/*
* MUST nullify XA ref here, otherwise Transaction.getStatus() doesn't match javax.transaction.Transaction.getStatus(). Must
* return STATUS_NO_TRANSACTION and not STATUS_COMMITTED.
*
* TransactionCoordination unbinds the association immediately on this method's exit.
*/
this.transaction = null;
closeResources();
}
}
Aggregations