mirror of
https://github.com/apache/activemq.git
synced 2025-02-16 23:16:52 +00:00
Allow for PooledConnectionFactory restart after being stopped. (cherry picked from commit 0706fd0bc1f499f1fc304ec1c70aa8aaa3dd4d69)
This commit is contained in:
parent
21cd612098
commit
85da157238
@ -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;
|
||||||
@ -117,6 +118,32 @@ public class PooledConnectionFactoryTest extends JmsPoolTestSupport {
|
|||||||
assertEquals(3, cf.getNumConnections());
|
assertEquals(3, cf.getNumConnections());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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…
x
Reference in New Issue
Block a user