相关疑难解决方法(0)

spring webclient:重试特定错误时退避

当响应为 5xx 时,我想在等待 10 秒后重试请求 3 次。但我没有看到可以使用的方法。在对象上

WebClient.builder()
                .baseUrl("...").build().post()
                .retrieve().bodyToMono(...)
Run Code Online (Sandbox Code Playgroud)

我可以看到方法:

在重试次数但没有延迟的条件下重试

.retry(3, {it is WebClientResponseException && it.statusCode.is5xxServerError} )
Run Code Online (Sandbox Code Playgroud)

重试退避和次数但没有条件

.retryBackoff 
Run Code Online (Sandbox Code Playgroud)

还有一个,retryWhen但我不知道如何使用它

java spring project-reactor spring-webflux spring-webclient

14
推荐指数
3
解决办法
2万
查看次数