transactionStore.start(); try { context.setBroker(this); final ConsumerBrokerExchange consumerExchange = new ConsumerBrokerExchange(); consumerExchange.setConnectionContext(context); transactionStore.recover(new TransactionRecoveryListener() { public void recover(XATransactionId xid, Message[] addedMessages, MessageAck[] aks) { try {
@Override public void rollback(TransactionId txid) throws IOException { Tx tx = removeTx(txid); if (tx != null) { for (Map.Entry<TransactionStore, TransactionId> storeTx : tx.getStoresMap().entrySet()) { TransactionId recovered = storeTx.getValue(); if (recovered != null) { storeTx.getKey().rollback(recovered); } else { storeTx.getKey().rollback(txid); } } } }
adapter.createTransactionStore().recover(new TransactionRecoveryListener() { @Override public void recover(XATransactionId xid, Message[] addedMessages, MessageAck[] acks) {
private void storeCommit(TransactionId txid, boolean wasPrepared, Runnable preCommit,Runnable postCommit) throws XAException, IOException { try { transactionStore.commit(getTransactionId(), wasPrepared, preCommitTask, postCommitTask); waitPostCommitDone(postCommitTask); } catch (XAException xae) { throw xae; } catch (Throwable t) { LOG.warn("Store COMMIT FAILED: " + txid, t); XAException xae = null; if (wasPrepared) { // report and await outcome xae = newXAException("STORE COMMIT FAILED: " + t.getMessage(), XAException.XA_RETRY); // fire rollback syncs to revert doPostRollback(); } else { try { rollback(); xae = newXAException("STORE COMMIT FAILED: Transaction rolled back", XAException.XA_RBCOMMFAIL); } catch (Throwable e) { xae = newXAException("STORE COMMIT FAILED: " + t.getMessage() +". Rolled failed:" + e.getMessage(), XAException.XA_RBINTEGRITY); } } xae.initCause(t); throw xae; } }
@Override public void prepare(TransactionId txid) throws IOException { Tx tx = getTx(txid); for (TransactionStore store : tx.getStores()) { store.prepare(txid); } }
public void stop() throws Exception { transactionStore.stop(); next.stop(); }
adapter.createTransactionStore().recover(new TransactionRecoveryListener() { @Override public void recover(XATransactionId xid, Message[] addedMessages, MessageAck[] acks) {
context.getTransactions().remove(xid); try { transactionStore.commit(getTransactionId(), false, preCommitTask, postCommitTask); this.waitPostCommitDone(postCommitTask); } catch (Throwable t) {
@Override public int prepare() throws XAException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("XA Transaction prepare: " + xid); } switch (getState()) { case START_STATE: // No work done.. no commit/rollback needed. setStateFinished(); return XAResource.XA_RDONLY; case IN_USE_STATE: // We would record prepare here. doPrePrepare(); setState(Transaction.PREPARED_STATE); transactionStore.prepare(getTransactionId()); return XAResource.XA_OK; default: illegalStateTransition("prepare"); return XAResource.XA_RDONLY; } }
public void stop() throws Exception { transactionStore.stop(); next.stop(); }
transactionStore.start(); try { final ConnectionContext context = new ConnectionContext(); final ConsumerBrokerExchange consumerExchange = new ConsumerBrokerExchange(); consumerExchange.setConnectionContext(context); transactionStore.recover(new TransactionRecoveryListener() { public void recover(XATransactionId xid, Message[] addedMessages, MessageAck[] aks) { try {
@Override public void rollback() throws XAException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("rollback: " + xid + " syncCount: " + size()); } setState(Transaction.FINISHED_STATE); context.getTransactions().remove(xid); transactionStore.rollback(getTransactionId()); try { fireAfterRollback(); } catch (Throwable e) { LOG.warn("POST ROLLBACK FAILED: ", e); XAException xae = new XAException("POST ROLLBACK FAILED"); xae.errorCode = XAException.XAER_RMERR; xae.initCause(e); throw xae; } }
adapter.createTransactionStore().recover(new TransactionRecoveryListener() { @Override public void recover(XATransactionId xid, Message[] addedMessages, MessageAck[] acks) {
private void storeCommit(TransactionId txid, boolean wasPrepared, Runnable preCommit,Runnable postCommit) throws XAException, IOException { try { transactionStore.commit(getTransactionId(), wasPrepared, preCommitTask, postCommitTask); waitPostCommitDone(postCommitTask); } catch (XAException xae) { throw xae; } catch (Throwable t) { LOG.warn("Store COMMIT FAILED: ", t); rollback(); XAException xae = newXAException("STORE COMMIT FAILED: Transaction rolled back", XAException.XA_RBOTHER); xae.initCause(t); throw xae; } }
@Override public void prepare(TransactionId txid) throws IOException { Tx tx = getTx(txid); for (TransactionStore store : tx.getStores()) { store.prepare(txid); } }
public void stop() throws Exception { transactionStore.stop(); next.stop(); }
transactionStore.start(); try { final ConnectionContext context = new ConnectionContext(); final ConsumerBrokerExchange consumerExchange = new ConsumerBrokerExchange(); consumerExchange.setConnectionContext(context); transactionStore.recover(new TransactionRecoveryListener() { public void recover(XATransactionId xid, Message[] addedMessages, MessageAck[] aks) { try {