【发布时间】:2018-10-05 08:18:56
【问题描述】:
假设我使用默认的 Hystrix 配置:
CircuitBreakerRequestVolumeThreshold=20
CircuitBreakerErrorThresholdPercentage=50
MetricsRollingStatisticalWindowInMilliseconds=10000ms
我假设这意味着在 10 秒的窗口内,如果在 20 个连续请求中处理了 10 个异常,则电路将中断。
我有一个名为 MyCommand 的类,它扩展了 HystrixCommand。我创建了 20 个对象并依次调用每个对象的执行。但我似乎没有使电路跳闸,因为它从未进入我的 getFallback 方法。我预计第 20 次执行会使电路跳闸。我哪里错了?
int i=0;
public MyObject run() throws Exception {
i++;
try {
throw new Exception("Handled exception "+i);
} catch (Exception e) {
System.out.print("Catch "+i);
}
return null;
}
【问题讨论】:
-
这里有一个相关的评论:在持续时间metrics.rollingStats.timeInMilliseconds的时间跨度内,导致处理异常的操作百分比超过errorThresholdPercentage,前提是在时间跨度内通过电路的操作数至少是 requestVolumeThreshold
标签: hystrix