Nservicebus 处理程序触发问题
Nservice Bus handler trigger issue
我的项目正在升级以使用 nservice bus 版本 7。其中一个处理程序正在并发执行。经过分析发现,有一段行为代码是在handler election之后编写并执行的。然后接下来处理程序将得到 executed.This 将在循环中执行并且不会结束。
public class GatewayPublishBehavior : Behavior<IIncomingLogicalMessageContext>
{
public override async Task Invoke(IIncomingLogicalMessageContext context, Func<Task> next)
{
//// custom logic before calling the next step in the pipeline.
await next().ConfigureAwait(false);
// custom logic after all inner steps in the pipeline completed.
await context.Publish(context.Message.Instance,
this.RetrieveAndGetSendOptions(context));
}
}
以上是行为代码。不确定为什么处理程序会被多次执行。
就是这个代码
public void Whatever()
{
Whatever();
}
无限循环。只需删除发布。你为什么添加那行?你喜欢重复吗?因为您也发布了两次完全相同的问题。试图在 Whosebug 中创建一个递归循环?
每个任务都需要return东西。
return Task.CompletedTask;
只需在Handler 底部添加上面给定的代码即可。它会解决你的问题
我的项目正在升级以使用 nservice bus 版本 7。其中一个处理程序正在并发执行。经过分析发现,有一段行为代码是在handler election之后编写并执行的。然后接下来处理程序将得到 executed.This 将在循环中执行并且不会结束。
public class GatewayPublishBehavior : Behavior<IIncomingLogicalMessageContext>
{
public override async Task Invoke(IIncomingLogicalMessageContext context, Func<Task> next)
{
//// custom logic before calling the next step in the pipeline.
await next().ConfigureAwait(false);
// custom logic after all inner steps in the pipeline completed.
await context.Publish(context.Message.Instance,
this.RetrieveAndGetSendOptions(context));
}
}
以上是行为代码。不确定为什么处理程序会被多次执行。
就是这个代码
public void Whatever()
{
Whatever();
}
无限循环。只需删除发布。你为什么添加那行?你喜欢重复吗?因为您也发布了两次完全相同的问题。试图在 Whosebug 中创建一个递归循环?
每个任务都需要return东西。
return Task.CompletedTask;
只需在Handler 底部添加上面给定的代码即可。它会解决你的问题