Reputation: 539
I am using amqplib as nodejs rmq client. I am using confirmChannel to publish a message with mandatory flag set.
Rabbitmq/Amqplib is not giving return on channel, when a message is posted to a topic exchange with two queues, in which one of node which has a queue got terminated.
According to the Documentation,
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).
When there are no queues to route, return
is fired. And when both queues are present ack
is received.
But during publishing if one of node got terminated which has a queue in it, I expected return
event. Only ack
is received in callback.
I am not sure whether it is Rabbitmq or amqplib behavior.
Upvotes: 1
Views: 1869
Reputation: 16177
I believe there is confusion here on what the expected behavior is.
Mandatory means that a message must be routable to a queue. If there is at least one queue bound to the routing key, then the condition of mandatory is met. If not, the message is returned.
There are two ways to receive a return. First, you may use the immediate flag. This tells the broker that the message must be immediately deliverable to a consumer (not just a queue). Or, you can use the mandatory flag, as you are doing.
In either case, if the message is deliverable, you should not expect it to be returned. So, if one of your queues is down, but the other is up, you have satisfied the conditions of either flag and will not have a returned message.
Publisher confirms is different. This feature will tell the client when a message was accepted by the broker. If the broker successfully accepts the message, a confirm will be received regardless of where the message goes.
Based on commentary below, the following documentation is relevant.
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.
Upvotes: 3