Spring Boot Resilience4J Circuit Breaker(fallback method)

I don't have clearly understand how the fallback method works. For example: Example Will this method be executed after each error in the callee method or just when the circuit breaker will be closed?

Upvotes: 1

Views: 3837

Answers (1)

Robert Winkler
Robert Winkler

Reputation: 1907

It's like a try/catch, but after the CircuitBreaker has recorded success/failure. If you use Exception in your fallback method signature, it catches all Exceptions. But you can narrow down the scope to CallNotPermittedException, if you only want to execute the fallback method when the CircuitBreaker is open.

Upvotes: 2

Related Questions