}
@Test
public void testListenerRecoversFromClosedConnection() throws Exception {
ConnectionFactory connectionFactory1 = createConnectionFactory();
RabbitTemplate template = new RabbitTemplate(connectionFactory1);
CountDownLatch latch = new CountDownLatch(messageCount);
ConnectionFactory connectionFactory2 = createConnectionFactory();
container = createContainer(queue.getName(),
new CloseConnectionListener((ConnectionProxy) connectionFactory2.createConnection(), latch),
connectionFactory2);
for (int i = 0; i < messageCount; i++) {
template.convertAndSend(queue.getName(), i + "foo");
}