RabbitMQ pop操作原子性
有谁知道 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的多个进程正在使用来自同一队列的消息,那么它们永远不应该使用相同的消息。
不过,这里有一些注意事项:
如果消息已由代理传递给您的某个消费者,并且它拒绝该消息(或在有机会确认它之前终止),那么代理会将其放回到同一消息上。队列,它将被传递给您剩余的活跃消费者之一。
If your multiple processes are consuming messages from the same queue then they should never consume the same message.
Here are the caveats, though:
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.
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.