activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r936811 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/command/ActiveMQDestination.java test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java
Date Thu, 22 Apr 2010 12:25:16 GMT
Author: dejanb
Date: Thu Apr 22 12:25:16 2010
New Revision: 936811

URL: http://svn.apache.org/viewvc?rev=936811&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQ-2323 - dupliactes with composite destinations

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java?rev=936811&r1=936810&r2=936811&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java
Thu Apr 22 12:25:16 2010
@@ -22,9 +22,11 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 import java.util.StringTokenizer;
 
 import javax.jms.Destination;
@@ -249,7 +251,7 @@ public abstract class ActiveMQDestinatio
         this.hashValue = 0;
         if (composite) {
             // Check to see if it is a composite.
-            List<String> l = new ArrayList<String>();
+            Set<String> l = new HashSet<String>();
             StringTokenizer iter = new StringTokenizer(physicalName, "" + COMPOSITE_SEPERATOR);
             while (iter.hasMoreTokens()) {
                 String name = iter.nextToken().trim();
@@ -258,12 +260,10 @@ public abstract class ActiveMQDestinatio
                 }
                 l.add(name);
             }
-            if (l.size() > 1) {
-                compositeDestinations = new ActiveMQDestination[l.size()];
-                int counter = 0;
-                for (String dest : l) {
-                    compositeDestinations[counter++] = createDestination(dest);
-                }
+            compositeDestinations = new ActiveMQDestination[l.size()];
+            int counter = 0;
+            for (String dest : l) {
+                compositeDestinations[counter++] = createDestination(dest);
             }
         }
     }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java?rev=936811&r1=936810&r2=936811&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java
Thu Apr 22 12:25:16 2010
@@ -18,9 +18,19 @@ package org.apache.activemq;
 
 import javax.jms.DeliveryMode;
 import javax.jms.Destination;
+import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.Topic;
-
+import javax.management.MBeanServerConnection;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.jmx.QueueViewMBean;
+import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.test.JmsTopicSendReceiveTest;
 
 
@@ -84,4 +94,26 @@ public class JmsQueueCompositeSendReceiv
         assertMessagesAreReceived();
         LOG.info("" + data.length + " messages(s) received, closing down connections");
     }
+    
+    public void testDuplicate() throws Exception {
+    	ActiveMQDestination queue = (ActiveMQDestination)session.createQueue("TEST,TEST");
+        for (int i = 0; i < data.length; i++) {
+            Message message = createMessage(i);
+            configureMessage(message);
+            if (verbose) {
+                LOG.info("About to send a message: " + message + " with text: " + data[i]);
+            }
+            producer.send(queue, message);
+        }
+        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi");
+        JMXConnector connector = JMXConnectorFactory.connect(url, null);
+        connector.connect();
+        MBeanServerConnection connection = connector.getMBeanServerConnection();
+        ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq:Type=Queue,Destination=TEST,BrokerName=localhost");
+        
+        QueueViewMBean queueMbean = (QueueViewMBean) MBeanServerInvocationHandler.newProxyInstance(connection,
queueViewMBeanName, QueueViewMBean.class, true);
+        assertEquals(data.length, queueMbean.getQueueSize());
+        queueMbean.purge();
+        assertEquals(0, queueMbean.getQueueSize());
+    }
 }



Mime
View raw message