0

I need to use spring boot retry logic in my code. My retry method is getting call from multiple method, so I want to run retry logic for all caller method but retry logic is running only for first caller method and for later caller method, it is running only for 1 time in case of exception too.

someMethod1() {
    retry();
}
someMethod2() {
    retry();
}
someMethod3() {
    retry();
}

@Retryable(maxAttempts = 2, value = SomeException.class)
public void retry() {
    doSomething;
}
  • Check out [this](https://docs.spring.io/spring-framework/reference/core/aop/proxying.html#aop-understanding-aop-proxies) chapter in the spring docs. Specifically self-invocation. – tobifasc May 22 '23 at 14:20

1 Answers1

0

@Retryable only works for methods called from another bean; internal calls within the same bean bypass the retry interceptor.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179