NServiceBus Sagas: Batch items together?

104 Views Asked by At

The title may not be quite right for what I am asking, but i can't think of a good way to phrase it.

Essentially, I am designing a system where a transaction enters the system, is validated, business rules are applied and the transaction persisted to a database. Each transaction has a defined key, so i was thinking of creating a saga that implemented the controller pattern and defined these steps.

The problem comes in at the timed transmission of the data later however. I have potentially thousands of different transactions that need to be transmitted to different partners at specified cutoff times. I need all transactions for a specified partner to be in that partner's file. What I don't see is how to get all the transactions that have an individual saga to fire and gather at the same time.

I was thinking of implementing a timeout to have each transaction fire at it's cutoff time, but how do i gather all the transactions together?

One option I am examining is to use Quartz.Net to set a timed job to run at each cutoff time and then have that job publish a message back to the saga and use the ConfigureHowToFindSaga function to update the status of the transaction. I'm just not sure this is the best implementation.

1

There are 1 best solutions below

0
On

After you process at least one of the transactions for a given partner you could request a timeout based on a calculation of the current time with the expected cutoff time. For example, if you process a transaction at 9am, this means you have at least one transaction to send to that partner and if your cutoff is at 5pm, then the requested timeout would be for 8 hours. Upon processing the timeout you can send the file and update the saga that the file was sent.