activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1158694 - in /activemq/trunk/activemq-pool/src: main/java/org/apache/activemq/pool/ test/java/org/apache/activemq/pool/
Date Wed, 17 Aug 2011 13:29:35 GMT
Author: tabish
Date: Wed Aug 17 13:29:35 2011
New Revision: 1158694

URL: http://svn.apache.org/viewvc?rev=1158694&view=rev
Log:
Apply patch for: https://issues.apache.org/jira/browse/AMQ-3457

Modified:
    activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/ConnectionPool.java
    activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnection.java
    activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryWithTemporaryDestinationsTest.java

Modified: activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/ConnectionPool.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/ConnectionPool.java?rev=1158694&r1=1158693&r2=1158694&view=diff
==============================================================================
--- activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/ConnectionPool.java
(original)
+++ activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/ConnectionPool.java
Wed Aug 17 13:29:35 2011
@@ -144,6 +144,12 @@ public class ConnectionPool {
         lastUsed = System.currentTimeMillis();
         if (referenceCount == 0) {
             expiredCheck();
+            
+            // only clean up temp destinations when all users 
+            // of this connection have called close
+            if (getConnection() != null) {
+                getConnection().cleanUpTempDestinations();
+            }
         }
     }
 

Modified: activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnection.java?rev=1158694&r1=1158693&r2=1158694&view=diff
==============================================================================
--- activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnection.java
(original)
+++ activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnection.java
Wed Aug 17 13:29:35 2011
@@ -16,9 +16,6 @@
  */
 package org.apache.activemq.pool;
 
-import java.util.Iterator;
-import java.util.concurrent.ConcurrentHashMap;
-
 import javax.jms.Connection;
 import javax.jms.ConnectionConsumer;
 import javax.jms.ConnectionMetaData;
@@ -39,7 +36,6 @@ import org.apache.activemq.ActiveMQSessi
 import org.apache.activemq.AlreadyClosedException;
 import org.apache.activemq.EnhancedConnection;
 import org.apache.activemq.advisory.DestinationSource;
-import org.apache.activemq.command.ActiveMQTempDestination;
 
 /**
  * Represents a proxy {@link Connection} which is-a {@link TopicConnection} and
@@ -73,9 +69,6 @@ public class PooledConnection implements
     public void close() throws JMSException {
         if (this.pool != null) {
             this.pool.decrementReferenceCount();
-            if (this.pool.getConnection() != null) {
-                this.pool.getConnection().cleanUpTempDestinations();
-            }
             this.pool = null;
         }
     }

Modified: activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryWithTemporaryDestinationsTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryWithTemporaryDestinationsTest.java?rev=1158694&r1=1158693&r2=1158694&view=diff
==============================================================================
--- activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryWithTemporaryDestinationsTest.java
(original)
+++ activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryWithTemporaryDestinationsTest.java
Wed Aug 17 13:29:35 2011
@@ -53,6 +53,36 @@ public class PooledConnectionFactoryWith
         broker.stop();
     }
 
+    public void testTemporaryQueueWithMultipleConnectionUsers() throws Exception {
+        Connection pooledConnection = null;
+        Connection pooledConnection2 = null;
+        Session session = null;
+        Session session2 = null;
+        Queue tempQueue = null;
+        Queue normalQueue = null;
+        
+        pooledConnection = pooledFactory.createConnection();
+        session = pooledConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        tempQueue = session.createTemporaryQueue();
+        LOG.info("Created queue named: " + tempQueue.getQueueName());
+        
+        assertEquals(1, countBrokerTemporaryQueues());
+        
+        pooledConnection2 = pooledFactory.createConnection();
+        session2 = pooledConnection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        normalQueue = session2.createQueue("queue:FOO.TEST");
+        LOG.info("Created queue named: " + normalQueue.getQueueName());        
+
+        // didn't create a temp queue on pooledConnection2 so we should still have a temp
queue
+        pooledConnection2.close();        
+        assertEquals(1, countBrokerTemporaryQueues());
+        
+        // after closing pooledConnection, where we created the temp queue, there should

+        // be no temp queues left
+        pooledConnection.close();        
+        assertEquals(0, countBrokerTemporaryQueues());
+    }
+    
     public void testTemporaryQueueLeakAfterConnectionClose() throws Exception {
         Connection pooledConnection = null;
         Session session = null;



Mime
View raw message