I encountered some odd behaviour with NSB when one endpoint listens for the same event with multiple internal handlers. When publishing the event, it would appear that if any handlers of that message encounter an error, all the other handlers of the same message fail to receive the event.
I have an assembly that takes the message “OrderReceived” and implements it in two handlers: GoodHandler and BadHandler. If I publish my event, both handlers fire correctly. However, if I force BadHandler to throw an exception, GoodHandler is never triggered. The message sits in the queue and is never delivered.
If I restart the endpoint, GoodHandler now runs and completes successfully. When BadHandler kicks in a few seconds later through the error retry mechanism in NSB, it throws another exception, which stops messages arriving again.
To replicate the issue, try downloading the Pub/Sub sample, copy the event handler and manually throw an exception in the second handler. Set a breakpoint or log a message in the first handler and notice it never fires.
My guess is that it might be unusual to have two handlers of the same event in the same assembly? In our real world case we have an event published that several aggregates in the domain are interested in. Once they receive the event being published, they kick off some internal tasks to bring their aggregates up to date.
Are we using the event handlers in a way that is not expected? If multiple handlers listen for the same event in one endpoint, is this expected behaviour?