'Spring Retry and Recovery

is it possible to recover from an exception, and then retry again with Spring Retry?

In Java, would be something like

try{
    doSomething(); // throws Exception
}catch(Exception e){
    recoverException();
    doSomething(); // OK
}

Thanks!!



Solution 1:[1]

A simpler alternative, using Failsafe:

RetryPolicy<Object> retryPolicy = RetryPolicy.ofDefaults();
Failsafe.with(retryPolicy).get(() -> doSomething());

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1