/** * @throws IOException * @see org.apache.activemq.store.TransactionStore#rollback(TransactionId) */ public void rollback(TransactionId txid) throws IOException { if (txid.isXATransaction() || theStore.isConcurrentStoreAndDispatchTransactions() == false) { KahaTransactionInfo info = getTransactionInfo(txid); theStore.store(new KahaRollbackCommand().setTransactionInfo(info), false, null, null); forgetRecoveredAcks(txid); } else { inflightTransactions.remove(txid); } }
/** * @throws IOException * @see org.apache.activemq.store.TransactionStore#prepare(TransactionId) */ public void prepare(TransactionId txid) throws IOException { KahaTransactionInfo info = getTransactionInfo(txid); if (txid.isXATransaction() || theStore.isConcurrentStoreAndDispatchTransactions() == false) { theStore.store(new KahaPrepareCommand().setTransactionInfo(info), true, null, null); } else { Tx tx = inflightTransactions.remove(txid); if (tx != null) { theStore.store(new KahaPrepareCommand().setTransactionInfo(info), true, null, null); } } }
public void commit( TransactionId txid, boolean wasPrepared, Runnable preCommit, Runnable postCommit) throws IOException { if (txid != null) { if (!txid.isXATransaction() && theStore.isConcurrentStoreAndDispatchTransactions()) { if (preCommit != null) { preCommit.run(); } Tx tx = inflightTransactions.remove(txid); if (tx != null) { List<Future<Object>> results = tx.commit(); boolean doneSomething = false; for (Future<Object> result : results) { try { result.get(); } catch (InterruptedException e) { theStore.brokerService.handleIOException(new IOException(e.getMessage())); } catch (ExecutionException e) { theStore.brokerService.handleIOException(new IOException(e.getMessage())); } catch (CancellationException e) { } if (!result.isCancelled()) { doneSomething = true; } } if (postCommit != null) { postCommit.run(); } if (doneSomething) { KahaTransactionInfo info = getTransactionInfo(txid); theStore.store(new KahaCommitCommand().setTransactionInfo(info), true, null, null); } } else { // The Tx will be null for failed over clients - lets run their post commits if (postCommit != null) { postCommit.run(); } } } else { KahaTransactionInfo info = getTransactionInfo(txid); theStore.store( new KahaCommitCommand().setTransactionInfo(info), true, preCommit, postCommit); forgetRecoveredAcks(txid); } } else { LOG.error("Null transaction passed on commit"); } }
public boolean isInXATransaction() { if (transactionId != null && transactionId.isXATransaction()) { return true; } else { synchronized (ENDED_XA_TRANSACTION_CONTEXTS) { for (List<TransactionContext> transactions : ENDED_XA_TRANSACTION_CONTEXTS.values()) { if (transactions.contains(this)) { return true; } } } } return false; }
protected void forgetRecoveredAcks(TransactionId txid) throws IOException { if (txid.isXATransaction()) { XATransactionId xaTid = ((XATransactionId) txid); theStore.forgetRecoveredAcks(xaTid.getPreparedAcks()); } }