xyzale
xyzale

Reputation: 795

Nack and reject on RabbitMQ

I want to handle unsuccessful messages the consumer gets from the queue and re-queue them.

Imagine I have a situation like this:

P => | foo | bar | baz | => C

Where foo, bar and baz are messages.

If consumer reads baz but something goes wrong, I can either use the basic.reject or the basic.nack ( https://www.rabbitmq.com/nack.html ). Using one of these two commands, I will pass the argument to requeue the message.

The problem is the message is requeued in the same position it was before, so the next message will be baz again.

I would like to requeue it but send it back to the beginning of the queue:

P => | baz | foo | bar | => C

I solved it with some lines of code on my application, but I wonder if a better solution exists, maybe using some functionality of RabbitMQ directly.

Upvotes: 3

Views: 4542

Answers (1)

lambodar
lambodar

Reputation: 3783

you can take a look on the Dead Letter Queue(DLQ): https://www.rabbitmq.com/dlx.html

Upvotes: 2

Related Questions