以下是官网原话
https://www.rabbitmq.com/confirms.html#when-publishes-are-confirmed
When Will Published Messages Be Confirmed by the Broker?
For unroutable messages, the broker will issue a confirm once the exchange verifies a message won’t route to any queue (returns an empty list of queues). If the message is also published as mandatory, the basic.return is sent to the client before basic.ack. The same is true for negative acknowledgements (basic.nack).
For routable messages, the basic.ack is sent when a message has been accepted by all the queues. For persistent messages routed to durable queues, this means persisting to disk. For mirrored queues, this means that all mirrors have accepted the message.
大意是说 消息只要进入交换器 就会发送 Ack 但是当消息无法路由到队列时 会在发送basic.ack 之前 发送一条basic.return 命令
所以 rabbitmq的confirm 模式 只是保证了消息进入了rabbitmq 并且被处理,这个被处理 不一定保证进入队列,还有可能被返回(设置了mandatory的时候)。只要交换器是存在的,在进入confirm模式后 就一定是返回Ack的 除非交换器不存在 才会返回Nack
我看 rabbitmq 实战指南说的是 保证进入队列 今天脑子一热试了下 结果怎么都是 ack 除非交换器不存在 一看官网,才知道到现在的版本 已经变成这样了。