apache-camel - Apache骆驼ThrottlingExceptionRoutePolicy失败重置
问题描述
ThrottlingExceptionRoutePolicy .failures 在 failureWindow(time) 之后不断增加。说 failureWindow=1000 和 failureThreshold=10。这意味着如果在 1 秒内出现 10 次故障,则断开断路器。
public void onExchangeDone(Route route, Exchange exchange) {
if (this.keepOpen.get()) {
if (this.state.get() != 2) {
LOG.debug("opening circuit b/c keepOpen is on");
this.openCircuit(route);
}
} else {
if (this.hasFailed(exchange)) { //#1
this.failures.incrementAndGet();
this.lastFailure = System.currentTimeMillis();
}
this.calculateState(route);
}
}
protected boolean isThresholdExceeded() {
boolean output = false;
this.logState();
if (this.failures.get() >= this.failureThreshold && this.lastFailure >= System.currentTimeMillis() - this.failureWindow) {
output = true;
return output;
}
在每个 #1(hasFailed=true) 上,无论时间窗口如何,this.failures 都会增加。现在假设在一个小时的时间段内出现 10 个异常,calculateState 将在第 10 个异常打开电路,因为 failures >= failureThreshold 并且 lastFailure 时间在 failureWindow 内。只有在调用 closeCircuit 时才会重置失败。
它是一个错误吗?我想知道它有什么用?如果您正在使用它,请分享您的见解。
解决方案
推荐阅读
- html - 使用 read_html 无法读取某些标签
- swift - 如何将 SwiftUI 图像保存到磁盘或获取数据?
- java - 我在 java 和 xml 文件中编写印地语字体/语言,但它显示框
- php - 删除两列连接重复的行
- colors - 如何设置flycheck-posframe的颜色
- python - 使用莳萝负载时出现 UnicodeDecodeError
- javascript - 如何利用其不同的部分制作垄断板?
- angular7 - 注入在构造函数中定义但在同一个类的函数中未定义的 BsModalService
- php - 由于提供的动态值,我无法从数据库中获取数据
- java - 如何使用命令“ant run”解决“[javac] 错误:无效目标版本:12.0.1”