NO-JIRA STOMP frame logging
This commit is contained in:
parent
1ed7a616ee
commit
c0d28432ad
|
@ -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.ConfigurationHelper;
|
||||||
import org.apache.activemq.artemis.utils.ExecutorFactory;
|
import org.apache.activemq.artemis.utils.ExecutorFactory;
|
||||||
import org.apache.activemq.artemis.utils.VersionLoader;
|
import org.apache.activemq.artemis.utils.VersionLoader;
|
||||||
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import static org.apache.activemq.artemis.core.protocol.stomp.ActiveMQStompProtocolMessageBundle.BUNDLE;
|
import static org.apache.activemq.artemis.core.protocol.stomp.ActiveMQStompProtocolMessageBundle.BUNDLE;
|
||||||
|
|
||||||
public final class StompConnection implements RemotingConnection {
|
public final class StompConnection implements RemotingConnection {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(StompConnection.class);
|
||||||
|
|
||||||
protected static final String CONNECTION_ID_PROP = "__AMQ_CID";
|
protected static final String CONNECTION_ID_PROP = "__AMQ_CID";
|
||||||
private static final String SERVER_NAME = "ActiveMQ-Artemis/" + VersionLoader.getVersion().getFullVersion() +
|
private static final String SERVER_NAME = "ActiveMQ-Artemis/" + VersionLoader.getVersion().getFullVersion() +
|
||||||
" ActiveMQ Artemis Messaging Engine";
|
" 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) {
|
public void sendFrame(StompFrame frame, StompPostReceiptFunction function) {
|
||||||
manager.sendReply(this, frame, function);
|
manager.sendReply(this, frame, function);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,8 +77,12 @@ public class StompFrame {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "StompFrame[command=" + command + ", headers=" + headers + ", content= " + this.body + " bytes " +
|
return new StringBuilder()
|
||||||
Arrays.toString(bytesBody);
|
.append("StompFrame[command=").append(command)
|
||||||
|
.append(", headers=").append(headers)
|
||||||
|
.append(", content= ").append(this.body)
|
||||||
|
.append(", bytes= ").append(Arrays.toString(bytesBody))
|
||||||
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPing() {
|
public boolean isPing() {
|
||||||
|
|
|
@ -155,6 +155,7 @@ public class StompProtocolManager extends AbstractProtocolManager<StompFrame, St
|
||||||
|
|
||||||
try {
|
try {
|
||||||
invokeInterceptors(this.incomingInterceptors, request, conn);
|
invokeInterceptors(this.incomingInterceptors, request, conn);
|
||||||
|
conn.logFrame(request, true);
|
||||||
conn.handleFrame(request);
|
conn.handleFrame(request);
|
||||||
} finally {
|
} finally {
|
||||||
server.getStorageManager().clearContext();
|
server.getStorageManager().clearContext();
|
||||||
|
@ -186,11 +187,8 @@ public class StompProtocolManager extends AbstractProtocolManager<StompFrame, St
|
||||||
// Public --------------------------------------------------------
|
// Public --------------------------------------------------------
|
||||||
|
|
||||||
public boolean send(final StompConnection connection, final StompFrame frame) {
|
public boolean send(final StompConnection connection, final StompFrame frame) {
|
||||||
if (ActiveMQStompProtocolLogger.LOGGER.isTraceEnabled()) {
|
|
||||||
ActiveMQStompProtocolLogger.LOGGER.trace("sent " + frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
invokeInterceptors(this.outgoingInterceptors, frame, connection);
|
invokeInterceptors(this.outgoingInterceptors, frame, connection);
|
||||||
|
connection.logFrame(frame, false);
|
||||||
|
|
||||||
synchronized (connection) {
|
synchronized (connection) {
|
||||||
if (connection.isDestroyed()) {
|
if (connection.isDestroyed()) {
|
||||||
|
|
|
@ -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.
|
*queues* depending on the operation being done and the desired semantics (e.g.
|
||||||
anycast or multicast).
|
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
|
## Sending
|
||||||
|
|
||||||
When a STOMP client sends a message (using a `SEND` frame), the protocol
|
When a STOMP client sends a message (using a `SEND` frame), the protocol
|
||||||
|
|
Loading…
Reference in New Issue