Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
443 views
in Technique[技术] by (71.8m points)

spring boot - Resilience4j circuit breaker doesn't open when slowCallRateThreshold is reached?

I've decorated the following method with a Resilience4j CircuitBreaker:

 @CircuitBreaker(name = "getSwaggerFileName")
 private Optional<String> getSwaggerFileName(String url) {
            return Optional.ofNullable(restTemplate.getForObject(url, SwaggerQueryResponse.class))
                    .flatMap(SwaggerQueryResponse::getFileName); 
 }

My circuit breaker config is stored in application.yaml:

resilience4j:
  circuitbreaker:
    configs:
      default:
        slowCallRateThreshold: 50
        slowCallDurationThreshold: 1
        slidingWindowSize: 20
        waitDurationInOpenState: 60000
    instances:
      getSwaggerFileName:
        baseConfig: default

This file is definitely being found, and a similar setup works fine with the @RateLimiter annotation. I've lowered the slowCallDurationThreshold from 2000ms to 1ms, and even tried introducing a Thread.sleep call to the method to verify it's taking longer than the duration threshold. The method runs around 100 times (edit: and the problem still occurs when slidingWindowSize and minimumNumberOfCalls are set well below this number).

But my circuit breaker doesn't open, after around 100 calls to this method. As I see it, it should open if more than 50% of those calls take more than 1ms. Am I missing something?

question from:https://stackoverflow.com/questions/65900515/resilience4j-circuit-breaker-doesnt-open-when-slowcallratethreshold-is-reached

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It's because the method is private. The method must be public so that it can be proxied.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...