Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8711518AB7 for ; Mon, 23 Nov 2015 20:36:29 +0000 (UTC) Received: (qmail 55847 invoked by uid 500); 23 Nov 2015 20:36:29 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 55679 invoked by uid 500); 23 Nov 2015 20:36:29 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 55634 invoked by uid 99); 23 Nov 2015 20:36:29 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Nov 2015 20:36:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0E2D9E0946; Mon, 23 Nov 2015 20:36:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cshannon@apache.org To: commits@activemq.apache.org Date: Mon, 23 Nov 2015 20:36:30 -0000 Message-Id: <2661daef127b4bc9b90bff15c07d2a9a@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [3/3] activemq git commit: https://issues.apache.org/jira/browse/AMQ-6058 https://issues.apache.org/jira/browse/AMQ-6058 Updating patch to make sure SelectorAwareVirtualTopics are covered and code cleanup Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/bc9edf00 Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/bc9edf00 Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/bc9edf00 Branch: refs/heads/master Commit: bc9edf00d198634722e4e8a2699a285e6050c184 Parents: bf36c4c Author: Christopher L. Shannon (cshannon) Authored: Mon Nov 23 20:35:32 2015 +0000 Committer: Christopher L. Shannon (cshannon) Committed: Mon Nov 23 20:35:32 2015 +0000 ---------------------------------------------------------------------- .../SelectorAwareVirtualTopicInterceptor.java | 30 +++++++++++--------- .../region/virtual/VirtualTopicInterceptor.java | 7 ++--- 2 files changed, 19 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/bc9edf00/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/SelectorAwareVirtualTopicInterceptor.java ---------------------------------------------------------------------- diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/SelectorAwareVirtualTopicInterceptor.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/SelectorAwareVirtualTopicInterceptor.java index fdbfbe6..cadf14a 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/SelectorAwareVirtualTopicInterceptor.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/SelectorAwareVirtualTopicInterceptor.java @@ -50,21 +50,25 @@ public class SelectorAwareVirtualTopicInterceptor extends VirtualTopicIntercepto */ @Override protected boolean shouldDispatch(final Broker broker, Message message, Destination dest) throws IOException { - boolean matches = false; - MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext(); - msgContext.setDestination(dest.getActiveMQDestination()); - msgContext.setMessageReference(message); - List subs = dest.getConsumers(); - for (Subscription sub : subs) { - if (sub.matches(message, msgContext)) { - matches = true; - break; + //first validate that the prefix matches in the super class + if (super.shouldDispatch(broker, message, dest)) { + boolean matches = false; + MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext(); + msgContext.setDestination(dest.getActiveMQDestination()); + msgContext.setMessageReference(message); + List subs = dest.getConsumers(); + for (Subscription sub : subs) { + if (sub.matches(message, msgContext)) { + matches = true; + break; + } } + if (matches == false) { + matches = tryMatchingCachedSubs(broker, dest, msgContext); + } + return matches; } - if (matches == false) { - matches = tryMatchingCachedSubs(broker, dest, msgContext); - } - return matches; + return false; } private boolean tryMatchingCachedSubs(final Broker broker, Destination dest, MessageEvaluationContext msgContext) { http://git-wip-us.apache.org/repos/asf/activemq/blob/bc9edf00/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/VirtualTopicInterceptor.java ---------------------------------------------------------------------- diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/VirtualTopicInterceptor.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/VirtualTopicInterceptor.java index b96171f..f673770 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/VirtualTopicInterceptor.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/VirtualTopicInterceptor.java @@ -142,11 +142,8 @@ public class VirtualTopicInterceptor extends DestinationFilter { } protected boolean shouldDispatch(Broker broker, Message message, Destination dest) throws IOException { - //can't find .* in the prefix, so default back to old logic and return true - if(prefix.indexOf(".*")>0){ - return dest.getName().startsWith(prefix.substring(0,prefix.indexOf(".*"))); - } - else return true; + //if can't find .* in the prefix, default back to old logic and return true + return prefix.contains(".*") ? dest.getName().startsWith(prefix.substring(0, prefix.indexOf(".*"))) : true; } protected ActiveMQDestination getQueueConsumersWildcard(ActiveMQDestination original) {