对于已发送 confirm.select
方法的发布者,RabbitMQ 代理的字面读取 documentation建议客户端收到消息确认响应的顺序可能与原始消息发布的顺序不同。
谁能证实情况确实如此?或者消息是否总是按照收到的顺序进行确认?如果可以以不同的顺序接收消息确认,那么需要什么条件才能实现这种情况?
最佳答案
Can anyone verify that this is indeed the case?
是的,消息可以按不同的顺序确认
What conditions are required for this to be the case?
The basic rules for confirm are as follows:
- an un-routable mandatory or immediate message is confirmed right after the basic.return;
- otherwise, a transient message is confirmed the moment it is enqueued;
- a persistent message is confirmed when it is persisted to disk or when it is consumed on every queue.
所以,可能的原因可能是:
- 考虑持久性消息尚未持久化到磁盘而是转发给消费者的情况。由于消息是异步处理的,不同的消息可能会被消费者以不同的顺序确认,因此确认的顺序也会相应改变。
- TCP 问题。发布者发布的数据包不能保证以相同的顺序到达代理服务器。因此,发布者不能假设按照其发布的顺序接收它们。
关于rabbitmq - RabbitMQ 是否保证已发布消息确认传送回客户端的顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42679694/