【发布时间】:2023-03-21 17:46:02
【问题描述】:
下面是我的Hystrix命令配置:
@HystrixCommand(fallbackMethod = "fall", commandProperties = {
@HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "5"),
@HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "10000") })
public <T> T getInfo(Class clazz) {....}
后备方法:
public <T> T fall(Class clazz) {
System.out.println("fallback");
throw new CustomRuntimeException("API Down");
}
我了解按照以下配置,即
@HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "5"),
@HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "10000") }
5 个请求将在 10 秒内被允许,直到电路跳闸打开并且来自第 5 个请求的每个请求都将被拒绝,并且由于我在回退方法中抛出异常,它将被包装为 HystrixRuntimeException。
但我面临以下问题:
- 直到电路跳闸打开,故障恢复正常执行,并且
throwing
CustomRuntimeException(注:Hystrix 命令方法也 抛出CustomRuntimeException) - 电路跳闸打开后,我得到
Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: getInfo short-circuited and fallback failed.
问题:
- 为什么在电路打开之前异常没有被包装为 HystrixRuntimeException,即当前回退正常执行并抛出 CustomRuntimeException 直到电路打开?*
- 为什么在流程 1->2->3->4->5->6->8 甚至在
失败(即抛出
CustomRuntimeException)并且不抛出 一个包裹的HystrixRuntimeException,这是在流的情况下发生的 1->2->3->4->8 和 1->2->3->5->8
【问题讨论】:
标签: spring-boot hystrix circuit-breaker