Checking a Spring Cloud CircuitBreakers status

925 views Asked by At

We're using Spring cloud circuitbreaker to handle outages when making calls to an external service. We also have a scheduled job which calls this service. I'd like to prevent the job from running if the circuitBreaker is open but I don't see any way of checking this as neither the CircuitBreaker (Resilience4JCircuitBeaker) or the CircuitBreakerFactory expose methods that allow this to be checked. Is there another way I can achieve this?

1

There are 1 answers

1
Robert Winkler On BEST ANSWER

As an alternative, you could use our Resilience4j Spring Boot 2 starter and inject the CircuitBreakerRegistry into your class in order to check the status of a CircuitBreaker instance. Our starter has a lot of other advantages like external configuration, annotation support, metrics, ...

Basically you can copy code snippets of our CircuitBreakersHealthIndicator class.