We're am trying to serialize processing of a list of business objects using a Saga.
Right now, without a Saga, we simply loop through a list of objects, and fire off a bus.Send(new ProcessBusinessObejct(obj))
async to have handlers execute. So the processing happens more or less in parallel, depending on this setting, I believe:
endpointConfiguration.LimitMessageProcessingConcurrencyTo( 4 );
This has worked fine but the amount of concurrent handlers is now hard on the database.
It would be OK to trigger these handlers in series, i.e. continue with the next only when the current process has finished (failed or succeeded). We don't want to set the concurrency to 1, it would affect all handlers in the endpoint.
The idea is to use the Scatter/Gather pattern and a Saga to keep track of the number of objects and update the state machine with the a count (total count, failed count, success count), and lastly fire an event when the list is done/empty.
The problem is
A) I'm not sure how to keep track of the list in the saga. The SagaData would need a List to keep all objects? Then remove an instance when a handler signals it's done processing. The saga does not support hierarchical data and hence no List or List. I believe this is still the case in NSB v7.
And B) Is this use of saga feasable or overkill or is there a much simpler way to accomplish this?
We are using Sql Server persistence and transport and NSB 7.
Any input is much appreciated!