Repository: activemq-artemis Updated Branches: refs/heads/master 305d16fd3 -> d531c5aac
ARTEMIS-1101 Fixing JMSFilter on AMQP Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/cc22a028 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/cc22a028 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/cc22a028 Branch: refs/heads/master Commit: cc22a0286bce7aadca47adc21e6286977402a2e6 Parents: 305d16f Author: Clebert Suconic <[email protected]> Authored: Tue Apr 11 09:58:31 2017 -0400 Committer: Clebert Suconic <[email protected]> Committed: Tue Apr 11 16:07:33 2017 -0400 ---------------------------------------------------------------------- .../apache/activemq/artemis/api/core/Message.java | 7 +++++-- .../artemis/protocol/amqp/broker/AMQPMessage.java | 17 +++++++++++++++++ .../protocol/amqp/message/AMQPMessageTest.java | 2 +- .../artemis/core/filter/impl/FilterImpl.java | 7 ++----- .../artemis/core/server/ActiveMQServerLogger.java | 2 +- 5 files changed, 26 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cc22a028/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java index e9c4fec..bef2f81 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java @@ -305,8 +305,11 @@ public interface Message { /** - * Returns the userID - this is an optional user specified UUID that can be set to identify the message - * and will be passed around with the message + * + * This represents historically the JMSMessageID. + * We had in the past used this for the MessageID that was sent on core messages... + * + * later on when we added AMQP this name clashed with AMQPMessage.getUserID(); * * @return the user id */ http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cc22a028/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java index d076b21..d627fd5 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java @@ -511,6 +511,22 @@ public class AMQPMessage extends RefCountMessage { @Override public Object getUserID() { Properties properties = getProperties(); + if (properties != null && properties.getMessageId() != null) { + return properties.getMessageId(); + } else { + return null; + } + } + + /** + * Before we added AMQP into Artemis / Hornetq, the name getUserID was already taken by JMSMessageID. + * We cannot simply change the names now as it would break the API for existing clients. + * + * This is to return and read the proper AMQP userID. + * @return + */ + public Object getAMQPUserID() { + Properties properties = getProperties(); if (properties != null && properties.getUserId() != null) { Binary binary = properties.getUserId(); return new String(binary.getArray(), binary.getArrayOffset(), binary.getLength(), StandardCharsets.UTF_8); @@ -519,6 +535,7 @@ public class AMQPMessage extends RefCountMessage { } } + @Override public org.apache.activemq.artemis.api.core.Message setUserID(Object userID) { return null; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cc22a028/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/message/AMQPMessageTest.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/message/AMQPMessageTest.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/message/AMQPMessageTest.java index 496454b..8b379a3 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/message/AMQPMessageTest.java +++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/message/AMQPMessageTest.java @@ -147,7 +147,7 @@ public class AMQPMessageTest { AMQPMessage decoded = encodeAndDecodeMessage(protonMessage); - assertEquals(USER_NAME, decoded.getUserID()); + assertEquals(USER_NAME, decoded.getAMQPUserID()); } @Test http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cc22a028/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 33a1187..23ca545 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 @@ -79,10 +79,7 @@ public class FilterImpl implements Filter { try { booleanExpression = SelectorParser.parse(filterStr.toString()); } catch (Throwable e) { - ActiveMQServerLogger.LOGGER.invalidFilter(filterStr); - if (ActiveMQServerLogger.LOGGER.isDebugEnabled()) { - ActiveMQServerLogger.LOGGER.debug("Invalid filter", e); - } + ActiveMQServerLogger.LOGGER.invalidFilter(filterStr, e); throw ActiveMQMessageBundle.BUNDLE.invalidFilter(e, filterStr); } return new FilterImpl(filterStr, booleanExpression); @@ -108,7 +105,7 @@ public class FilterImpl implements Filter { boolean result = booleanExpression.matches(new FilterableServerMessage(message)); return result; } catch (Exception e) { - ActiveMQServerLogger.LOGGER.invalidFilter(sfilterString); + ActiveMQServerLogger.LOGGER.invalidFilter(sfilterString, e); if (ActiveMQServerLogger.LOGGER.isDebugEnabled()) { ActiveMQServerLogger.LOGGER.debug("Invalid filter", e); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cc22a028/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java index df576b2..9aaba7c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java @@ -1320,7 +1320,7 @@ public interface ActiveMQServerLogger extends BasicLogger { @LogMessage(level = Logger.Level.ERROR) @Message(id = 224006, value = "Invalid filter: {0}", format = Message.Format.MESSAGE_FORMAT) - void invalidFilter(SimpleString filter); + void invalidFilter(SimpleString filter, @Cause Throwable cause); @LogMessage(level = Logger.Level.ERROR) @Message(id = 224007, value = "page subscription = {0} error={1}", format = Message.Format.MESSAGE_FORMAT)
