在 RabbitMQ 上拒绝和拒绝 [英] Nack and reject on RabbitMQ

查看:73
本文介绍了在 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

其中 foo、bar 和 baz 是消息.

Where foo, bar and baz are messages.

如果消费者读取 baz 但出现问题,我可以使用 basic.rejectbasic.nack ( https://www.rabbitmq.com/nack.html).使用这两个命令之一,我将传递参数以重新排队消息.

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.

问题是消息在之前的位置重新排队,所以下一个消息将再次baz.

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

我在我的应用程序中使用了一些代码行解决了问题,但我想知道是否存在更好的解决方案,也许直接使用 RabbitMQ 的某些功能.

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.

推荐答案

你可以看看死信队列(DLQ):https://www.rabbitmq.com/dlx.html

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

这篇关于在 RabbitMQ 上拒绝和拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆