public static ObjectName createXATransactionName(String brokerObjectName, XATransaction transaction) throws MalformedObjectNameException { String objectNameStr = brokerObjectName; objectNameStr += "," + "transactionType=RecoveredXaTransaction"; objectNameStr += "," + "xid=" + JMXSupport.encodeObjectNamePart(transaction.getTransactionId().toString()); return new ObjectName(objectNameStr); }
@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; } }
transactionStore.rollback(getTransactionId()); doPostRollback(); break; transactionStore.rollback(getTransactionId()); doPostRollback(); break; case FINISHED_STATE: transactionStore.rollback(getTransactionId()); doPostRollback(); break;
public void recover(XATransactionId xid, Message[] addedMessages, MessageAck[] aks) { try { beginTransaction(context, xid); XATransaction transaction = (XATransaction) getTransaction(context, xid, false); for (int i = 0; i < addedMessages.length; i++) { forceDestinationWakeupOnCompletion(context, transaction, addedMessages[i].getDestination(), addedMessages[i]); } for (int i = 0; i < aks.length; i++) { forceDestinationWakeupOnCompletion(context, transaction, aks[i].getDestination(), aks[i]); } transaction.setState(Transaction.PREPARED_STATE); registerMBean(transaction); LOG.debug("recovered prepared transaction: {}", transaction.getTransactionId()); } catch (Throwable e) { throw new WrappedException(e); } } });
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 commit(boolean onePhase) throws XAException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("XA Transaction commit onePhase:" + onePhase + ", xid: " + xid); } switch (getState()) { case START_STATE: // 1 phase commit, no work done. checkForPreparedState(onePhase); setStateFinished(); break; case IN_USE_STATE: // 1 phase commit, work done. checkForPreparedState(onePhase); doPrePrepare(); setStateFinished(); storeCommit(getTransactionId(), false, preCommitTask, postCommitTask); break; case PREPARED_STATE: // 2 phase commit, work done. // We would record commit here. storeCommit(getTransactionId(), true, preCommitTask, postCommitTask); setStateFinished(); break; default: illegalStateTransition("commit"); } }
public static ObjectName createXATransactionName(String brokerObjectName, XATransaction transaction) throws MalformedObjectNameException { String objectNameStr = brokerObjectName; objectNameStr += "," + "transactionType=RecoveredXaTransaction"; objectNameStr += "," + "xid=" + JMXSupport.encodeObjectNamePart(transaction.getTransactionId().toString()); return new ObjectName(objectNameStr); }
public static ObjectName createXATransactionName(String brokerObjectName, XATransaction transaction) throws MalformedObjectNameException { String objectNameStr = brokerObjectName; objectNameStr += "," + "transactionType=RecoveredXaTransaction"; objectNameStr += "," + "xid=" + JMXSupport.encodeObjectNamePart(transaction.getTransactionId().toString()); return new ObjectName(objectNameStr); }
public static ObjectName createXATransactionName(String brokerObjectName, XATransaction transaction) throws MalformedObjectNameException { String objectNameStr = brokerObjectName; objectNameStr += "," + "transactionType=RecoveredXaTransaction"; objectNameStr += "," + "xid=" + JMXSupport.encodeObjectNamePart(transaction.getTransactionId().toString()); return new ObjectName(objectNameStr); }
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; } }
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; } }
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; } }
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 = new XAException("STORE COMMIT FAILED: Transaction rolled back."); xae.errorCode = XAException.XA_RBOTHER; xae.initCause(t); throw xae; } }
@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; } }
@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; } }
@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; } }
@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 recover(XATransactionId xid, Message[] addedMessages, MessageAck[] aks) { try { beginTransaction(context, xid); XATransaction transaction = (XATransaction) getTransaction(context, xid, false); for (int i = 0; i < addedMessages.length; i++) { forceDestinationWakeupOnCompletion(context, transaction, addedMessages[i].getDestination(), addedMessages[i]); } for (int i = 0; i < aks.length; i++) { forceDestinationWakeupOnCompletion(context, transaction, aks[i].getDestination(), aks[i]); } transaction.setState(Transaction.PREPARED_STATE); registerMBean(transaction); LOG.debug("recovered prepared transaction: {}", transaction.getTransactionId()); } catch (Throwable e) { throw new WrappedException(e); } } });
public void recover(XATransactionId xid, Message[] addedMessages, MessageAck[] aks) { try { beginTransaction(context, xid); XATransaction transaction = (XATransaction) getTransaction(context, xid, false); for (int i = 0; i < addedMessages.length; i++) { forceDestinationWakeupOnCompletion(context, transaction, addedMessages[i].getDestination(), addedMessages[i]); } for (int i = 0; i < aks.length; i++) { forceDestinationWakeupOnCompletion(context, transaction, aks[i].getDestination(), aks[i]); } transaction.setState(Transaction.PREPARED_STATE); registerMBean(transaction); LOG.debug("recovered prepared transaction: {}", transaction.getTransactionId()); } catch (Throwable e) { throw new WrappedException(e); } } });
public void recover(XATransactionId xid, Message[] addedMessages, MessageAck[] aks) { try { beginTransaction(context, xid); XATransaction transaction = (XATransaction) getTransaction(context, xid, false); for (int i = 0; i < addedMessages.length; i++) { forceDestinationWakeupOnCompletion(context, transaction, addedMessages[i].getDestination(), addedMessages[i]); } for (int i = 0; i < aks.length; i++) { forceDestinationWakeupOnCompletion(context, transaction, aks[i].getDestination(), aks[i]); } transaction.setState(Transaction.PREPARED_STATE); registerMBean(transaction); LOG.debug("recovered prepared transaction: {}", transaction.getTransactionId()); } catch (Throwable e) { throw new WrappedException(e); } } });