public DistributedTransaction(AMQPSession<?,?> session, DtxRegistry dtxRegistry) { _session = session; _dtxRegistry = dtxRegistry; _autoCommitTransaction = new AutoCommitTransaction(dtxRegistry.getMessageStore()); }
public void prepare() throws StoreException { LOGGER.debug("Performing prepare for DtxBranch {}", _xid); Transaction txn = _dtxRegistry.getMessageStore().newTransaction(); _storedXidRecord = txn.recordXid(_xid.getFormat(), _xid.getGlobalId(), _xid.getBranchId(), _enqueueRecords.toArray(new EnqueueRecord[_enqueueRecords.size()]), _dequeueRecords.toArray(new DequeueRecord[_dequeueRecords.size()])); txn.commitTran(); prePrepareTransaction(); }
public synchronized void rollback() throws StoreException { LOGGER.debug("Performing rollback for DtxBranch {}", _xid); if(_timeoutFuture != null) { LOGGER.debug("Attempting to cancel previous timeout task future for DtxBranch {}", _xid); boolean succeeded = _timeoutFuture.cancel(false); _timeoutFuture = null; LOGGER.debug("Cancelling previous timeout task {} for DtxBranch {}", (succeeded ? "succeeded" : "failed"), _xid); } if(_transaction != null) { // prepare has previously been called Transaction txn = _dtxRegistry.getMessageStore().newTransaction(); txn.removeXid(_storedXidRecord); txn.commitTran(); _transaction.abortTran(); } for(ServerTransaction.Action action : _postTransactionActions) { action.onRollback(); } _postTransactionActions.clear(); }
public void prePrepareTransaction() throws StoreException { _transaction = _dtxRegistry.getMessageStore().newTransaction(); for(final EnqueueRecord enqueue : _enqueueRecords) { final MessageEnqueueRecord record; if(enqueue.isDurable()) { record = _transaction.enqueueMessage(enqueue.getResource(), enqueue.getMessage()); } else { record = null; } enqueue.getEnqueueAction().performAction(record); } for(DequeueRecord dequeue : _dequeueRecords) { _transaction.dequeueMessage(dequeue.getEnqueueRecord()); } }