Spring Retry Circuit breaker opening for all exceptions

一个人想着一个人 提交于 2021-01-29 08:41:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!