获取 MassTransit 消息重试次数 [英] Get MassTransit message retries amount

查看:59
本文介绍了获取 MassTransit 消息重试次数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Masstransit+RabbitMQ.我的一位消费者实施了重试策略,我想知道一旦消息在错误队列中,是否有任何方法可以重试消息?

I'm using Masstransit+RabbitMQ. One of the my consumers implements retry policy and I'm wondering if there any way to get message's retries amout once message is in the error queue?

我还想知道 MT 计数是如何重试的,因为我没有使用 RabbitMq 服务器在消息头中查找任何相关信息.

Also I would like to know how MT counting retries because I didn't namage to find any related information in message's headers using RabbitMq server.

谢谢.

推荐答案

您可以在您的消费者中使用以下方法重试重试次数.

You can, in your consumer, use the following method to retry the retry attempt number.

consumeContext.GetRetryAttempt()

如果当前处理尝试是重试,它应该返回 > 0.

It should return > 0 if the current processing attempt is a retry.

一旦达到重试限制,下一个版本的 MassTransit (v6) 将在错误队列 MT-Fault-RetryCount 中包含一个标头,其中包含已尝试的重试次数.此外,Fault<T> 消息将具有相同的可用标头.

Once the retry limit is reached, the next version of MassTransit (v6) will include a header in the error queue MT-Fault-RetryCount which will have the number of retries that were attempted. Also, Fault<T> messages will have that same header available.

这篇关于获取 MassTransit 消息重试次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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