I am using NServiceBus (latest) with SQL Server everything…
I have what I believe to be a reasonably simple question - though my process or understanding may be a bit off kilter, so some suggestions are welcome.
What I would like to achieve is for a failed handler to publish an event prior to the message being sent to the message queue. I had this in a try/catch inside the handler where I was using the current context to publish the event and then re-throw the exception, but obviously then the published event gets rolled back, so the failure is never noticed. And I would also get an event per retry which isn’t ideal either.
Does the answer lie in a behaviour? Is there some other way to have an event published prior to a message heading to the error queue?