mirror of https://github.com/apache/activemq.git
Allow for PooledConnectionFactory restart after being stopped.
This commit is contained in:
parent
667ea7c640
commit
0706fd0bc1
|
@ -301,6 +301,7 @@ public class PooledConnectionFactory implements ConnectionFactory, QueueConnecti
|
||||||
try {
|
try {
|
||||||
if (connectionsPool != null) {
|
if (connectionsPool != null) {
|
||||||
connectionsPool.close();
|
connectionsPool.close();
|
||||||
|
connectionsPool = null;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.activemq.jms.pool;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.Assert.assertNotSame;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
@ -122,6 +123,32 @@ public class PooledConnectionFactoryTest extends JmsPoolTestSupport {
|
||||||
cf.stop();
|
cf.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(timeout = 60000)
|
||||||
|
public void testFactoryStopStart() throws Exception {
|
||||||
|
|
||||||
|
ActiveMQConnectionFactory amq = new ActiveMQConnectionFactory(
|
||||||
|
"vm://broker1?marshal=false&broker.persistent=false&broker.useJmx=false");
|
||||||
|
PooledConnectionFactory cf = new PooledConnectionFactory();
|
||||||
|
cf.setConnectionFactory(amq);
|
||||||
|
cf.setMaxConnections(1);
|
||||||
|
|
||||||
|
PooledConnection conn1 = (PooledConnection) cf.createConnection();
|
||||||
|
|
||||||
|
cf.stop();
|
||||||
|
|
||||||
|
assertNull(cf.createConnection());
|
||||||
|
|
||||||
|
cf.start();
|
||||||
|
|
||||||
|
PooledConnection conn2 = (PooledConnection) cf.createConnection();
|
||||||
|
|
||||||
|
assertNotSame(conn1.getConnection(), conn2.getConnection());
|
||||||
|
|
||||||
|
assertEquals(1, cf.getNumConnections());
|
||||||
|
|
||||||
|
cf.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Test(timeout = 60000)
|
@Test(timeout = 60000)
|
||||||
public void testConnectionsAreRotated() throws Exception {
|
public void testConnectionsAreRotated() throws Exception {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue