Nack and reject on RabbitMQ

我是研究僧i 提交于 2021-01-04 06:40:50

问题


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 with some lines of code on my application, but I wonder if a better solution exists, maybe using some functionality of RabbitMQ directly.


回答1:


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



来源:https://stackoverflow.com/questions/43249811/nack-and-reject-on-rabbitmq

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!