簡體   English   中英

駱駝Hystrix EIP-IgnoreException防止調用回退

[英]Camel Hystrix EIP - IgnoreExceptions to prevent call to Fallback

在Apache駱駝Hystrix EIP中,如何防止由於錯誤的請求異常而調用回退方法。 我嘗試從請求調度程序處理器中拋出“ 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM