0

I would like my IHandleMessages<X>.Handle(X x) methods to be called concurrently by NSB. Even when configuring the default host AsA_Client - which turns off transactions - and providing two or more threads (NumberOfWorkerThreads="3" in App.Config), the following handler is called twice sequentially when there are two messages on the queue:

public void Handle(EventMessage message)
{
    Logger.Info(string.Format("Subscriber 1 received EventMessage with Id {0}.", message.EventId));
    Logger.Info(string.Format("Message time: {0}.", message.Time));
    Logger.Info(string.Format("Message duration: {0}.", message.Duration));
    Thread.Sleep(10000);
}

This is merely a modified version of the PubSub demo that is supplied with NSB. No matter what settings I provide - I've also tried tweaking the IsolationLevel, to no avail - this handler blocks concurrent calls.

In practice, this is not desirable for one specific set of handlers that we are writing. The desired behavior would be - at minimum - to let concurrent threads into the Handle method and we would manually mediate access to state with software locks.

Is this not possible or am I missing a trick?

  • could it be that executing three log statements is so blindingly fast that they just happen to end up next to each other in your log file? – mookid8000 Mar 01 '11 at 08:56
  • maybe you should try interleaving the log statements with `Thread.Sleep(1000)` – mookid8000 Mar 01 '11 at 09:04
  • Since you are using NServiceBus 2.0, and the thread limit does not apply, it would be helpful to see your app.config and the logger output. – David Boike Mar 09 '11 at 19:27

1 Answers1

2

The most likely cause is that you're using the free Express Edition of NServiceBus which is limited to a single thread. The commercially available Standard Edition allows you to run multiple threads.

NOTE: NServiceBus now performs at full speed in the free trial - no more performance throttling.

Udi Dahan
  • 11,932
  • 1
  • 27
  • 35