final CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
cachingConnectionFactory.setHost("localhost");
final RabbitTemplate template = new RabbitTemplate(cachingConnectionFactory);
template.setExchange(exchange.getName());
BlockingQueueConsumer consumer = template.execute(new ChannelCallback<BlockingQueueConsumer>() {
@Override
public BlockingQueueConsumer doInRabbit(Channel channel) throws Exception {
BlockingQueueConsumer consumer = createConsumer(template);
String tag = consumer.getConsumerTag();
assertNotNull(tag);
return consumer;
}
});
template.convertAndSend("foo", "message");
String result = getResult(consumer);
assertEquals(null, result);
template.convertAndSend("foo.end", "message");
result = getResult(consumer);
assertEquals("message", result);
consumer.stop();
cachingConnectionFactory.destroy();
}