Listener Container Queues
-
能够动态添加和移除队列。
-
提高了容错性,当一个队列不可用时,容器会自动重试。
-
当一个队列被移除时,容器会尝试恢复处理其他队列的消息。
版本 1.3 对侦听器容器中处理多个队列进行了多项改进。
Version 1.3 introduced a number of improvements for handling multiple queues in a listener container.
容器最初可以配置为监听零队列。队列可以在运行时添加和删除。SimpleMessageListenerContainer
循环回收(取消并重新创建)所有消费者,当已处理任何预取的消息时。DirectMessageListenerContainer
为每个队列创建/取消单个消费者,而不影响其他队列上的消费者。请参阅 addQueues
、addQueueNames
、removeQueues
和 removeQueueNames
方法的 Javadoc。
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.
如果并非所有队列都可用,该容器会尝试以静默方式声明(然后消费)缺失队列,每 60 秒执行一次。
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.