public void rollback(JmsTransactionInfo transactionInfo, final AsyncResult request) throws Exception { if (!transactionInfo.getId().equals(current)) { if (!transactionInfo.isInDoubt() && current == null) { throw new IllegalStateException("Rollback called with no active Transaction."); } else if (!transactionInfo.isInDoubt() && current != null) { throw new IllegalStateException( "Attempt to rollback a transaction other than the current one"); } else { request.onSuccess(); return; } } preRollback(); LOG.trace("TX Context[{}] rolling back current TX[[]]", this, current); coordinator.discharge( current, new AsyncResult() { @Override public void onSuccess() { current = null; postRollback(); request.onSuccess(); } @Override public void onFailure(Throwable result) { current = null; postRollback(); request.onFailure(result); } @Override public boolean isComplete() { return current == null; } }, false); }
public void commit(JmsTransactionInfo transactionInfo, final AsyncResult request) throws Exception { if (!transactionInfo.getId().equals(current)) { if (!transactionInfo.isInDoubt() && current == null) { throw new IllegalStateException("Commit called with no active Transaction."); } else if (!transactionInfo.isInDoubt() && current != null) { throw new IllegalStateException( "Attempt to Commit a transaction other than the current one"); } else { throw new TransactionRolledBackException("Transaction in doubt and cannot be committed."); } } preCommit(); LOG.trace("TX Context[{}] committing current TX[[]]", this, current); coordinator.discharge( current, new AsyncResult() { @Override public void onSuccess() { current = null; postCommit(); request.onSuccess(); } @Override public void onFailure(Throwable result) { current = null; postCommit(); request.onFailure(result); } @Override public boolean isComplete() { return current == null; } }, true); }