问题
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