Debugging our Code
Let’s go ahead and fix the exception in our Activity code by removing the thrown exception or commenting it out and re-running our code to register the code change.
In practice, your code will continue retrying until whatever issue the Activity has encountered has resolved itself, whether that is the network coming back online or an internal service starting to respond again.
By leveraging the durability of Temporal and out of the box retry capabilities, you have avoided writing retry and timeout logic yourself and saved your downstream services from being unnecessarily overwhelmed.
using Temporalio.Activities;
public class Activities
{
[Activity]
public Task<bool> withdrawMoney(double amount)
{
// throw new Exception("Bank service temporarily unavailable");
Console.WriteLine($"Successfully withdrawn $${amount}");
return Task.FromResult(true);
}
[Activity]
public Task<bool> depositMoney(double amount)
{
Console.WriteLine($"Successfully deposited $${amount}");
return Task.FromResult(true);
}
}