0

I'm using Spring Boot to configure Retry, I configured some of Retry instances in YML file but because I can't find option how to calculate IntervalFuntion I want to config some instances in @Configuration file, and I have been lost.

  @Bean
  public Retry customRetryConfigCustomizer() {
    RetryConfig config = RetryConfig.custom()
        .intervalFunction(IntervalFunction.ofExponentialBackoff(2000L, 1.75d))
        .maxAttempts(10)
        .retryExceptions(WebClientRequestException.class)
        .build();
    Retry.of(SOME_CLIENT_INSTANCE, config);
    return RetryRegistry.ofDefaults().retry(SOME_CLIENT_INSTANCE, config);
  }

I think Retry configurates but it hasn't been added into RetryRegistry that spring uses in his @Retry annotations, and I don't know what am I missing. Also I don't want to use RetryConfigCustomizer because in that option first I have to create instance in YML file then I can change it.

So I repeat my question:

Is there a way to extend RetryRegistry that is configured in YML file and creates Retry in configuration file?

Adriano
  • 874
  • 2
  • 11
  • 37
  • Did you manage to solve this problem? I needed to add logging https://stackoverflow.com/a/66883879/1460643 – LeshaRB Feb 11 '22 at 10:01
  • I did it everything by Spring config file ` resilience4j.retry: instances: webClient: maxAttempts: 4 waitDuration: 2s enableExponentialBackoff: true exponentialBackoffMultiplier: 2 retryExceptions: - org.springframework.web.reactive.function.client.WebClientRequestExceptio` – Adriano Feb 11 '22 at 12:22

0 Answers0