Getting IMessageSession into OnMessageSentToErrorQueue callback

Hi all,

I’m trying to send an event message when certain messages fail for the last time (going to error queue). I’ve read in other posts that I could leverage OnMessageSentToErrorQueue with a callback.

My current setup is a console service that uses .net standard IoC and calls UseNServiceBus inside Host.CreateDefaultBuilder to set everything up. I have no idea how to get the IMessageSession to the error handling callback with this configuration. All examples I’ve seen show a simple setup not using IoC where the endpoint is configured and started in the same class.

Any help would be appreciated. Thanks.

Hi @Bill_Staff,

you can use my very simple NServiceBus.Extensions.EndpointStarted addon to capture the message session instance.

Let me know if that helps.
.m

1 Like

That looks like it did the trick.
Thank you.

1 Like