You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2008/10/17 15:00:55 UTC

svn commit: r705592 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/ft/ test/java/org/apache/activemq/advisory/

Author: gtully
Date: Fri Oct 17 06:00:54 2008
New Revision: 705592

URL: http://svn.apache.org/viewvc?rev=705592&view=rev
Log:
resolve AMQ-1979, slave connection did not know about temp destinations so it would not delete on close, only on an explicit delete command

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java?rev=705592&r1=705591&r2=705592&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java Fri Oct 17 06:00:54 2008
@@ -17,6 +17,7 @@
 package org.apache.activemq.broker.ft;
 
 import java.util.concurrent.atomic.AtomicBoolean;
+
 import org.apache.activemq.broker.Connection;
 import org.apache.activemq.broker.ConnectionContext;
 import org.apache.activemq.broker.ConsumerBrokerExchange;
@@ -211,14 +212,24 @@
         super.removeSubscription(context, info);
         sendAsyncToSlave(info);
     }
+    
+    @Override
+    public void addDestinationInfo(ConnectionContext context,
+            DestinationInfo info) throws Exception {
+        super.addDestinationInfo(context, info);
+        if (info.getDestination().isTemporary()) {
+            sendAsyncToSlave(info);
+        }
+    }
 
+    @Override
     public void removeDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception {
         super.removeDestinationInfo(context, info);
         if (info.getDestination().isTemporary()) {
             sendAsyncToSlave(info);
         }
-
     }
+    
     /**
      * begin a transaction
      * 

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java?rev=705592&r1=705591&r2=705592&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java Fri Oct 17 06:00:54 2008
@@ -75,6 +75,10 @@
         AdvisoryBroker ab = (AdvisoryBroker) slave.getBroker().getAdaptor(
                 AdvisoryBroker.class);
         
+        if (!deleteTempQueue) {
+            // give temp destination removes a chance to perculate on connection.close
+            Thread.sleep(2000);
+        }
         assertEquals("the temp queues should not be visible as they are removed", 1, ab.getAdvisoryDestinations().size());
                        
         RegionBroker rb = (RegionBroker) slave.getBroker().getAdaptor(
@@ -101,7 +105,7 @@
         // master does not always reach expected total, should be assertEquals.., why?
         assertTrue("dispatched to slave is as good as master, master=" 
                 + masterRb.getDestinationStatistics().getDispatched().getCount(),
-                rb.getDestinationStatistics().getDispatched().getCount() + 2*COUNT >= 
+                rb.getDestinationStatistics().getDispatched().getCount() + 2*messagesToSend >= 
                 masterRb.getDestinationStatistics().getDispatched().getCount());
     }
     
@@ -121,7 +125,6 @@
                 try {
                     latch.await(30L, TimeUnit.SECONDS);
                 } catch (Exception e) {
-                    // TODO Auto-generated catch block
                     e.printStackTrace();
                 }
             }
@@ -147,4 +150,11 @@
         assertEquals("inflight match expected", 0, masterRb.getDestinationStatistics().getInflight().getCount());        
         assertEquals("inflight match on slave and master", slaveRb.getDestinationStatistics().getInflight().getCount(), masterRb.getDestinationStatistics().getInflight().getCount());
     }
+    
+    public void testLoadRequestReplyWithNoTempQueueDelete() throws Exception {
+        deleteTempQueue = false;
+        messagesToSend = 10;
+        testLoadRequestReply();
+    }
+
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java?rev=705592&r1=705591&r2=705592&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java Fri Oct 17 06:00:54 2008
@@ -37,7 +37,8 @@
     protected Connection clientConnection;
     protected Session clientSession;
     protected Destination serverDestination;
-    protected static final int COUNT = 2000;
+    protected int messagesToSend = 2000;
+    protected boolean deleteTempQueue = true;
 
     public void testLoadRequestReply() throws Exception {
         MessageConsumer serverConsumer = serverSession.createConsumer(serverDestination);
@@ -56,7 +57,7 @@
         });
         
         MessageProducer producer = clientSession.createProducer(serverDestination);
-        for (int i =0; i< COUNT; i++) {
+        for (int i =0; i< messagesToSend; i++) {
             TemporaryQueue replyTo = clientSession.createTemporaryQueue();
             MessageConsumer consumer = clientSession.createConsumer(replyTo);
             Message msg = clientSession.createMessage();
@@ -64,7 +65,11 @@
             producer.send(msg);
             Message reply = consumer.receive();
             consumer.close();
-            replyTo.delete();
+            if (deleteTempQueue) {
+                replyTo.delete();
+            } else {
+                // temp queue will be cleaned up on clientConnection.close
+            }
         }
         
         clientSession.close();