4

I'm using Resilience4j @Retry combined with @CircuitBreaker. I use annotations in SpringBoot 2 and my configuration is in application.yml. I have a fallback method in the @Retry annotation, but not in the @CircuitBreaker (That's the way to make them work together because of the aspect order as per my findings).

The @CircuitBreaker works fine using my configuration in application.yml. The Retry also works but does use only the default config values and do not reflect the values in the application.yml (EX.: maxAttempts is 3 instead of 5).

Any idea what I may be doing wrong here, please?

In the code:

@CircuitBreaker(name = "myService")
@Retry(name = "myService", fallbackMethod="myServiceFallback")
public HttpEntity myService(final String url) throws MyException{ 
//My logic 
}

The config in application.yml

Stadmina
  • 121
  • 1
  • 8

1 Answers1

4

Sorted out.

I was using maxAttempts in the configuration as mentioned here : https://resilience4j.readme.io/docs/retry

Where the proper config name is maxRetryAttempts as shown here: https://github.com/resilience4j/resilience4j-spring-boot2-demo/blob/master/src/main/resources/application.yml

resilience4j.retry:
    configs:
        default:
            maxRetryAttempts: 3
            waitDuration: 100
...
subhashis
  • 4,629
  • 8
  • 37
  • 52
Stadmina
  • 121
  • 1
  • 8
  • 1
    Yes, Spring Boot documentation can be improved. Keep in mind it's community-driven. You can always improve it as well ;) https://resilience4j.readme.io/docs/getting-started-3#configuration – Robert Winkler Jun 02 '20 at 11:44