RE: programmatic RabbitTemplate configuration
thanks gary for the pointers!
i took a shortcut, in the init method i did this:
Code:
private void init()
{
isUsable = true;
amqpTemplate = new RabbitTemplate(connectionFactory);
replyContainer = new SimpleMessageListenerContainer(connectionFactory);
context = new GenericApplicationContext();
admin = new RabbitAdmin(connectionFactory);
admin.setApplicationContext(context);
admin.setAutoStartup(true);
replyQueueName = "REPLY_QUEUE."+ UUID.randomUUID().toString();
createReplyQueue();
}
..and in createReplyQueue()
Code:
private void createReplyQueue()
{
declareQueue();
replyContainer.setQueueNames(replyQueueName);
replyContainer.setMessageListener(amqpTemplate);
replyContainer.afterPropertiesSet();
replyContainer.start();
}
private void declareQueue()
{
boolean durable = false;
boolean autoDelete = true;
boolean exclusive = true;
replyQueue = new Queue(replyQueueName,durable,exclusive,autoDelete);
context.getBeanFactory().registerSingleton(replyQueueName, replyQueue);
admin.afterPropertiesSet();
}
this works very well and passes all the tests. any potential overhead might be only due to creating GenericApplicationContext at initialization time. not sure if that's too much.
RabbitAdmin is a constructor parameter and the manager now hands out pre-configured with a connectionFactory.
The user is allowed to specify #of connections (for performance).
when you get a chance, feel free to point as many errors/bugs/in-efficiencies with this code!
best regards and thanks much,
-cogitate