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.