stumped
stumped

Reputation: 489

Hystrix: cannot trip circuit breaker

Assuming i use the default Hystrix configurations:

CircuitBreakerRequestVolumeThreshold=20    
CircuitBreakerErrorThresholdPercentage=50    
MetricsRollingStatisticalWindowInMilliseconds=10000ms 

I assume this means that within a 10 sec window, the circuit will break if there are 10 handled exceptions within 20 consecutive requests.
I have a class called MyCommand which extends HystrixCommand. I create 20 objects of it and call execute on each sequentially. But I don't seem to trip the circuit because it never goes into my getFallback method. I expected the 20th execute to trip the circuit. Where am i going wrong?

int i=0;    
    public MyObject run() throws Exception {    
        i++;    
        try {    
            throw new Exception("Handled exception "+i);    
        } catch (Exception e) {    
            System.out.print("Catch "+i);    
        }    
        return null;    
    }

Upvotes: 1

Views: 704

Answers (1)

Davin
Davin

Reputation: 243

If you handle the exceptions within the command then the circuit breaker will not open. In your run method do not catch the exception.

Upvotes: 1

Related Questions