ARTEMIS-3810 Do not throw error resuming already active XA Transaction

This commit is contained in:
Clebert Suconic 2022-05-02 14:24:29 -04:00 committed by clebertsuconic
parent 1dbbad5582
commit 784b0e967e
2 changed files with 12 additions and 1 deletions

View File

@ -1447,7 +1447,12 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
throw new ActiveMQXAException(XAException.XAER_NOTA, msg); throw new ActiveMQXAException(XAException.XAER_NOTA, msg);
} else { } else {
if (theTx.getState() != Transaction.State.SUSPENDED) { if (theTx.getState() == State.ACTIVE) {
// nothing to be done on this case, it's already active, we just ignore it and keep live as usual
// TM 1.2 specs expects this as a regular scenario and it should just be ignored by TM Spec
return;
} else if (theTx.getState() != Transaction.State.SUSPENDED) {
final String msg = "Transaction is not suspended " + xid; final String msg = "Transaction is not suspended " + xid;
throw new ActiveMQXAException(XAException.XAER_PROTO, msg); throw new ActiveMQXAException(XAException.XAER_PROTO, msg);

View File

@ -206,6 +206,12 @@ public class BasicXaTest extends ActiveMQTestBase {
clientSession.start(xid2, XAResource.TMNOFLAGS); clientSession.start(xid2, XAResource.TMNOFLAGS);
clientProducer.send(m2); clientProducer.send(m2);
clientSession.end(xid, XAResource.TMSUCCESS); clientSession.end(xid, XAResource.TMSUCCESS);
// this is calling resume twice
// the TM may eventually do it, and if the state is ACTIVE, the
// broker should just ignore the call and keep going
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.commit(xid, true); clientSession.commit(xid, true);
ClientMessage message = clientConsumer.receiveImmediate(); ClientMessage message = clientConsumer.receiveImmediate();
assertNotNull(message); assertNotNull(message);