问题
I was trying to use Spring Retry Circuit Breaker. My requirement is to open the Circuit only for repetitive exceptions of a specific type. And for all other exceptions, I would like to pass the exception back to the caller without opening the circuit. What I am observing is that the Circuit is opening for all types of Exceptions, not just the specific exception. Wondering if this is how it is designed to work?
My requirement: When I call a remote service, I would like to open the service only for any network errors. If I receive any data validation error from remote service, I would just like to pass a meaningful exception back to the business layer.
As I was playing with the framework, I see that the circuit is opening for all exceptions. Can someone advise if the above requirement can be achieved with Spring Retry Circuit breaker? If yes, could you point to some sample code?
Thanks in advance, B Jagan
回答1:
Yes; that's the way it works; when you include
or exclude
exception types, it relates to the max attempts.
When a "retryable" exception is thrown, the circuit won't go open until maxAttempts
have occurred within openTimeout
; if an exception is not retryable, the circuit goes open on the first attempt.
You would need a custom retry policy to do what you want.
来源:https://stackoverflow.com/questions/62780667/spring-retry-circuit-breaker-opening-for-all-exceptions