Listener Container Queues
Version 1.3 introduced a number of improvements for handling multiple queues in a listener container.
Container can be initially configured to listen on zero queues.
Queues can be added and removed at runtime.
The SimpleMessageListenerContainer
recycles (cancels and re-creates) all consumers when any pre-fetched messages have been processed.
The DirectMessageListenerContainer
creates/cancels individual consumer(s) for each queue without affecting consumers on other queues.
See the Javadoc for the addQueues
, addQueueNames
, removeQueues
and removeQueueNames
methods.
If not all queues are available, the container tries to passively declare (and consume from) the missing queues every 60 seconds.
Also, if a consumer receives a cancel from the broker (for example, if a queue is deleted) the consumer tries to recover, and the recovered consumer continues to process messages from any other configured queues. Previously, a cancel on one queue cancelled the entire consumer and, eventually, the container would stop due to the missing queue.
If you wish to permanently remove a queue, you should update the container before or after deleting to queue, to avoid future attempts trying to consume from it.