gpt4 book ai didi

java - 没有连接的 AMQP/RabbitMQ channel 什么时候死掉?

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:20:58 27 4
gpt4 key购买 nike

我有一个简单的 RabbitMQ 测试程序随机排列消息,另一个读取它们,全部使用 Spring-AMQP。如果消费者死亡(例如,在没有机会关闭其连接或 channel 的情况下终止进程),任何它尚未确认的消息似乎永远都不会被确认。

我看到很多引用资料(例如 this question )都说 channel 在没有连接时就死掉了,剩下的未确认的消息将被重新传送。这不是我看到的行为 - 相反,我得到了越来越多的标记为 IDLE 的 channel 列表和越来越多的标记为正在运行但没有 Activity 的连接列表。

是否需要一些配置来注意到一旦进程被终止连接就终止了?

编辑:我在 VirtualBox VM 中运行 rabbitmq 服务器,这显然无法通过 NAT 正确管理死入站连接。这适用于直接在物理主机上运行的 mq 服务器。

最佳答案

AMQP 使用队列和交换。您在交换器上发布并绑定(bind)队列以从交换器获取消息(您可以在我的博客上看到 short explanation。当您创建队列时,您可以将其设置为自动删除以及它在多长时间之前保持未使用状态它会自动删除。这是来自 RabbitMQ quickref 的引述:

queue.declare(short reserved-1, queue-name queue, bit passive, bit durable, bit exclusive, bit auto-delete, no-wait no-wait, table arguments) ➔ declare-ok

Support: full Declare queue, create if needed.

This method creates or checks a queue. When creating a new queue the client can specify various properties that control the durability of the queue and its contents, and the level of sharing for the queue.

RabbitMQ implements extensions to the AMQP specification that permits the creator of a queue to control various aspects of its behaviour.

Per-Queue Message TTL This extension determines for how long a message published to a queue can live before it is discarded by the server. The time-to-live is configured with the x-message-ttl argument to the arguments parameter of this method.

Queue Expiry Queues can be declared with an optional lease time. The lease time determines how long a queue can remain unused before it is automatically deleted by the server. The lease time is provided as an x-expires argument in the arguments parameter to this method.

Mirrored Queues We have developed active/active high availability for queues. This works by allowing queues to be mirrored on other nodes within a RabbitMQ cluster. The result is that should one node of a cluster fail, the queue can automatically switch to one of the mirrors and continue to operate, with no unavailability of service. To create a mirrored queue, you provide an x-ha-policy argument in the arguments parameter to this method.

关于java - 没有连接的 AMQP/RabbitMQ channel 什么时候死掉?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8296201/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com