Nservice Bus handler trigger issue

ぃ、小莉子 提交于 2020-04-17 17:53:08

问题


My project is upgrading to use nservice bus version 7. One of the handler is getting executed concurrently. After analysis found that there is a behavior code written and getting executed after handler election. 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.


回答1:


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?



来源:https://stackoverflow.com/questions/60553781/nservice-bus-handler-trigger-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!