activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
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 GMT
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 @@
             </virtualDestinationInterceptor>
         </destinationInterceptors>
         <plugins>
-            <virtualSelectorCacheBrokerPlugin persistFile = "selectorcache.data"/>
+            <virtualSelectorCacheBrokerPlugin persistFile = "target/selectorcache.data"/>
         </plugins>
     </broker>
 </beans>



Mime
View raw message