How to set handler concurrency per entity


I wonder if it’s possible to have something like in NServiceBus?

Sample scenario:

  • for customer id = 1, DoSthHandler should execute messages one by one
    and messages for customers 2 and 3 can run at the same time as for customer 1


Within NServiceBus, a Saga is very close to an actor. An actor has concurrency, an inbox, a behaviour, and communicates via messaging. Similar attributes can be seen within NServiceBus Sagas.

This means that if you described your handlers within a Saga which is identified by customer ID, then messages for customer 1 would run synchronously and other customers messages could be processed at the same time.

Hi Kamil

What are the restrictions that force you to only process messages of customer 1 one by one?

Those restrictions could be an indication that a distinct message type for that type of customer is needed that goes to an individual endpoint that is only processing messages one by one (as an alternative to the saga proposal).

It seems even with the saga idea proposed by @WilliamBZA you need a way to identify this specific type of customer and then explicitly model that with messages, handlers and potentially sagas.


I guess he is having concurrency issues. If you allow concurrency and have a lot of messages for the same customer than you would continuously get optimistic concurrency errors.

Please read the following for suggestions on how to deal with high load scenarios:

The consistent hashing approach is very much similar to partitioned message processing: