public synchronized void xaResume(final Xid xid) throws Exception { if (tx != null) { final String msg = "Cannot resume, session is currently doing work in a transaction " + tx.getXid(); throw new HornetQXAException(XAException.XAER_PROTO, msg); } else { Transaction theTx = resourceManager.getTransaction(xid); if (theTx == null) { final String msg = "Cannot find xid in resource manager: " + xid; throw new HornetQXAException(XAException.XAER_NOTA, msg); } else { if (theTx.getState() != Transaction.State.SUSPENDED) { throw new HornetQXAException( XAException.XAER_PROTO, "Cannot resume transaction, it is not suspended " + xid); } else { tx = theTx; tx.resume(); } } } }
public synchronized void xaEnd(final Xid xid) throws Exception { if (tx != null && tx.getXid().equals(xid)) { if (tx.getState() == Transaction.State.SUSPENDED) { final String msg = "Cannot end, transaction is suspended"; throw new HornetQXAException(XAException.XAER_PROTO, msg); } else if (tx.getState() == Transaction.State.ROLLEDBACK) { final String msg = "Cannot end, transaction is rolled back"; tx = null; throw new HornetQXAException(XAException.XAER_PROTO, msg); } else { tx = null; } } else { // It's also legal for the TM to call end for a Xid in the suspended // state // See JTA 1.1 spec 3.4.4 - state diagram // Although in practice TMs rarely do this. Transaction theTx = resourceManager.getTransaction(xid); if (theTx == null) { final String msg = "Cannot find suspended transaction to end " + xid; throw new HornetQXAException(XAException.XAER_NOTA, msg); } else { if (theTx.getState() != Transaction.State.SUSPENDED) { final String msg = "Transaction is not suspended " + xid; throw new HornetQXAException(XAException.XAER_PROTO, msg); } else { theTx.resume(); } } } }