Camel Hystrix EIP - IgnoreExceptions 以防止调用 Fallback
Posted
技术标签:
【中文标题】Camel Hystrix EIP - IgnoreExceptions 以防止调用 Fallback【英文标题】:Camel Hystrix EIP - IgnoreExceptions to prevent call to Fallback 【发布时间】:2019-06-06 16:17:39 【问题描述】:在 Apache camel Hystrix EIP 中,我们如何防止对 bad request 异常的 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");
【问题讨论】:
【参考方案1】:这目前没有在 camel-hystrix 中实现。我已经记录了一张票,以便在即将发布的版本中添加它:https://issues.apache.org/jira/browse/CAMEL-13066
【讨论】:
以上是关于Camel Hystrix EIP - IgnoreExceptions 以防止调用 Fallback的主要内容,如果未能解决你的问题,请参考以下文章
Camel Hystrix EIP - IgnoreExceptions 以防止调用 Fallback
EIP/Apache Camel - 如何同时处理消息,但每个组原子处理?
如何在 Apache Camel 中结合 Redelivery policy 和 Hystrix 断路器?