【问题标题】:Resilience4j Retry+Spring Boot 2 application.yml config not appliedResilience4j Retry+Spring Boot 2 application.yml 配置未应用
【发布时间】:2020-09-19 11:55:04
【问题描述】:

我将 Resilience4j @Retry 与 @CircuitBreaker 结合使用。 我在 SpringBoot 2 中使用注解,我的配置在 application.yml 中。 我在@Retry 注释中有一个后备方法,但在@CircuitBreaker 中没有(这是使它们一起工作的方法,因为根据我的发现的方面顺序)。

@CircuitBreaker 使用我在 application.yml 中的配置可以正常工作。 重试也有效,但仅使用默认配置值,并且不反映 application.yml 中的值(例如:maxAttempts 是 3 而不是 5)。

知道我在这里可能做错了什么吗?

在代码中:

@CircuitBreaker(name = "myService")
@Retry(name = "myService", fallbackMethod="myServiceFallback")
public HttpEntity myService(final String url) throws MyException{ 
//My logic 
}

The config in application.yml

【问题讨论】:

    标签: spring-boot circuit-breaker retry-logic resilience4j


    【解决方案1】:

    整理好了

    我正在使用 maxAttempts 在此处提到的配置中: https://resilience4j.readme.io/docs/retry

    正确的配置名称是 maxRetryAttempts,如下所示: https://github.com/resilience4j/resilience4j-spring-boot2-demo/blob/master/src/main/resources/application.yml

    resilience4j.retry:
        configs:
            default:
                maxRetryAttempts: 3
                waitDuration: 100
    ...
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-24
    • 2020-09-10
    • 2018-03-24
    • 2018-09-24
    • 2020-11-02
    • 2019-07-17
    • 2019-05-19
    • 1970-01-01
    相关资源
    最近更新 更多