Revert "Don't set routingType header on JMS producer as this breaks backwards 
compatibility"

This reverts commit 8338080a9be1b3ee317a766423468b39bf6bf64b.


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

Branch: refs/heads/ARTEMIS-780
Commit: 5fa3f45982fc5410b0519884bfea35beff66ecf9
Parents: a73aa09
Author: Martyn Taylor <mtay...@redhat.com>
Authored: Thu Dec 1 11:33:38 2016 +0000
Committer: Martyn Taylor <mtay...@redhat.com>
Committed: Thu Dec 1 15:26:23 2016 +0000

----------------------------------------------------------------------
 .../activemq/artemis/reader/MessageUtil.java    | 14 ++++++++++---
 .../artemis/jms/client/ActiveMQMessage.java     | 21 +++++++++++---------
 .../jms/client/ActiveMQMessageConsumer.java     |  7 -------
 .../jms/client/ActiveMQMessageProducer.java     |  3 +++
 4 files changed, 26 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5fa3f459/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MessageUtil.java
----------------------------------------------------------------------
diff --git 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MessageUtil.java
 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MessageUtil.java
index 507a454..9d37cd3 100644
--- 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MessageUtil.java
+++ 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MessageUtil.java
@@ -120,11 +120,19 @@ public class MessageUtil {
    }
 
    public static void clearProperties(Message message) {
+      /**
+       * JavaDoc for this method states:
+       *    Clears a message's properties.
+       *    The message's header fields and body are not cleared.
+       *
+       * Since the {@code Message.HDR_ROUTING_TYPE} is used for the 
JMSDestination header it isn't cleared
+       */
+
       List<SimpleString> toRemove = new ArrayList<>();
 
       for (SimpleString propName : message.getPropertyNames()) {
-         if (!propName.startsWith(JMS) || propName.startsWith(JMSX) ||
-            propName.startsWith(JMS_)) {
+         if ((!propName.startsWith(JMS) || propName.startsWith(JMSX) ||
+            propName.startsWith(JMS_)) && 
!propName.equals(Message.HDR_ROUTING_TYPE)) {
             toRemove.add(propName);
          }
       }
@@ -139,7 +147,7 @@ public class MessageUtil {
 
       for (SimpleString propName : message.getPropertyNames()) {
          if ((!propName.startsWith(JMS) || propName.startsWith(JMSX) ||
-            propName.startsWith(JMS_)) && 
!propName.startsWith(CONNECTION_ID_PROPERTY_NAME)) {
+            propName.startsWith(JMS_)) && 
!propName.startsWith(CONNECTION_ID_PROPERTY_NAME) && 
!propName.equals(Message.HDR_ROUTING_TYPE)) {
             set.add(propName.toString());
          }
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5fa3f459/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 d30fd1b..e558197 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
@@ -201,11 +201,9 @@ public class ActiveMQMessage implements javax.jms.Message {
 
    private long jmsDeliveryTime;
 
-   private boolean fromQueue;
-
    // Constructors --------------------------------------------------
 
-   /*g
+   /*
     * Create a new message prior to sending
     */
    protected ActiveMQMessage(final byte type, final ClientSession session) {
@@ -399,8 +397,17 @@ public class ActiveMQMessage implements javax.jms.Message {
    public Destination getJMSDestination() throws JMSException {
       if (dest == null) {
          SimpleString address = message.getAddress();
+         String prefix = "";
+         if 
(message.containsProperty(org.apache.activemq.artemis.api.core.Message.HDR_ROUTING_TYPE))
 {
+            RoutingType routingType = 
RoutingType.getType(message.getByteProperty(org.apache.activemq.artemis.api.core.Message.HDR_ROUTING_TYPE));
+            if (routingType.equals(RoutingType.ANYCAST)) {
+               prefix = QUEUE_QUALIFIED_PREFIX;
+            } else if (routingType.equals(RoutingType.MULTICAST)) {
+               prefix = TOPIC_QUALIFIED_PREFIX;
+            }
+         }
 
-         dest = address == null ? null : 
ActiveMQDestination.fromPrefixedName((fromQueue ? QUEUE_QUALIFIED_PREFIX : 
TOPIC_QUALIFIED_PREFIX) + address.toString());
+         dest = address == null ? null : 
ActiveMQDestination.fromPrefixedName(prefix + address.toString());
       }
 
       return dest;
@@ -777,11 +784,7 @@ public class ActiveMQMessage implements javax.jms.Message {
       return message.getBodySize() == 0;
    }
 
-   // Public ---------------------------------------------------------
-
-   public void setFromQueue(boolean fromQueue) {
-      this.fromQueue = fromQueue;
-   }
+   // Public --------------------------------------------------------
 
    public void setIndividualAcknowledge() {
       this.individualAck = true;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5fa3f459/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java
----------------------------------------------------------------------
diff --git 
a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java
 
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java
index ec362fa..8bc1fd8 100644
--- 
a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java
+++ 
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java
@@ -60,8 +60,6 @@ public final class ActiveMQMessageConsumer implements 
QueueReceiver, TopicSubscr
 
    private final ActiveMQDestination destination;
 
-   private final boolean destinationIsQueue;
-
    private final String selector;
 
    private final SimpleString autoDeleteQueueName;
@@ -90,8 +88,6 @@ public final class ActiveMQMessageConsumer implements 
QueueReceiver, TopicSubscr
 
       this.destination = destination;
 
-      this.destinationIsQueue = destination instanceof ActiveMQQueue;
-
       this.selector = selector;
 
       this.autoDeleteQueueName = autoDeleteQueueName;
@@ -244,9 +240,6 @@ public final class ActiveMQMessageConsumer implements 
QueueReceiver, TopicSubscr
             } else {
                coreMessage.acknowledge();
             }
-
-            // TODO find a more elegant way to do this
-            jmsMsg.setFromQueue(destinationIsQueue);
          }
 
          return jmsMsg;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5fa3f459/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
----------------------------------------------------------------------
diff --git 
a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
 
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
index 47d9ff2..4c1d335 100644
--- 
a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
+++ 
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
@@ -491,6 +491,9 @@ public class ActiveMQMessageProducer implements 
MessageProducer, QueueSender, To
       ClientMessage coreMessage = activeMQJmsMessage.getCoreMessage();
       
coreMessage.putStringProperty(ActiveMQConnection.CONNECTION_ID_PROPERTY_NAME, 
connID);
 
+      byte routingType = destination.isQueue() ? RoutingType.ANYCAST.getType() 
: RoutingType.MULTICAST.getType();
+      
coreMessage.putByteProperty(org.apache.activemq.artemis.api.core.Message.HDR_ROUTING_TYPE,
 routingType);
+
       try {
          /**
           * Using a completionListener requires wrapping using a {@link 
CompletionListenerWrapper},

Reply via email to