Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rabbitmq when to use basic reject over basic nack?

Tags:

rabbitmq

Basic nack provides facility to return negative acknowledgement for one or multiple messages.

Basic reject has facility to return negative acknowledgement for only one message.

Do we have any use case where we definitely need basic reject?

like image 690
Sahil Sharma Avatar asked Dec 22 '25 05:12

Sahil Sharma


2 Answers

The answer by @cantSleepNow is correct, I would also like to add one more difference which is in their default behaviour.

By default, nack will put the message back in the queue for later handling. You can change the setting to not re-queue with nack.

With reject, by default, the message is not re-queued by RabbitMQ but will drop the message from the queue entirely.

like image 187
Ankush G Avatar answered Dec 24 '25 09:12

Ankush G


With rabbitmq you can always nack over reject. Logically there is no explicit need to use reject, since nack can do anything reject can. As you said, both of these work for one message, but nack also for multiple.

Also nack is introduced by rabbitmq (so it's an extension), and is not part of amqp 0.9.1 specs.

like image 20
cantSleepNow Avatar answered Dec 24 '25 11:12

cantSleepNow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!