c# - NServiceBus 可恢复性失败时发送消息
问题描述
有没有办法在且仅当 Recoverability 执行的所有重试都失败时才向 NServiceBus 发送消息?简而言之,我想向另一个队列发送一条新消息(同时它被发送到错误队列)。我不确定是否或如何插入管道来执行此操作。
我有一个行为,当我抛出一个特定的异常时,它通过向 NServiceBus 发送一个事件(绕过重试)来处理它,但是我有另一个用例,我想仅在重试失败后发送相同的事件。
class OperationFailedExceptionBehavior : Behavior<IIncomingLogicalMessageContext>
{
public override async Task Invoke(IIncomingLogicalMessageContext context, Func<Task> next)
{
try
{
await next().ConfigureAwait(false);
}
catch (OperationFailedException ex)
{
//since we're catching the exception, retries will no longer occur.
await context.Publish(new OperationFailedEvent(ex));
}
}
}
解决方案
可能通知是您正在寻找的。您可以订阅错误通知,我认为它将为您提供实现上述要求所需的所有详细信息。
有关更多详细信息:https ://docs.particular.net/nservicebus/recoverability/subscribing-to-error-notifications
推荐阅读
- http - 为什么带有 vanilla Rust 的 HTTP GET 请求没有得到响应?
- sql - 如何在 Presto SQL 中 JSON.stringify 我的 SELECT 值?
- javascript - 从字符串的开头和结尾删除一个字符的所有实例
- scala - 在 Akka Scala 中访问消息对象实例
- reactjs - 为什么当我将 onClick 事件添加到我的按钮时,CSVLINK(react-csv) 不再工作?
- wordpress - 为酒店建立网站 - WordPress 是最好的主意吗?
- r - R 中 dplyr 的 filter() 无法创建子集数据帧
- php - 如何从另一个表中获取一个值并将其保存到 Laravel 5 中的另一个表中
- git-bash - 打开名称中带有空格的文件夹
- 3d - 有什么方法可以从 Blender 中的多个对象中删除修改器?