Liam
Liam

Reputation: 139

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?

Upvotes: 1

Views: 1343

Answers (1)

Robert Winkler
Robert Winkler

Reputation: 1907

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

Upvotes: 1

Related Questions