diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java index 8a9d7c323a..65e0021cb9 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java @@ -1447,7 +1447,12 @@ public class ServerSessionImpl implements ServerSession, FailureListener { throw new ActiveMQXAException(XAException.XAER_NOTA, msg); } 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; throw new ActiveMQXAException(XAException.XAER_PROTO, msg); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaTest.java index a545439444..81b064e5a6 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaTest.java @@ -206,6 +206,12 @@ public class BasicXaTest extends ActiveMQTestBase { clientSession.start(xid2, XAResource.TMNOFLAGS); clientProducer.send(m2); 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); ClientMessage message = clientConsumer.receiveImmediate(); assertNotNull(message);