【问题标题】:Camel Hystrix EIP - IgnoreExceptions to prevent call to FallbackCamel Hystrix EIP - IgnoreExceptions 以防止调用 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");
        }
    }
}

【问题讨论】:

    标签: java apache-camel hystrix


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2023-03-21
      • 1970-01-01
      • 2018-11-06
      • 2017-08-22
      • 1970-01-01
      • 2019-01-07
      • 1970-01-01
      • 2014-03-12
      • 2013-05-23
      相关资源
      最近更新 更多