doTestEviction(pooledFactory);
}
public void doTestEviction(ConnectionFactory pooledFactory) throws Exception {
PooledConnection connection = (PooledConnection) pooledFactory.createConnection();
ActiveMQConnection amqC = (ActiveMQConnection) connection.getConnection();
final CountDownLatch gotExceptionEvent = new CountDownLatch(1);
amqC.addTransportListener(new TransportListener() {
public void onCommand(Object command) {
}
public void onException(IOException error) {
// we know connection is dead...
// listeners are fired async
gotExceptionEvent.countDown();
}
public void transportInterupted() {
}
public void transportResumed() {
}
});
sendMessage(connection);
LOG.info("sent one message worked fine");
createConnectionFailure(connection);
try {
sendMessage(connection);
TestCase.fail("Expected Error");
} catch (JMSException e) {
} finally {
connection.close();
}
TestCase.assertTrue("exception event propagated ok", gotExceptionEvent.await(5, TimeUnit.SECONDS));
// If we get another connection now it should be a new connection that
// works.
LOG.info("expect new connection after failure");