2

In Apache camel Hystrix EIP, how can we prevent the call to fallback method for bad request exception. I tried throwing "HystrixBadRequestException" from my request dispatcher processor, but I still see that fallback is getting triggered. Is there any way to solve this problem?

 /* 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");
        }
    }
}
pushkin
  • 9,575
  • 15
  • 51
  • 95
user2857397
  • 61
  • 1
  • 1
  • 2

1 Answers1

1

This is currently not implemented in camel-hystrix. I have logged a ticket to get this added in upcoming releases: https://issues.apache.org/jira/browse/CAMEL-13066

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65