From 3def84e5330099c786bc9a5301804ea839e1e8c4 Mon Sep 17 00:00:00 2001 From: bayern39 Date: Thu, 23 Jun 2016 15:06:06 +0800 Subject: [PATCH] [ARTEMIS-591] Wrong XAException return code when broker timeout is hit --- .../artemis/core/server/impl/ServerSessionImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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;