From 3ea73d7475d6162a71e0fbaaf785c3d230d9f4ca Mon Sep 17 00:00:00 2001 From: Radovan Stancel Date: Tue, 3 Apr 2018 17:09:58 +0200 Subject: [PATCH] [JBEAP-9791] Log warning when connection is closed --- .../artemis/core/client/ActiveMQClientLogger.java | 5 +++++ .../artemis/core/client/impl/ClientSessionImpl.java | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java index 88c817fe082..fbc6959251f 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java @@ -442,4 +442,9 @@ public interface ActiveMQClientLogger extends BasicLogger { @Message(id = 214029, value = "Unexpected response from HTTP server: %s") void unexpectedResponseFromHttpServer(Object response); + @LogMessage(level = Logger.Level.WARN) + @Message(id = 214034, value = "Connection closed: {0} - {1}", + format = Message.Format.MESSAGE_FORMAT) + void connectionClosedWarn(ActiveMQExceptionType type, String message); + } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java index d5a867da224..4596616f807 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java @@ -31,6 +31,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; +import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -1171,6 +1172,11 @@ public void end(final Xid xid, final int flags) throws XAException { startCall(); try { sessionContext.xaEnd(xid, flags); + } catch (ActiveMQNotConnectedException ex) { + ActiveMQClientLogger.LOGGER.connectionClosedWarn(ex.getType(), ex.getMessage()); + if (logger.isDebugEnabled()) { + logger.debug(ex.getMessage(), ex); + } } finally { endCall(); } @@ -1375,6 +1381,11 @@ public void rollback(final Xid xid) throws XAException { try { sessionContext.xaRollback(xid, wasStarted); + } catch (ActiveMQNotConnectedException ex) { + ActiveMQClientLogger.LOGGER.connectionClosedWarn(ex.getType(), ex.getMessage()); + if (logger.isDebugEnabled()) { + logger.debug(ex.getMessage(), ex); + } } finally { if (wasStarted) { start();