https://issues.apache.org/jira/browse/AMQ-6068 - fix and test. Cleanup from ra managed connection needs to remove the connection info, leaving the tcp connection free for another identity. Possibly this could be conditional on having a user supplied clientId

This commit is contained in:
gtully 2015-12-01 14:28:07 +00:00
parent 144b711a9a
commit 5a27bdf07e
3 changed files with 41 additions and 6 deletions

View File

@ -232,7 +232,7 @@ public class ActiveMQManagedConnection implements ManagedConnection, ExceptionLi
proxyConnections.clear();
try {
physicalConnection.cleanup();
physicalConnection.doCleanup(true);
} catch (JMSException e) {
throw new ResourceException("Could not cleanup the ActiveMQ connection: " + e, e);
} finally {

View File

@ -86,11 +86,7 @@ public class ConnectionManagerAdapter implements ConnectionManager, ConnectionEv
LOG.warn("Error occured during the cleanup of a managed connection: ", e);
}
try {
((ManagedConnection)event.getSource()).destroy();
} catch (ResourceException e) {
LOG.warn("Error occured during the destruction of a managed connection: ", e);
}
// should go back in a pool, no destroy
}
/**

View File

@ -33,7 +33,9 @@ import javax.jms.TopicConnectionFactory;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionEvent;
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -61,6 +63,13 @@ public class ManagedConnectionTest {
}
@After
public void destroyManagedConnection() throws Exception {
if (managedConnection != null) {
managedConnection.destroy();
}
}
@Test(timeout = 60000)
public void testConnectionCloseEvent() throws ResourceException, JMSException {
@ -160,6 +169,36 @@ public class ManagedConnectionTest {
}
}
@Test(timeout = 60000)
public void testSetClientIdAfterCleanup() throws Exception {
connection.setClientID("test");
try {
connection.setClientID("test");
fail("Should have received JMSException");
} catch (JMSException e) {
}
ActiveMQConnection physicalConnection = (ActiveMQConnection) managedConnection.getPhysicalConnection();
try {
physicalConnection.setClientID("testTwo");
fail("Should have received JMSException");
} catch (JMSException e) {
}
// close the proxy
connection.close();
// can set the id on the physical connection again after cleanup
physicalConnection.setClientID("test3");
try {
physicalConnection.setClientID("test4");
fail("Should have received JMSException");
} catch (JMSException e) {
}
}
@Test(timeout = 60000)
public void testSessionCloseIndependance() throws ResourceException, JMSException {