NimbusAPI / Nimbus

Nimbus is a .NET client library to provide an easy abstraction over common messaging frameworks.

Home Page:http://nimbusapi.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BusEventSender.Publish() swallowing exceptions - how does OutboundInterceptor.OnEventPublishingError work?

ma499 opened this issue · comments

We've seen a couple of instances in production now of losing transactions where we are calling IBus.Publish() within a message handler (i.e. a message handler that publish events as part of it's work). We're using our fork of Nimbus v2.

From what we can see the message handler fails to deadletter because the bus.publish() method call, which we await, does not throw an exception. Despite this we see the Nimbus Logger log the fact that the IBus.Publish() method failed.

Looking at BusEventSender.cs we see that it catches the exception, awaits interceptor.OnEventPublishingError() and then logs the error (a network error connecting to our Service Bus instance - I can provide the log, if of interest).

Looking at the source of OutboundInterceptor.cs I can't understand what it's doing or how it's supposed to work.

To my understanding we want BusEventSender.Publish() to re-throw any exception, so that it bubbles up to IBus.Publish() and hence to any consumer. In that way, our message handler would then get (and re-throw) the exception such that the message would have been re-submitted to the queue - or deadlettered.

I'm happy to work on a patch to ensure exceptions are thrown but I'm just a little bit cautious because I don't understand how the Interceptor is working.

We have now raised PR #266 to solve this.