Get MassTransit message retries amount(获取 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 消息重试次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:获取 MassTransit 消息重试次数
基础教程推荐
- C# 从 List<List<int>> 中删除重 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- WPF 模态进度窗口 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
