Hello,
I’m wanting to use NServiceBus’s concurrency to plow through a repetitive action and append the result to an list in memory. I have a list of ID’s and I want to perform an operation on each of the IDs, and make a list of the results to insert into a database. I was thinking I would have a secondary endpoint with some concurrency > 1 that would handle a message with one of the IDs, and an object would be sent back in the reply, and that object would be added to a list. When the list is complete, I would write the list to the database in a single connection.
I was hoping I could use this approach instead of writing each result to the DB as it is calculated so I wouldn’t waste all the extra time opening and closing the connection for each row, and also to avoid database deadlocks.
Is this possible to implement in NServiceBus? It seems it would be straightforward with this kind of tool. The part I’m getting hung up on is once the calculation is performed for the ID, how do I reply in a way that in my handler that sent off the message with the ID can add the result to the list for each calculation? Thanks.
(C#, .NET Standard 2.0)