Time Based Saga with Event Sourcing

Let's say I wanted to create a saga created by some event, then it sits and waits for several hours, and if nothing happens, sends some command.

Now, if this saga was all in memory, and I had to restart the application / server, the saga would be unloaded and never be seen again, right?

Would I use Event Sourcing to bring this saga to speed as soon as the system returns to the network?

If so, I will need quite a lot of separate event storage with “active sagas” that can be replayed at system startup to speed up my Sagas. This is good for me so far, but how would I implement a timeout?

I need to somehow "fake" timeouts during repeated playback, given that there may be several subsequent timeouts depending on the events included in the saga.

+5
source share
1 answer

The best way to achieve this is with another endpoint that can return a message to you at a specific point in time. For example, your saga may send a message to this “timeout manager” and say wake me up in 1 hour or 1 day or even 1 year. Then the message will be returned to you at that time. Ideally, this message has a business meaning that can trigger an action.

, - , , 7 , . "-" : RemindUserToConfirmAccountMessage. 7 , , , . , - .

+6

All Articles