0
votes

I was playing with the fault tolerance of my system by turning off my NServiceBus endpoint and pushing messages into an MSMQ queue.

On startup of the endpoint (NServiceBus.Host.exe) my messages are picked up (they are "Commands") and processed. The handlers that handle these commands also publish events. These events however aren't being handled. Does anyone know why this might be?

If I Send a new command whilst the endpoint is running everything processes fine. The flow is this when the NServiceBus host is already running (correct):

UI -> 
    Command -> 
        MSMQ -> 
            Endpoint -> 
                CommandHandler -> 
                    Event -> 
                        EventHandler

This is the flow when the messages are sitting on the queue with no endpoint yet started:

--Endpoint not running -- -> 
    UI -> 
        Command -> 
            MSMQ -> 
                --Endpoint started-- -> 
                    CommandHandler -> 
                        Nothing.

The event handler is in the same assembly as the command handlers that are picking up the commands and processing them.

It just appears that the events aren't being published and/or handled during NService Bus' startup process. The messages are picked up and commands are handled.. but any events that are then published are not picked up by their listeners and are therefore not handled.

You should be aware that I have called PurgeOnStartup(false) for the endpoint and the client. This works fine as far as I am aware.. because the commands on the queue are actually handled fine.. they just don't publish any events.

1
I am seeing the same behavior. I shut down the subscriber, put some messages in the queue with Bus.Send from my client. When I startup the subscribers, the commands are handled, but the subscribed events are not. I can then send another message and my event handlers fire. Is it because I am using InMemoryPersistence?Kevin Raffay
What type of persistence do you use?Szymon Pobiega

1 Answers

1
votes

I'm guessing that since the endpoint is self contained NSB will not initiate a subscription to itself implicitly. You could try to explicitly set up a subscription and it should work. This is somewhat an atypical scenario and won't work implicitly.