0

I have a method on a service annotated with @Retryable. If I call that method direct in a Controller the retry logic works. When I call that method indirectly through a wrapper method the retry logic does not get triggered.

public class SomeService{
  // When calling this there is no retry
  public void wrapper(){
    isOn();
  }
  
  // Calling this direct the retry works
  @Retryable(maxAttempts = 8)
  public boolean isOn() {
    System.out.println("Testing");
    throw new RuntimeException("Failing");
  }
}

I want to call the method with retry logic because there is a rather unstable endpoint that needs to be connected to. After that any errors would be valid and no retry is needed.

Is there a way to make sure the nested retry logic runs without having to retry the entire wrapping method?

nerdlyist
  • 2,842
  • 2
  • 20
  • 32
  • I believe @Retryable(maxAttempts = 8) is supposed to be the exception value to retry... i.e. `@Retryable(value = SQLException.class)` and if that exception occurs it will retry. https://www.baeldung.com/spring-retry – Darkman Dec 15 '22 at 18:17

0 Answers0