Repository: activemq-artemis
Updated Branches:
  refs/heads/2.6.x b3d700a66 -> d37532a40


ARTEMIS-2139 Fix setJMSReplyTo for 1.x clients with enable1xPrefixes


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

Branch: refs/heads/2.6.x
Commit: d37532a40530c1aee97e53a25b559f2b743666f2
Parents: b3d700a
Author: Francesco Nigro <nigro....@gmail.com>
Authored: Fri Nov 23 17:54:27 2018 +0100
Committer: Francesco Nigro <nigro....@gmail.com>
Committed: Fri Nov 23 17:54:27 2018 +0100

----------------------------------------------------------------------
 .../artemis/jms/client/ActiveMQMessage.java     | 43 ++++++++++++++------
 1 file changed, 31 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d37532a4/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
----------------------------------------------------------------------
diff --git 
a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
 
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
index fb0574e..746e9e8 100644
--- 
a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
+++ 
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
@@ -414,25 +414,44 @@ public class ActiveMQMessage implements javax.jms.Message 
{
          if (dest instanceof ActiveMQDestination == false) {
             throw new InvalidDestinationException("Foreign destination " + 
dest);
          }
-
-         String prefix = "";
-         if (dest instanceof ActiveMQTemporaryQueue) {
-            prefix = TEMP_QUEUE_QUALIFED_PREFIX;
-         } else if (dest instanceof ActiveMQQueue) {
-            prefix = QUEUE_QUALIFIED_PREFIX;
-         } else if (dest instanceof ActiveMQTemporaryTopic) {
-            prefix = TEMP_TOPIC_QUALIFED_PREFIX;
-         } else if (dest instanceof ActiveMQTopic) {
-            prefix = TOPIC_QUALIFIED_PREFIX;
-         }
          ActiveMQDestination jbd = (ActiveMQDestination) dest;
+         final String address = jbd.getAddress();
+         if (enable1xPrefixes && hasPrefix1X(address)) {
+            MessageUtil.setJMSReplyTo(message, jbd.getAddress());
+         } else {
+            String prefix = "";
+            if (dest instanceof ActiveMQTemporaryQueue) {
+               prefix = TEMP_QUEUE_QUALIFED_PREFIX;
+            } else if (dest instanceof ActiveMQQueue) {
+               prefix = QUEUE_QUALIFIED_PREFIX;
+            } else if (dest instanceof ActiveMQTemporaryTopic) {
+               prefix = TEMP_TOPIC_QUALIFED_PREFIX;
+            } else if (dest instanceof ActiveMQTopic) {
+               prefix = TOPIC_QUALIFIED_PREFIX;
+            }
 
-         MessageUtil.setJMSReplyTo(message, prefix + jbd.getAddress());
+            MessageUtil.setJMSReplyTo(message, prefix + jbd.getAddress());
+         }
 
          replyTo = jbd;
       }
    }
 
+   private static boolean hasPrefix1X(String address) {
+      if (address != null) {
+         if (address.startsWith(PacketImpl.OLD_QUEUE_PREFIX.toString())) {
+            return true;
+         } else if 
(address.startsWith(PacketImpl.OLD_TEMP_QUEUE_PREFIX.toString())) {
+            return true;
+         } else if 
(address.startsWith(PacketImpl.OLD_TOPIC_PREFIX.toString())) {
+            return true;
+         } else if 
(address.startsWith(PacketImpl.OLD_TEMP_TOPIC_PREFIX.toString())) {
+            return true;
+         }
+      }
+      return false;
+   }
+
    @Override
    public Destination getJMSDestination() throws JMSException {
       if (dest == null) {

Reply via email to