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# 控制相机设备 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 如果条件可以为空 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 将数据集转换为列表 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
