RabbitTemplate.invoke(OperationsCallBack) 在消息 nacked/returned/timeout 时不会抛出异常

RabbitTemplate.invoke(OperationsCallBack) is not throwing exceptions when messages are nacked/returned/timeout

我正在使用以下代码在同一频道上等待确认(ack/nack/returns/timeout)。

我发送的 routingKey 不正确,因此 rabbitMq 应该根据以下 api 文档抛出异常。但是我没有从 api.

中得到异常

我们将 waitForConfirmsOrDie 超时设置为(60 秒) 有人可以建议我对 api 的期望是否不正确。

不直观,但是返回的消息不会产生nack;返回消息后收到肯定的ack。 Nacks 仅由代理错误或具有大小限制且溢出行为设置为 reject-publish.

的队列引起

https://www.rabbitmq.com/confirms.html

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.

使用correlated confirms(不是简单的confirms),可以在收到ack后通过查看相关数据来判断消息是否返回

In addition, when both confirms and returns are enabled, the CorrelationData is populated with the returned message, as long as the CorrelationData has a unique id; this is always the case, by default, starting with version 2.3. It is guaranteed that the return message is set before the future is set with the ack.