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 7C081E711 for ; Thu, 24 Jan 2013 14:55:13 +0000 (UTC) Received: (qmail 99859 invoked by uid 500); 24 Jan 2013 14:55:13 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 99773 invoked by uid 500); 24 Jan 2013 14:55:12 -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 99753 invoked by uid 99); 24 Jan 2013 14:55:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jan 2013 14:55:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jan 2013 14:55:09 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8416323888D2; Thu, 24 Jan 2013 14:54:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1438032 - in /activemq/trunk: activemq-broker/src/main/java/org/apache/activemq/plugin/ activemq-core/src/test/java/org/apache/activemq/broker/virtual/ activemq-core/src/test/resources/org/apache/activemq/broker/virtual/ Date: Thu, 24 Jan 2013 14:54:49 -0000 To: commits@activemq.apache.org From: dejanb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130124145449.8416323888D2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dejanb Date: Thu Jan 24 14:54:49 2013 New Revision: 1438032 URL: http://svn.apache.org/viewvc?rev=1438032&view=rev Log: https://issues.apache.org/jira/browse/AMQ-4271 - virtualSelectorCacheBrokerPlugin support for consumers with no selectors Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicDisconnectSelectorTest.java activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/virtual/disconnected-selector.xml Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java?rev=1438032&r1=1438031&r2=1438032&view=diff ============================================================================== --- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java (original) +++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java Thu Jan 24 14:54:49 2013 @@ -86,9 +86,15 @@ public class SubQueueSelectorCacheBroker @Override public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { LOG.debug("Caching consumer selector [" + info.getSelector() + "] on a " + info.getDestination().getQualifiedName()); - if (info.getSelector() != null) { - subSelectorCache.put(info.getDestination().getQualifiedName(), info.getSelector()); - } //if + String selector = info.getSelector(); + + // As ConcurrentHashMap doesn't support null values, use always true expression + if (selector == null) { + selector = "TRUE"; + } + + subSelectorCache.put(info.getDestination().getQualifiedName(), selector); + return super.addConsumer(context, info); } Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicDisconnectSelectorTest.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicDisconnectSelectorTest.java?rev=1438032&r1=1438031&r2=1438032&view=diff ============================================================================== --- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicDisconnectSelectorTest.java (original) +++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicDisconnectSelectorTest.java Thu Jan 24 14:54:49 2013 @@ -44,10 +44,16 @@ public class VirtualTopicDisconnectSelec private static final Logger LOG = LoggerFactory.getLogger(VirtualTopicDisconnectSelectorTest.class); protected Connection connection; - protected int total = 3000; - protected String messageSelector; - public void testVirtualTopicDisconnect() throws Exception { + public void testVirtualTopicSelectorDisconnect() throws Exception { + testVirtualTopicDisconnect("odd = 'no'", 3000, 1500); + } + + public void testVirtualTopicNoSelectorDisconnect() throws Exception { + testVirtualTopicDisconnect(null, 3000, 3000); + } + + public void testVirtualTopicDisconnect(String messageSelector, int total , int expected) throws Exception { if (connection == null) { connection = createConnection(); } @@ -63,7 +69,7 @@ public class VirtualTopicDisconnectSelec LOG.info("Sending to: " + producerDestination); LOG.info("Consuming from: " + destination ); - MessageConsumer consumer = session.createConsumer(destination, messageSelector); + MessageConsumer consumer = createConsumer(session, destination, messageSelector); MessageListener listener = new MessageListener(){ public void onMessage(Message message){ @@ -93,12 +99,12 @@ public class VirtualTopicDisconnectSelec consumer.close(); } if (i==reconnectCount){ - consumer = session.createConsumer(destination, messageSelector); + consumer = createConsumer(session, destination, messageSelector); consumer.setMessageListener(listener); } } - assertMessagesArrived(messageList,total/2,10000); + assertMessagesArrived(messageList, expected ,10000); } protected Destination getConsumerDsetination() { @@ -112,7 +118,14 @@ public class VirtualTopicDisconnectSelec protected void setUp() throws Exception { super.setUp(); - messageSelector = "odd = 'no'"; + } + + protected MessageConsumer createConsumer(Session session, Destination destination, String messageSelector) throws JMSException { + if (messageSelector != null) { + return session.createConsumer(destination, messageSelector); + } else { + return session.createConsumer(destination); + } } protected TextMessage createMessage(Session session, int i) throws JMSException { Modified: activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/virtual/disconnected-selector.xml URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/virtual/disconnected-selector.xml?rev=1438032&r1=1438031&r2=1438032&view=diff ============================================================================== --- activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/virtual/disconnected-selector.xml (original) +++ activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/virtual/disconnected-selector.xml Thu Jan 24 14:54:49 2013 @@ -36,7 +36,7 @@ - +