没有连接的 AMQP/RabbitMQ 通道什么时候会死亡?

发布于 2024-12-18 12:12:03 字数 465 浏览 7 评论 0原文

我有一个简单的 RabbitMQ 测试程序,随机将消息排队,另一个读取它们,所有这些都使用 Spring-AMQP。如果消费者死亡(例如,在没有机会关闭其连接或通道的情况下终止进程),则它尚未确认的任何消息似乎将永远保持未确认状态。

我看过许多参考资料(例如 这个问题),这些参考文献都说通道在没有连接时就会终止,而剩下的通道就会终止。未确认的消息将被重新传送。这不是我看到的行为 - 相反,我得到了越来越多的标记为空闲的通道列表和越来越多的标记为正在运行但没有活动的连接列表。

是否需要进行一些配置才能注意到进程被终止后连接就消失了?

编辑: 我在 VirtualBox VM 中运行rabbitmq 服务器,它显然无法通过 NAT 正确管理无效的入站连接。这对于直接在物理主机上运行的 mq 服务器来说效果很好。

I have a simple RabbitMQ test program randomly enqueuing messages, and another reading them, all using Spring-AMQP. If the consumer dies (for example killing a process without having a chance to close its connection or channel), any messages that it had not acknowledged appear to remain unacknowledged forever.

I have seen a number of references (for example this question) that say that the channel dies when it has no connections, and that remaining unack'd messages will be redelivered. That's not the behaviour I see - instead I get a growing list of channels marked IDLE and a growing list of connections marked running but with no activity.

Is there some configuration required to notice that connections are dead once the process has been killed?

EDIT:
I was running the rabbitmq server inside a VirtualBox VM, which apparently doesn't manage dead inbound connections correctly over NAT. This works just fine with the mq server running directly on the physical host.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

中二柚 2024-12-25 12:12:03

AMQP 使用队列和交换器。您在交换器上发布并绑定队列以从交换器获取消息(您可以查看简短说明 在我的博客上,当您创建队列时,您可以将其设置为自动删除,以及在自动删除之前它会保持未使用的时间。
以下是 RabbitMQ 快速参考中的引用:

queue.declare(短保留-1,队列名称队列,位被动,位
持久、位独占、位自动删除、不等待不等待、表
参数)➔声明-ok

支持:完整的声明队列,如果需要则创建。

此方法创建或检查队列。创建新队列时
客户端可以指定控制持久性的各种属性
队列及其内容,以及队列的共享级别。

RabbitMQ 实现了 AMQP 规范的扩展,允许
队列的创建者来控制其行为的各个方面。

每队列消息 TTL 此扩展确定消息的持续时间
发布到队列的数据在被服务器丢弃之前可以存活。
生存时间通过 x-message-ttl 参数配置
该方法的arguments参数。

队列到期 可以使用可选的租用时间来声明队列。这
租约时间决定队列在被使用之前可以保持未使用状态的时间长度
被服务器自动删除。租赁时间作为
x-expires 此方法的arguments 参数中的参数。

镜像队列我们开发了主动/主动高可用性
队列。这是通过允许队列镜像到其他节点来实现的
在 RabbitMQ 集群内。结果是 a 的一个节点应该
集群失败,队列可以自动切换到其中一个镜像
并继续运营,不会出现服务不可用的情况。创造
镜像队列,您在参数中提供 x-ha-policy 参数
此方法的参数。

AMQP uses Queues and Exchanges. You publish on an exchange and you bind queues to get messages from exchanges (you can see a short explanation on my blog. When you create a queue you can set it to auto-delete as well as how much time will it stay unused before it auto deletes.
Here's a quote from the 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.

千年*琉璃梦 2024-12-25 12:12:03

回答结束。事实证明这不是一个真正的问题。

我在 VirtualBox VM 中运行rabbitmq 服务器,它显然无法通过 NAT 正确管理无效的入站连接。这对于直接在物理主机上运行的 mq 服务器来说效果很好。

Answering to close. This turns out not to be a real issue.

I was running the rabbitmq server inside a VirtualBox VM, which apparently doesn't manage dead inbound connections correctly over NAT. This works just fine with the mq server running directly on the physical host.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文