spring webclient: retry with backoff on specific error

前端 未结 4 1420
后悔当初
后悔当初 2021-01-12 16:07

i\'d like to retry the request 3 times after waiting 10sec when response is 5xx. but i don\'t see a method that I can use. On object

WebClient.builder()
             


        
4条回答
  •  天命终不由人
    2021-01-12 17:08

    // ...
    .retryWhen(
        backoff(maxAttempts, minBackoff)
            .filter(throwable -> ((WebClientResponseException) throwable).getStatusCode().is5xxServerError()))
    // ...
    

提交回复
热议问题