gpt4 book ai didi

java - Camel Hystrix EIP - IgnoreExceptions 以防止调用 Fallback

转载 作者:太空宇宙 更新时间:2023-11-04 09:55:54 25 4
gpt4 key购买 nike

在Apache Camel Hystrix EIP中,如何防止调用错误请求异常的fallback方法。我尝试从请求调度程序处理器中抛出“HystrixBadRequestException”,但我仍然看到回退正在被触发。有什么办法可以解决这个问题吗?

 /* in route builder class */
public void configure() throws Exception {
.hystrix()
.hystrixConfiguration()
.circuitBreakerEnabled(circuitBreakerConfig.isEnabled())
.executionTimeoutInMilliseconds(circuitBreakerConfig.getConnectionTimeoutInMilliseconds())
.circuitBreakerErrorThresholdPercentage(circuitBreakerConfig.getErrorThresholdPercentage())
.circuitBreakerSleepWindowInMilliseconds(circuitBreakerConfig.getSleepWindowInMilliseconds())
.circuitBreakerRequestVolumeThreshold(circuitBreakerConfig.getRequestVolumeThreshold())
.metricsRollingStatisticalWindowInMilliseconds(circuitBreakerConfig.getRollingPercentileWindowInMilliseconds())
.end()
.to("requestDispatcher")
.onFallback()
.log(LoggingLevel.INFO, "Fallback:")
.bean("responsehandler", "getFallbackResponse")
.stop()
.end()
}
/* in dispatcher class */
private Exchange dispatchRequest(Exchange exchange) {
if (exception instanceof HttpOperationFailedException) {
Integer statusCode = ((HttpOperationFailedException) exception).getStatusCode();
if(statusCode == 400) {
throw new HystrixBadRequestException("Hystrix bad request");
}
}
}

最佳答案

目前camel-hystrix 中尚未实现此功能。我已经记录了一张票证,以便在即将发布的版本中添加此功能:https://issues.apache.org/jira/browse/CAMEL-13066

关于java - Camel Hystrix EIP - IgnoreExceptions 以防止调用 Fallback,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54151657/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com