Search code examples
spring-bootcircuit-breakerretry-logicresilience4j

Resilience4j Retry+Spring Boot 2 application.yml config not applied


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


Solution

  • 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
    ...