activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/3] activemq-artemis git commit: NO-JIRA STOMP frame logging
Date Fri, 22 Jun 2018 19:47:20 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 4f0bb9866 -> 532317cef


NO-JIRA STOMP frame logging


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/c0d28432
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/c0d28432
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/c0d28432

Branch: refs/heads/master
Commit: c0d28432ad113190ba51777c7e92f38be87e933d
Parents: 1ed7a61
Author: Justin Bertram <jbertram@apache.org>
Authored: Mon Jun 18 19:14:15 2018 -0500
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Fri Jun 22 15:47:14 2018 -0400

----------------------------------------------------------------------
 .../core/protocol/stomp/StompConnection.java    | 24 ++++++++++++++++++++
 .../artemis/core/protocol/stomp/StompFrame.java |  8 +++++--
 .../protocol/stomp/StompProtocolManager.java    |  6 ++---
 docs/user-manual/en/stomp.md                    |  8 +++++++
 4 files changed, 40 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c0d28432/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
----------------------------------------------------------------------
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 f7accb1..92b6edc 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
@@ -54,11 +54,14 @@ import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
 import org.apache.activemq.artemis.utils.ConfigurationHelper;
 import org.apache.activemq.artemis.utils.ExecutorFactory;
 import org.apache.activemq.artemis.utils.VersionLoader;
+import org.jboss.logging.Logger;
 
 import static org.apache.activemq.artemis.core.protocol.stomp.ActiveMQStompProtocolMessageBundle.BUNDLE;
 
 public final class StompConnection implements RemotingConnection {
 
+   private static final Logger logger = Logger.getLogger(StompConnection.class);
+
    protected static final String CONNECTION_ID_PROP = "__AMQ_CID";
    private static final String SERVER_NAME = "ActiveMQ-Artemis/" + VersionLoader.getVersion().getFullVersion()
+
       " ActiveMQ Artemis Messaging Engine";
@@ -582,6 +585,27 @@ public final class StompConnection implements RemotingConnection {
       }
    }
 
+   public void logFrame(StompFrame request, boolean in) {
+      if (logger.isDebugEnabled()) {
+         StringBuilder message = new StringBuilder()
+            .append("STOMP(")
+            .append(getRemoteAddress())
+            .append(", ")
+            .append(this.getID())
+            .append("):");
+
+         if (in) {
+            message.append(" IN << ");
+         } else {
+            message.append("OUT >> ");
+         }
+
+         message.append(request);
+
+         logger.debug(message.toString());
+      }
+   }
+
    public void sendFrame(StompFrame frame, StompPostReceiptFunction function) {
       manager.sendReply(this, frame, function);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c0d28432/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java
b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java
index 439eba2..1ba5d38 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java
@@ -77,8 +77,12 @@ public class StompFrame {
 
    @Override
    public String toString() {
-      return "StompFrame[command=" + command + ", headers=" + headers + ", content= " + this.body
+ " bytes " +
-         Arrays.toString(bytesBody);
+      return new StringBuilder()
+         .append("StompFrame[command=").append(command)
+         .append(", headers=").append(headers)
+         .append(", content= ").append(this.body)
+         .append(", bytes= ").append(Arrays.toString(bytesBody))
+         .toString();
    }
 
    public boolean isPing() {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c0d28432/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java
b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java
index 62df6e5..19a0062 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java
@@ -155,6 +155,7 @@ public class StompProtocolManager extends AbstractProtocolManager<StompFrame,
St
 
          try {
             invokeInterceptors(this.incomingInterceptors, request, conn);
+            conn.logFrame(request, true);
             conn.handleFrame(request);
          } finally {
             server.getStorageManager().clearContext();
@@ -186,11 +187,8 @@ public class StompProtocolManager extends AbstractProtocolManager<StompFrame,
St
    // Public --------------------------------------------------------
 
    public boolean send(final StompConnection connection, final StompFrame frame) {
-      if (ActiveMQStompProtocolLogger.LOGGER.isTraceEnabled()) {
-         ActiveMQStompProtocolLogger.LOGGER.trace("sent " + frame);
-      }
-
       invokeInterceptors(this.outgoingInterceptors, frame, connection);
+      connection.logFrame(frame, false);
 
       synchronized (connection) {
          if (connection.isDestroyed()) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c0d28432/docs/user-manual/en/stomp.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/stomp.md b/docs/user-manual/en/stomp.md
index 4abe8d4..27db086 100644
--- a/docs/user-manual/en/stomp.md
+++ b/docs/user-manual/en/stomp.md
@@ -38,6 +38,14 @@ In Apache ActiveMQ Artemis, these destinations are mapped to *addresses*
and
 *queues* depending on the operation being done and the desired semantics (e.g.
 anycast or multicast).
 
+## Logging
+
+Incoming and outgoing STOMP frames can be logged by enabling `DEBUG` for
+`org.apache.activemq.artemis.core.protocol.stomp.StompConnection`. This can be
+extremely useful for debugging or simply monitoring client activity. Along with
+the STOMP frame itself the remote IP address of the client is logged as well as
+the internal connection ID so that frames from the same client can be correlated.
+
 ## Sending
 
 When a STOMP client sends a message (using a `SEND` frame), the protocol


Mime
View raw message