I studied the answer from this question @Recover methods are not triggered with @Retryable
But I can't figure out why recover method does not run in my case.
@Service public MyRetryingService {
@Scheduled(fixedRate = 10 * 1000)
@Retryable(backoff = @Backoff(delay = 100, maxDelay = 101), maxAttempts = 3)
public void transferData() {
throw new IllegalArgumentException();
}
@Recover
public void recover(IllegalArgumentException exception) {
System.out.println("Recovering from a service down");
}
}
I get this exception
org.springframework.retry.ExhaustedRetryException: Cannot locate recovery method; nested exception is java.lang.IllegalArgumentException
What am I missing here?