activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r753297 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/region/TopicRegion.java test/java/org/apache/activemq/broker/virtual/VirtualTopicsAndDurableSubsTest.java
Date Fri, 13 Mar 2009 15:18:28 GMT
Author: gtully
Date: Fri Mar 13 15:18:27 2009
New Revision: 753297

URL: http://svn.apache.org/viewvc?rev=753297&view=rev
Log:
resolve: AMQ-2144|https://issues.apache.org/activemq/browse/AMQ-2144 - patch applied with
thanks

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicsAndDurableSubsTest.java
  (with props)
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java?rev=753297&r1=753296&r2=753297&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
Fri Mar 13 15:18:27 2009
@@ -80,8 +80,12 @@
                     durableSubscriptions.remove(key);
                     synchronized (destinationsMutex) {
                         for (Iterator<Destination> iter = destinations.values().iterator();
iter.hasNext();) {
-                            Topic topic = (Topic)iter.next();
-                            topic.deleteSubscription(context, key);
+                            Destination dest = iter.next();
+                            //Account for virtual destinations
+                            if (dest instanceof Topic){
+                                Topic topic = (Topic)dest;
+                                topic.deleteSubscription(context, key);
+                            }
                         }
                     }
                     super.removeConsumer(context, sub.getConsumerInfo());
@@ -136,8 +140,12 @@
         durableSubscriptions.remove(key);
         synchronized (destinationsMutex) {
             for (Iterator<Destination> iter = destinations.values().iterator(); iter.hasNext();)
{
-                Topic topic = (Topic)iter.next();
-                topic.deleteSubscription(context, key);
+            	Destination dest = iter.next();
+            	//Account for virtual destinations
+            	if (dest instanceof Topic){
+            	    Topic topic = (Topic)dest;
+            	    topic.deleteSubscription(context, key);
+            	}
             }
         }
         super.removeConsumer(context, sub.getConsumerInfo());

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicsAndDurableSubsTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicsAndDurableSubsTest.java?rev=753297&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicsAndDurableSubsTest.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicsAndDurableSubsTest.java
Fri Mar 13 15:18:27 2009
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.broker.virtual;
+
+import javax.jms.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+import org.apache.activemq.broker.jmx.MBeanTest;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.spring.ConsumerBean;
+
+public class VirtualTopicsAndDurableSubsTest extends MBeanTest {
+
+    private Connection connection;
+
+    public void testVirtualTopicCreationAndDurableSubs() throws Exception {
+        if (connection == null) {
+            connection = createConnection();
+        }
+        connection.setClientID(getAClientID());
+        connection.start();
+
+        ConsumerBean messageList = new ConsumerBean();
+        messageList.setVerbose(true);
+        
+        String queueAName = getVirtualTopicConsumerName();
+        // create consumer 'cluster'
+        ActiveMQQueue queue1 = new ActiveMQQueue(queueAName);
+        ActiveMQQueue queue2 = new ActiveMQQueue(queueAName);
+
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageConsumer c1 = session.createConsumer(queue1);
+        MessageConsumer c2 = session.createConsumer(queue2);
+
+        c1.setMessageListener(messageList);
+        c2.setMessageListener(messageList);
+
+        // create topic producer
+        MessageProducer producer = session.createProducer(new ActiveMQTopic(getVirtualTopicName()));
+        assertNotNull(producer);
+
+        int total = 10;
+        for (int i = 0; i < total; i++) {
+            producer.send(session.createTextMessage("message: " + i));
+        }
+        messageList.assertMessagesArrived(total);
+        
+        //Add and remove durable subscriber after using VirtualTopics
+        assertCreateAndDestroyDurableSubscriptions();
+    }
+
+    protected String getAClientID(){
+    	return "VirtualTopicCreationAndDurableSubs";
+    }
+
+    protected String getVirtualTopicName() {
+        return "VirtualTopic.TEST";
+    }
+
+
+    protected String getVirtualTopicConsumerName() {
+        return "Consumer.A.VirtualTopic.TEST";
+    }
+
+    protected String getDurableSubscriberName(){
+    	return "Sub1";
+    }
+    
+    protected String getDurableSubscriberTopicName(){
+    	return "simple.topic";
+    }
+
+    protected void tearDown() throws Exception {
+        if (connection != null) {
+            connection.close();
+        }
+        super.tearDown();
+    }
+    
+    //Overrides test cases from MBeanTest to avoid having them run.
+    public void testMBeans() throws Exception {}
+    public void testMoveMessages() throws Exception {}
+    public void testRetryMessages() throws Exception {}
+    public void testMoveMessagesBySelector() throws Exception {}
+    public void testCopyMessagesBySelector() throws Exception {}
+}

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicsAndDurableSubsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicsAndDurableSubsTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message