From ed3c4fec89269de48130537b0ad544b272f2cfe3 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Thu, 19 Jul 2018 17:29:06 -0400 Subject: [PATCH] AMQ-7012 Fix STOMP protocol handler to log correct command names Ensure Commands are logged correctly by the protocol converter. (cherry picked from commit 5fb470478f8511619ddf9f0725ce000756536843) --- .../activemq/transport/stomp/ProtocolConverter.java | 8 ++++++-- .../org/apache/activemq/transport/stomp/Stomp.java | 10 ++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java index cb799c6786..2c4d4023be 100644 --- a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java +++ b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java @@ -257,9 +257,9 @@ public class ProtocolConverter { onStompCommit(command); } else if (action.startsWith(Stomp.Commands.ABORT)) { onStompAbort(command); - } else if (action.startsWith(Stomp.Commands.SUBSCRIBE)) { + } else if (action.startsWith(Stomp.Commands.SUBSCRIBE_PREFIX)) { onStompSubscribe(command); - } else if (action.startsWith(Stomp.Commands.UNSUBSCRIBE)) { + } else if (action.startsWith(Stomp.Commands.UNSUBSCRIBE_PREFIX)) { onStompUnsubscribe(command); } else if (action.startsWith(Stomp.Commands.CONNECT) || action.startsWith(Stomp.Commands.STOMP)) { @@ -1031,6 +1031,10 @@ public class ProtocolConverter { case Stomp.Commands.DISCONNECT: result = action; break; + case Stomp.Commands.SUBSCRIBE_PREFIX: + result = Stomp.Commands.SUBSCRIBE; + case Stomp.Commands.UNSUBSCRIBE_PREFIX: + result = Stomp.Commands.UNSUBSCRIBE; default: break; } diff --git a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/Stomp.java b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/Stomp.java index 767e947b5c..9731f7b1b4 100644 --- a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/Stomp.java +++ b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/Stomp.java @@ -49,8 +49,14 @@ public interface Stomp { String CONNECT = "CONNECT"; String SEND = "SEND"; String DISCONNECT = "DISCONNECT"; - String SUBSCRIBE = "SUB"; - String UNSUBSCRIBE = "UNSUB"; + String SUBSCRIBE = "SUBSCRIBE"; + String UNSUBSCRIBE = "UNSUBSCRIBE"; + + // Preserve legacy incorrect allow shortened names for + // subscribe and un-subscribe as it has been there for so + // long that someone has undoubtedly come to expect it. + String SUBSCRIBE_PREFIX = "SUB"; + String UNSUBSCRIBE_PREFIX = "UNSUB"; String BEGIN_TRANSACTION = "BEGIN"; String COMMIT_TRANSACTION = "COMMIT";