From 5b7b84a1b3e1eb4a78cc2e391e0c77baa7e983f2 Mon Sep 17 00:00:00 2001 From: Justin Bertram Date: Fri, 1 Jun 2018 11:16:10 -0500 Subject: [PATCH] ARTEMIS-1903 Log STOMP ERROR frames at WARN --- .../core/protocol/stomp/ActiveMQStompProtocolLogger.java | 8 ++++++-- .../artemis/core/protocol/stomp/StompConnection.java | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompProtocolLogger.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompProtocolLogger.java index e9dc4ee5ab..e9c431b5b9 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompProtocolLogger.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompProtocolLogger.java @@ -26,7 +26,7 @@ import org.jboss.logging.annotations.MessageLogger; /** * Logger Code 22 * - * each message id must be 6 digits long starting with 10, the 3rd digit donates the level so + * each message id must be 6 digits long starting with 22, the 3rd digit donates the level so * * INF0 1 * WARN 2 @@ -35,7 +35,7 @@ import org.jboss.logging.annotations.MessageLogger; * TRACE 5 * FATAL 6 * - * so an INFO message would be 101000 to 101999 + * so an INFO message would be 241000 to 246999 */ @MessageLogger(projectCode = "AMQ") @@ -50,6 +50,10 @@ public interface ActiveMQStompProtocolLogger extends BasicLogger { @Message(id = 222068, value = "connection closed {0}", format = Message.Format.MESSAGE_FORMAT) void connectionClosed(StompConnection connection); + @LogMessage(level = Logger.Level.WARN) + @Message(id = 222069, value = "Sent ERROR frame to STOMP client {0}: {1}", format = Message.Format.MESSAGE_FORMAT) + void sentErrorToClient(String address, String message); + @LogMessage(level = Logger.Level.ERROR) @Message(id = 224023, value = "Unable to send frame {0}", format = Message.Format.MESSAGE_FORMAT) void errorSendingFrame(@Cause Exception e, StompFrame frame); diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java index 78cd21b141..c247585ac5 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java @@ -778,6 +778,14 @@ public final class StompConnection implements RemotingConnection { stompListener.replySent(frame); } + if (frame.getCommand().equals(Stomp.Responses.ERROR)) { + String message = "no message header"; + if (frame.hasHeader(Stomp.Headers.Error.MESSAGE)) { + message = frame.getHeader(Stomp.Headers.Error.MESSAGE); + } + ActiveMQStompProtocolLogger.LOGGER.sentErrorToClient(getTransportConnection().getRemoteAddress(), message); + } + } public VersionedStompFrameHandler getFrameHandler() {