Question

i use NServiceBus as enterprise Service Bus, in the solution i'm developing i have an orchestration service which receives up to 10k messages from all client applications. I would like to improve the architecture performance and consequently enhance the solution provided.

I use a Saga Data class and i would like to share the access to it between all worker threads(up to now i set just to one thread but i want to set at least to 10), what happens when multiple threads try to access the same saga istance? Does NSB already provide such a concurrency feature? Do i have to implement it on my own? if latter any hints?

Thanks in advance

Was it helpful?

Solution

If I understand you correctly your asking what will happen if you have more than one thread accessing the same saga instance concurrently. NServiceBus is using the underlying storage to make sure that only one thread can create/update a given saga instance at the same time. Others will rollback and the NServiceBus support for retries will make sure that the message is retried and thereby solve the race condition for you. You can read more here:

http://andreasohlund.net/2012/09/19/nservicebus-sagas-and-concurrency/

OTHER TIPS

Its unlikely that you would have multiple sagas sharing the same instance data, its just not how they are designed to work. A saga is an instance of a long running process. The saga data class is just a construct that allows you to store information about that instance that helps manage its state over its lifetime. If you want to improve performance I would recommend you look at distributing your worker endpoints (http://docs.particular.net/samples/scaleout/).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top