RabbitMQ pop操作原子性

发布于 2024-11-02 09:43:26 字数 107 浏览 6 评论 0原文

有谁知道 RabbitMQ 队列上的 pop 操作是否是原子的?

我有几个进程从同一个队列中读取数据(该队列被标记为持久的,在版本 2.0.0 上运行),并且我看到一些非常奇怪的行为。

Does anyone know if the pop operation on a RabbitMQ queue is atomic?

I have several processes reading from the same queue (the queue is marked as durable, running on version 2.0.0) and I am seeing some quite odd behaviour.

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

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

发布评论

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

评论(1

街角迷惘 2024-11-09 09:43:27

如果您的多个进程正在使用来自同一队列的消息,那么它们永远不应该使用相同的消息。

不过,这里有一些注意事项:

  1. 如果消息已由代理传递给您的某个消费者,并且它拒绝该消息(或在有机会确认它之前终止),那么代理会将其放回到同一消息上。队列,它将被传递给您剩余的活跃消费者之一。

  2. 消费者从不同的队列中提取数据(每个队列都有一个匹配的绑定),那么代理会将消息的副本放在每个队列上,并且每个消费者将获得同一消息的副本。

If your multiple processes are consuming messages from the same queue then they should never consume the same message.

Here are the caveats, though:

  1. If a message has been delivered by the broker to one of your consumers and it rejects the message (or terminates before getting a chance to acknowledge it) then the broker will put it back on the same queue and it would be delivered to one of your remaining active consumers.

  2. If your consumers are pulling from distinct queues -- each with a matching binding -- then the broker will put copies of the message on each queue and each consumer will get a copy of the same message.

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