В Apache Camel 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");
}
}
}