简体   繁体   English

Nservice Bus 处理程序触发问题

[英]Nservice Bus handler trigger issue

My project is upgrading to use nservice bus version 7. One of the handler is getting executed concurrently.我的项目正在升级以使用 nservice 总线版本 7。其中一个处理程序正在同时执行。 After analysis found that there is a behavior code written and getting executed after handler election.经过分析发现,有一个行为代码在handler选举后被编写并被执行。 Then next the handler will get executed.This will executed in loop and not getting ended.然后接下来将执行处理程序。这将在循环中执行并且不会结束。

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));
  }
}

Above is the behavior code.以上是行为代码。 Not sure why the handler getting executed multiple times.不知道为什么处理程序被多次执行。

It's exactly like this code和这段代码一模一样

public void Whatever()
{
  Whatever();
}

An endless loop.一个无限循环。 Just remove the Publish.只需删除发布。 Why did you add that line?为什么要添加那行? Do you like duplicates?你喜欢重复吗? Because you posted the exact same question twice as well.因为您也两次发布了完全相同的问题。 Trying to create a recursive loop inside StackOverflow?试图在 StackOverflow 中创建递归循环?

Every task need to return something.每个任务都需要返回一些东西。

return Task.CompletedTask;

Just add the upper given code at the bottom of the Handler.只需在 Handler 底部添加上面的给定代码即可。 It will solve you problem它会解决你的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM