mirror of https://github.com/apache/activemq.git
AMQ-7233 - ensure sessions are cleaned up on pooledconnection.close before temp dests to ensure temp dests actually get deleted, fix and test
This commit is contained in:
parent
dc56fa3f6e
commit
efc857fc1f
|
@ -81,8 +81,8 @@ public class PooledConnection implements TopicConnection, QueueConnection, Poole
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws JMSException {
|
public void close() throws JMSException {
|
||||||
this.cleanupConnectionTemporaryDestinations();
|
|
||||||
this.cleanupAllLoanedSessions();
|
this.cleanupAllLoanedSessions();
|
||||||
|
this.cleanupConnectionTemporaryDestinations();
|
||||||
if (this.pool != null) {
|
if (this.pool != null) {
|
||||||
this.pool.decrementReferenceCount();
|
this.pool.decrementReferenceCount();
|
||||||
this.pool = null;
|
this.pool = null;
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.activemq.jms.pool;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import javax.jms.Connection;
|
import javax.jms.Connection;
|
||||||
|
import javax.jms.MessageConsumer;
|
||||||
import javax.jms.Queue;
|
import javax.jms.Queue;
|
||||||
import javax.jms.Session;
|
import javax.jms.Session;
|
||||||
import javax.jms.Topic;
|
import javax.jms.Topic;
|
||||||
|
@ -119,6 +120,24 @@ public class PooledConnectionFactoryWithTemporaryDestinationsTest extends JmsPoo
|
||||||
assertEquals(0, countBrokerTemporaryTopics());
|
assertEquals(0, countBrokerTemporaryTopics());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(timeout = 60000)
|
||||||
|
public void testTemporaryQueueLeakAfterConnectionCloseWithConsumer() throws Exception {
|
||||||
|
Connection pooledConnection = null;
|
||||||
|
Session session = null;
|
||||||
|
Queue tempQueue = null;
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
pooledConnection = pooledFactory.createConnection();
|
||||||
|
session = pooledConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||||
|
tempQueue = session.createTemporaryQueue();
|
||||||
|
MessageConsumer consumer = session.createConsumer(tempQueue);
|
||||||
|
consumer.receiveNoWait();
|
||||||
|
LOG.info("Created queue named: " + tempQueue.getQueueName());
|
||||||
|
pooledConnection.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(0, countBrokerTemporaryQueues());
|
||||||
|
}
|
||||||
|
|
||||||
private int countBrokerTemporaryQueues() throws Exception {
|
private int countBrokerTemporaryQueues() throws Exception {
|
||||||
return ((RegionBroker) brokerService.getRegionBroker()).getTempQueueRegion().getDestinationMap().size();
|
return ((RegionBroker) brokerService.getRegionBroker()).getTempQueueRegion().getDestinationMap().size();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue