Reputation: 910
I'm trying to implement a basic workflow (basic in my opinion), but I cannot figure out the AWS step functions way.
Basically, the requirements are the following:
So based on the requirements above I'm trying to combine that 2 months "timeout" and reminder mechanism, but it seems there is no built-in way to do that. It's pretty easy to deal with without step functions by creating records in the database and running cron jobs, but I'm hoping to get some advice on how to deal with this in an AWS way.
I've tried to add a "wait for callback" statement to the initial function which sends the first email, so that's how I can put a timeout 2 months on that task, so it'll fail after 2 months if I don't send "sendTaskSuccess" by clicking the link inside the email. But in this case, I don't know how to deal with reminders.
Another thing I've tried is to delegate reminders to another state machine and execute that state machine after initiating the first email. Basically workflow inside the workflow. But the problem here is that I cannot cancel the child workflow (it has the same task token as the parent) when the parent is successful (user clicked the link), it stays and sends reminders even after the parent step is gone.
Thanks for any advice!
Upvotes: 1
Views: 580
Reputation: 1078
One way of handling the timeout is to catch either States.Timeout or States.HeartbeatTimeout and move to the next reminder state.
There is a pattern for more complicated cases. You can have a Parallel branch with both your Callback Task and your Wait state. When you call SendTaskSuccess, you also want to complete the Parallel state and not wait for the Wait state to complete. If you don't receive a call to SendTaskSuccess, your Wait state will fire and can move to a Fail state. You also need to add the Catch statements to your parallel to control the execution flow (complete or enter another reminder).
There is a recent blog post about these early out patterns here:
Upvotes: 0