【问题标题】:SimpleMessageListenerContainer subscribing to multiple queues with RetryOperationsInterceptorSimpleMessageListenerContainer 使用 RetryOperationsInterceptor 订阅多个队列
【发布时间】:2018-10-16 21:33:30
【问题描述】:

我正在使用订阅 3 个不同队列的 SimpleMessageListenerContainer。 SimpleMessageListenerContainer 已配置了具有指数退避策略的 RetryOperationsInterceptor。

我的 SimpleMessageListenerContainer 已配置:

container.addQueueNames("news.politics","news.science","news.tech");
container.setMaxConcurrentConsumers(10);
container.setAdviceChain(new Advice[]{retryInterceptor});

如果来自已消费的 3 个队列之一的消息进入错误状态导致异常,则消费者会按预期触发策略的指数回退。但是,我注意到消费者停止循环,以处理其他 2 个队列上的消息。我在想,既然消费者的“MaxConcurrentConsumer”设置为 10,消费者将开始生成消费者线程并循环其余队列。

  1. 这是 SimpleMessageListenerContainer 的正常行为吗?
  2. 可以调整此行为吗?
  3. 对于我的用例,是否建议每个队列有一个 SimpleMessageListenerContainer 以保持它们隔离?也许想出一个装饰器 CompositeSimpleMessageListener 容器,它在每个队列内部都有一个 SimpleMessageListenerContainers 映射?

【问题讨论】:

    标签: spring-boot rabbitmq spring-rabbit


    【解决方案1】:

    增加消费者的算法有限;如果重试拦截器挂起消费者线程,它将阻止新消费者的启动。

    要么增加concurrentConsumers(至少为3),要么切换到DirectMessageListenerContainer。 见choosing a container

    【讨论】:

    • 谢谢加里! DirectMessageListenerContainer 解决方案就像一个魅力。感谢您链接到“选择容器”文章 - 非常有帮助。将并发消费者增加到 3 个的另一种方法不起作用。最终,所有 3 个消费者都陷入了指数退避,忽略了其他队列中的消息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-29
    • 2019-06-02
    • 1970-01-01
    • 2013-01-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多