AMQ-5933 - add test and fix

(cherry picked from commit 3c2ed9352b)
This commit is contained in:
gtully 2015-08-19 15:02:09 +01:00 committed by Timothy Bish
parent 9ecef371ae
commit e546d29997
2 changed files with 27 additions and 8 deletions

View File

@ -76,15 +76,17 @@ public class SelectorAwareVirtualTopicInterceptor extends VirtualTopicIntercepto
if (cache != null) { if (cache != null) {
final Set<String> selectors = cache.getSelector(dest.getActiveMQDestination().getQualifiedName()); final Set<String> selectors = cache.getSelector(dest.getActiveMQDestination().getQualifiedName());
for (String selector : selectors) { if (selectors != null) {
try { for (String selector : selectors) {
final BooleanExpression expression = getExpression(selector); try {
matches = expression.matches(msgContext); final BooleanExpression expression = getExpression(selector);
if (matches) { matches = expression.matches(msgContext);
return true; if (matches) {
return true;
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
} }
} catch (Exception e) {
LOG.error(e.getMessage(), e);
} }
} }
} }

View File

@ -578,6 +578,23 @@ public class TwoBrokerVirtualTopicSelectorAwareForwardingTest extends
} }
public void testSelectorNoMatchInCache() throws Exception {
clearSelectorCacheFiles();
// have the cache ignoreWildcardSelectors
final BrokerService brokerA = brokers.get("BrokerA").broker;
((SubQueueSelectorCacheBrokerPlugin)brokerA.getPlugins()[0]).setIgnoreWildcardSelectors(true);
startAllBrokers();
ActiveMQDestination consumerBQueue = createDestination("Consumer.B.VirtualTopic.tempTopic", false);
MessageConsumer nonMatchingConsumer = createConsumer("BrokerA", consumerBQueue, "foo = 'bar%'");
ActiveMQTopic virtualTopic = new ActiveMQTopic("VirtualTopic.tempTopic");
sendMessages("BrokerA", virtualTopic, 1, asMap("foo", "notBar"));
}
private HashMap<String, Object> asMap(String key, Object value) { private HashMap<String, Object> asMap(String key, Object value) {
HashMap<String, Object> rc = new HashMap<String, Object>(1); HashMap<String, Object> rc = new HashMap<String, Object>(1);
rc.put(key, value); rc.put(key, value);