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 c3d399a4bd..f7c0a292e5 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 @@ -855,9 +855,16 @@ public class ServerSessionImpl implements ServerSession, FailureListener { else if (tx.getState() == Transaction.State.ROLLEDBACK) { final String msg = "Cannot end, transaction is rolled back"; + final long now = System.currentTimeMillis(); + final boolean timeout = tx.hasTimedOut(now, resourceManager.getTimeoutSeconds()); tx = null; - throw new ActiveMQXAException(XAException.XAER_PROTO, msg); + if (timeout) { + throw new ActiveMQXAException(XAException.XA_RBTIMEOUT, msg); + } + else { + throw new ActiveMQXAException(XAException.XAER_PROTO, msg); + } } else { tx = null;