[英]RabbitMQ - How to configure conditional DLX?
I have active queue which will have all messages from Publisher.我有活动队列,其中包含来自发布者的所有消息。 My Consumer reads those message and Acks/Nacks depending on the message processing result.我的消费者根据消息处理结果读取这些消息和确认/确认。
while (true)
{
var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue();
var body = ea.Body;
var message = Encoding.UTF8.GetString(body);
var processed = ProcessMessage(message)
if (processed)
channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false);
else
channel.BasicNack(deliveryTag: ea.DeliveryTag, multiple: false, requeue: true);
}
My questions are我的问题是
true
for requeue
parameter when it is nacked correct?当requeue
参数被正确设置时,它是否设置为true
?Thanks for your inputs感谢您的投入
Starting with release 3.5.2, RabbitMQ automatically adds a header to dead-letterred messages with informations such as:从版本 3.5.2 开始,RabbitMQ 会自动向死信消息添加标头,其中包含以下信息:
Look at the "Dead-Lettered Messages" section near the end of the DLX documentation for more details.有关更多详细信息,请查看DLX 文档末尾附近的“死信消息”部分。
If you use an older version of RabbitMQ, then @Franklin's solution should work.如果您使用旧版本的 RabbitMQ,那么@Franklin 的解决方案应该可以工作。
if you set requeue to false then it will go to any DeadLetter Exchange assigned to the Queue.如果您将 requeue 设置为 false,那么它将转到分配给队列的任何 DeadLetter Exchange。 True will requeue the message. True 将重新排队消息。
What I have done for retry attempts is to Create a Hold Exchange and Queue.我为重试所做的工作是创建一个保留交换和队列。 If you want to retry a message Return a positive Ack to the Queue, Add a RetryAttepmts Header to the Message then Publish it to the HoldQueue Exchange with a timeout value.如果要重试消息向队列返回肯定的 Ack,请向消息添加 RetryAttepmts 标头,然后将其发布到具有超时值的 HoldQueue Exchange。 Set the Hold Queue Dead Letter Exchange to an exchange that will send the message to the original Queue.将保留队列死信交换设置为将消息发送到原始队列的交换。 Then Check the header and nack if the retry attempts are too large.如果重试尝试太大,则检查标头和 nack。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.