0

Right now I define retry strategy for each webClient call (like below)

    public ModelResponse exampleMethod() {

        return webClient
                .get()
                .uri("/example")
                .retrieve()
                .bodyToMono(ModelResponse.class)
                .retryWhen(Retry.backoff(3, Duration.ofSeconds(1))
                        .filter(throwable -> throwable instanceof WebClientResponseException
                                && ((WebClientResponseException) throwable).getStatusCode().is5xxServerError()))
                .block();
    }

I'd like to share the same retry strategy among all WebClients calls (for different methods and http requests).

Is it possible to set retry strategy on reactor.netty.http.client.HttpClient and then use it to create WebClient ?

1 Answers1

0

There is one way to do so by creating ExchangeFilterFunction to handle server error, and there define retry strategy. Although, it sounds great there are some kickbacks. Finally, I came up with solution based on Adding a retry all requests of WebClient