Let's Throw an Exception!
Now let's see Temporal in action!
We’ll now look at how Temporal retries your code. We’ll intentionally throw an exception in the withdrawMoney Activity code.
In our case, this is just an exception we are intentionally throwing, but this could just as easily be an internal service that isn't responding, a network outage, an application crashing, or more.
public class ReimbursementActivitiesImpl implements ReimbursementActivities {
@Override
public boolean withdrawMoney(double amount) {
// throw new RuntimeException("Bank service temporarily unavailable");
System.out.println("Successfully withdrawn $" + amount);
return true;
}
@Override
public boolean depositMoney(double amount) {
System.out.println("Successfully deposited $" + amount);
return true;
}
}