tags:

views:

86

answers:

1

I have an NServiceBus app which receives a particular message when a large database update is required. While this update is happening, I want to either somehow ignore all incoming messages of this type. What is the best way of doing it? Should I put a lock statement in there?

+1  A: 

In the config of NServiceBus (App.config) you can set the NumberOfWorkerThreads, if you set this to 1 only one message at a time will be processed.

Then if you keep the time you stopped processing this message in memory. You can drop all messages that have arrived between these two times.

But as Udi probably would say, don't try to solve it technically but find a solution from the business perspective.

Jochen
Thanks! Is it possible to specify the # of threads for a particular message, rather than every single type of message?
Dmitri Nesteruk
That isn't possible, but wouldn't it be better to have an other endpoint (other queue) for that type of message? To do that you have to create a seperate component that only handles these types of messages.
Jochen