activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-842 JMSMessageID doesn't appear to work in selector
Date Tue, 08 Nov 2016 13:56:58 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master df4c3c858 -> 7198671c0


ARTEMIS-842 JMSMessageID doesn't appear to work in selector


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

Branch: refs/heads/master
Commit: 4691cbe88215def28e4388d9605b76656af6ef75
Parents: df4c3c8
Author: Howard Gao <howard.gao@gmail.com>
Authored: Tue Nov 8 09:51:16 2016 +0800
Committer: Howard Gao <howard.gao@gmail.com>
Committed: Tue Nov 8 09:52:12 2016 +0800

----------------------------------------------------------------------
 .../activemq/artemis/api/core/FilterConstants.java  |  5 +++++
 .../amqp/converter/jms/ServerJMSMessage.java        |  4 ++--
 .../message/JMSMappingOutboundTransformer.java      |  3 ++-
 .../artemis/core/filter/impl/FilterImpl.java        |  9 +++++++++
 .../artemis/tests/integration/amqp/ProtonTest.java  | 16 ++++++++++++++++
 5 files changed, 34 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4691cbe8/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/FilterConstants.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/FilterConstants.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/FilterConstants.java
index c4809f6..37b221c 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/FilterConstants.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/FilterConstants.java
@@ -72,6 +72,11 @@ public final class FilterConstants {
     */
    public static final SimpleString ACTIVEMQ_PREFIX = new SimpleString("AMQ");
 
+   /**
+    * Proton protocol stores JMSMessageID as NATIVE_MESSAGE_ID
+    */
+   public static final String NATIVE_MESSAGE_ID = "NATIVE_MESSAGE_ID";
+
    private FilterConstants() {
       // Utility class
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4691cbe8/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java
index c7900e4..f9a94f5 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java
@@ -31,9 +31,9 @@ import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
 import org.apache.activemq.artemis.reader.MessageUtil;
 
-public class ServerJMSMessage implements Message {
+import static org.apache.activemq.artemis.api.core.FilterConstants.NATIVE_MESSAGE_ID;
 
-   public static final String NATIVE_MESSAGE_ID = "NATIVE_MESSAGE_ID";
+public class ServerJMSMessage implements Message {
 
    protected final MessageInternal message;
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4691cbe8/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java
index efa1a81..2fa7145 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.protocol.amqp.converter.message;
 
+import static org.apache.activemq.artemis.api.core.FilterConstants.NATIVE_MESSAGE_ID;
 import static org.apache.activemq.artemis.api.core.Message.HDR_SCHEDULED_DELIVERY_TIME;
 import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.AMQP_DATA;
 import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.AMQP_NULL;
@@ -338,7 +339,7 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer
{
             }
             properties.setGroupId(value);
             continue;
-         } else if (key.equals(ServerJMSMessage.NATIVE_MESSAGE_ID)) {
+         } else if (key.equals(NATIVE_MESSAGE_ID)) {
             // skip..internal use only
             continue;
          } else if (key.endsWith(HDR_SCHEDULED_DELIVERY_TIME.toString())) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4691cbe8/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
index b014b86..0a459c9 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
@@ -28,6 +28,8 @@ import org.apache.activemq.artemis.selector.filter.FilterException;
 import org.apache.activemq.artemis.selector.filter.Filterable;
 import org.apache.activemq.artemis.selector.impl.SelectorParser;
 
+import static org.apache.activemq.artemis.api.core.FilterConstants.NATIVE_MESSAGE_ID;
+
 /**
  * This class implements an ActiveMQ Artemis filter
  *
@@ -148,6 +150,13 @@ public class FilterImpl implements Filter {
 
    private static Object getHeaderFieldValue(final ServerMessage msg, final SimpleString
fieldName) {
       if (FilterConstants.ACTIVEMQ_USERID.equals(fieldName)) {
+         if (msg.getUserID() == null) {
+            // Proton stores JMSMessageID as NATIVE_MESSAGE_ID that is an arbitrary string
+            String amqpNativeID = msg.getStringProperty(NATIVE_MESSAGE_ID);
+            if (amqpNativeID != null) {
+               return new SimpleString(amqpNativeID);
+            }
+         }
          // It's the stringified (hex) representation of a user id that can be used in a
selector expression
          return new SimpleString("ID:" + msg.getUserID());
       } else if (FilterConstants.ACTIVEMQ_PRIORITY.equals(fieldName)) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4691cbe8/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
index 1a1021e..c3c8933 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
@@ -1606,6 +1606,22 @@ public class ProtonTest extends ProtonTestBase {
       }
    }
 
+   @Test
+   public void testFilterJMSMessageID() throws Exception {
+      javax.jms.Queue queue = createQueue(address);
+      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      MessageProducer p = session.createProducer(queue);
+      TextMessage message = session.createTextMessage();
+      p.send(message);
+      System.out.println("get mid: " + message.getJMSMessageID());
+      connection.start();
+      MessageConsumer messageConsumer = session.createConsumer(queue, "JMSMessageID = '"
+ message.getJMSMessageID() + "'");
+      TextMessage m = (TextMessage) messageConsumer.receive(5000);
+      Assert.assertNotNull(m);
+      assertEquals(message.getJMSMessageID(), m.getJMSMessageID());
+      connection.close();
+   }
+
    private javax.jms.Queue createQueue(String address) throws Exception {
       Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
       try {


Mime
View raw message