我有配置服务器,应用程序从该服务器获取配置。我想设置重试机制。如果配置服务器不可用,应用程序将发送请求10分钟。
在春季文档中,我找到了下一个配置
spring.cloud.config.uri=http://localhost:9090
spring.cloud.config.fail-fast=true
spring.cloud.config.retry.max-interval=10000
spring.cloud.config.retry.max-attempts=2000
但是他们什么也没改变。我的应用程序不重试请求,只是失败
Caused by: java.net.ConnectException: Connection refused: connect
(此时配置服务器已关闭)
我究竟做错了什么?有办法解决我的问题吗?
我通过在上下文中添加下一个@Bean解决了我的问题
@Bean
public RetryOperationsInterceptor configServerRetryInterceptor(RetryProperties properties) {
return RetryInterceptorBuilder
.stateless()
.backOffOptions(properties.getInitialInterval(),
properties.getMultiplier(),
properties.getMaxInterval())
.maxAttempts(properties.getMaxAttempts()).build();
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句