Roll back an activity on failure

Taking the example of money transfer in a banking app described in the docs, I have a question regarding a scenario.

Money transfer has 2 steps: withdrawal and deposit. Let’s say withdrawal was a success. Now while trying to deposit, it fails because the routing number is incorrect. Now I want the withdrawal to be rolled back. I’m trying to make a case where if an activity fails, the previous activities should be rolled back.

How does Temporal handle this?

Which sdk are you using. If activity B fails you can run activity that compensates already performed A. Java sdk has a built in saga class id that helps:

Thank you for responding. I’m using go sdk, and I found an example implementing the saga pattern - samples-go/saga at main · temporalio/samples-go · GitHub.

@tihomir Hi is there any similar util exist in python SDK? I cannot locate that. Also the saga sample is not present in GitHub - temporalio/samples-python: Samples for working with the Temporal Python SDK