rabbitmq - 在 RabbitMQ 中处理消费者取消通知

标签 rabbitmq

我们已按照 http://www.rabbitmq.com/ha.html 中的说明进行操作设置具有 3 个节点rabbit1、rabbit2 和rabbit3 的主动-主动集群。 为了创建镜像队列,我们​​使用 x-ha-policy 并获取消费者取消通知,我们在 clientProperties 中将 Consumer_cancel_notify 设置为 true。 现在,我们将消息发布到以rabbit2为主的队列,并让消费者从rabbit3消费。当rabbit2停止时,连接到rabbit3的消费者不会收到取消通知。

我们使用的是rabbitmq 2.8.2-1,我们的java消费者POC代码在这里 - https://gist.github.com/2990146

不确定我们做错了什么。任何指示将不胜感激。

有人尝试过使用 php-amqplib 处理取消通知吗?

最佳答案

您要点的第 22 行是一个问题。 Consumer_cancel_notify 需要位于 clientProperties 的功能表中,而不是顶级键。

clientProperties.put("consumer_cancel_notify", Boolean.valueOf(true));

AMQP 0-9-1 clients don't by default expect to receive basic.cancel methods from the broker asynchronously, and so in order to enable this behaviour, the client must present a capabilities table in its client-properties in which there is a key consumer_cancel_notify and a boolean value true. See the capabilities section for further details on this. http://www.rabbitmq.com/extensions.html#consumer-cancel-notify

Handwaving伪java(请测试后编辑此答案)

Map<String, Object> clientProperties = new HashMap<String, Object>();
Map<String, Object> clientCapabilities = new HashMap<String, Object>();
clientCapabilities.put("consumer_cancel_notify", Boolean.valueOf(true));
clientProperties.put("capabilities", clientCapabilities);

至于您最初的问题,“有人尝试使用 php-amqplib 处理取消通知吗?”看起来答案是坚定的“也许”==> http://grokbase.com/t/rabbitmq/rabbitmq-discuss/11cynv8zkz/active-active-implementation-in-php

关于rabbitmq - 在 RabbitMQ 中处理消费者取消通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11218603/

相关文章:

django - 我无法在我的 Mac 上启动 rabbitmq

rabbitmq - 直接交换和扇出交换有何必要?

java - Spring云流-RabbitMQ配置

Spring Boot 无法 Autowiring 和运行

linux - erl与centos "Failed to create main carrier for ll_alloc"

ruby-on-rails - 无法在 Linux 上安装 rabbitmq-server(Oracle Linux Server 版本 6.7/RHEL)

rabbitmq - 自动化 RabbitMQ 消费者测试

python - RabbitMQ 不断关闭连接

java - RabbitMQ 如何将作业拆分为任务并处理结果

ssl - 使用 SSL 配置 rabbitmq 的问题