Closed kyle-log closed 3 months ago
The exception that should be thrown when the circuit breaker is open is CallNotPermittedException
.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Thanks for the answer. It seems that CallNotPermittedException
is a specific exception used in the Resilience4j
framework.
// as is
import io.github.resilience4j.circuitbreaker.CallNotPermittedException;
factory.create(name).run(
() -> { /* block */ },
e -> {
if (e instanceof CallNotPermittedException) {
// Open
return DefaultValue()
} else {
// Not open
throw e
}
}
);
// to be, (example)
import org.springframework.cloud.client.CircuitOpenException
factory.create(name).run(
() -> { /* block */ },
e -> {
if (e instanceof CircuitOpenException) {
// Open
return DefaultValue()
} else {
// Not open
throw e
}
}
);
This is to provide flexibility in case the circuit breaker implementation Resilience4j
changes to something else..
Sorry I am not following what you are saying
Problem describe I need to know the Resilience4j implementation to define the behavior of the CircuitBreaker when it is opened. Here's why
I only want to know the Spring cloud circuit breaker interface, not the resilience4j implementation, because I want to be able to easily change to a different implementation in the future.
Solution
Alternatives I'm currently using a custom exception to handle the situation when the circuit breaker is open. For more details, you can refer to this implementation: https://github.com/kyle-log/circuit-breaker-without-annotation"