Art*_*nov 5 java spring kotlin spring-boot spring-cloud
我有配置服务器,应用程序从该服务器获取配置。我想设置抓取的重试机制。如果配置服务器不可用,应用程序应发送 10 分钟的请求。
在 spring 文档中我找到了下一个配置
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
Run Code Online (Sandbox Code Playgroud)
但他们什么也改变不了。我的应用程序不执行重试请求,它只是失败了
Caused by: java.net.ConnectException: Connection refused: connect
Run Code Online (Sandbox Code Playgroud)
(配置服务器此时已关闭)
我究竟做错了什么?有办法解决我的问题吗?
Art*_*nov -1
我通过将 next @Bean 添加到上下文中解决了我的问题
@Bean
public RetryOperationsInterceptor configServerRetryInterceptor(RetryProperties properties) {
return RetryInterceptorBuilder
.stateless()
.backOffOptions(properties.getInitialInterval(),
properties.getMultiplier(),
properties.getMaxInterval())
.maxAttempts(properties.getMaxAttempts()).build();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5049 次 |
| 最近记录: |