I am trying to understand how to design a Temporal workflow. In my case, I need to wire transfer money from one bank account to another in a workflow. The wire transfer code is written in an activity.
When the activity runs, it tries to do the wire transfer. But if the API call it makes fails, I don’t want to retry this activity as I am not sure if the transfer succeeded or not. While configuring the activity I say no retries.
But what happens to the workflow at this point?
A manual intervention is required here. Someone manually confirms the wire transfer has not happened. In this case, I would like the workflow to re-execute the activity. In the case wire transfer is done I would like the workflow to skip over the activity.
My design involves a DB table update - When the activity start it puts a ‘wire-in-progress’ entry in the DB before making a call to the API. When the wire transfer completes, it marks the entry as ‘complete’.
This is to ensure idempotency of the activity. If the activity by some chance runs again, if it finds a ‘wire-in-progress’ or ‘complete’ entry in the DB, it doesn’t do the wire transfer again.
My plan is, during the manual intervention, the user will mark the ‘wire-in-progress’ entry as complete, if the wire was successful, or will make the ‘wire-in-progress’ entry as ‘not-started’ as part of the manual resolution. After doing that, the workflow can be kicked off again.
My question is, how does one start the workflow from that point, skipping things that have happened before. How do we re-execute an activity that has been marked as no-retries.