Zebi
Zebi

Reputation: 8882

How to add a service dependency to NServiceBus Generic Host

I have the following services Layout:

I am using the MSMQ Subscription storage.

My current problem is that I have to start the event handler service after the worker service is started. If I do it in reverse, or restart the worker service publications won't be received by the event handler service.

My first idea is to add a service dependency on the event handler service.

How would I do this using the generic host provided by NServiceBus? Is there a better way to solve the problem?

Upvotes: 1

Views: 223

Answers (2)

Adam Fyles
Adam Fyles

Reputation: 6050

I would recommend using the DB subscription option. This will keep your subscriptions around.

Upvotes: 0

tom redfern
tom redfern

Reputation: 31760

If you are using MSMQ as subscription storage then make the subscription queue transactional.

Then the subscription messages from the event handler service will remain on the worker service subscription queue even after restarting.

Regarding start up order, the event handler service will put a subscription into the input queue of the worker service, whether or not the worker services is started. So the start up order is also unimportant.

UPDATE

Actually this is strictly untrue, because making the queues transactional will give you durability across server restarts.

You should still get the same behaviour I described above with non-transactional queues.

Upvotes: 1

Related Questions