RabbitMQ/Spring: 如果当前独占注销,另一个独占消费者会注册自己吗?

RabbitMQ/Spring: Will another exclusive consumer register itself, if the current exclusive deregisters?

我有一个 spring 应用程序,它在 cloudfoundry 上的多个实例中运行。 这些实例共享一个数据库。他们有一个 RabbitListener 配置如下:

@RabbitListener(queues = "${items.updated.queue}", exclusive = true)

如果需要从某个来源重新导入项目,队列会收到一条消息。

我只想要一个实例来执行导入。据我了解,这可以通过独占标志来实现。

现在,如果当前 exclusive consumer 崩溃会怎样? 另一个当前 运行 的实例会把自己注册为新的 exclusive consumer 吗?还是仅在应用程序启动时才进行注册?

是的,另一个消费者将被授予访问权限。

消费者将 re-attempt 每 recoveryInterval 毫秒(默认 5000 - 5 秒)消费一次。

您可以通过在侦听器容器中设置间隔或 recoveryBackoff 来更改此设置。

请注意,您将从容器中获取有关故障的 WARN 日志和来自连接工厂的 INFO 日志,表明通道因故障而关闭。

您可以调整日志级别以减少这些日志,或者您可以将自定义 ConditionalExceptionLogger 注入到容器和工厂中。

the documentation

If a consumer fails because one if its queues is being used exclusively, by default, as well as publishing the event, a WARN log is issued. To change this logging behavior, provide a custom ConditionalExceptionLogger in the SimpleMessageListenerContainer's exclusiveConsumerExceptionLogger property. See also the section called “Logging Channel Close Events”.