I'm testing Spring Cloud circuit breaker and I'm missing the point of how actually "circuitBreaker.requestVolumeThreshold" parameter actually works...See my example...
@HystrixCommand(
fallbackMethod = "invokeMicroServiceFallback",
commandProperties = {
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds",
value = "30000"),
@HystrixProperty(name = "circuitBreaker.requestVolumeThreshold",
value = "2"),
@HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds",
value = "500"),
@HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds",
value = "180000")
},
threadPoolProperties = {
@HystrixProperty(name = "coreSize", value = "30"),
@HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds",
value = "180000")
})
public void invokeMicroService() {
final RestTemplate restTemplate = new RestTemplate();
final ServiceInstance serviceInstance = loadBalancer.choose("personsService");
if (serviceInstance != null) {
System.out.println("Invoking instance at URL: "+serviceInstance.getUri());
System.out.println("Result :"+
restTemplate.getForObject(serviceInstance.getUri()+"/persons",
String.class));
} else {
System.out.println("Service is down...");
throw new IllegalStateException("PersonsService is not running!");
}
}
public void invokeMicroServiceFallback() {
System.out.println("Waiting for circuit-breaker to close again...");
}
If I turn the personsService down and invoke invokeMicroService in the loop then I've got a lot of output like:
First:
Invoking instance at URL: <URL at my service>;
"Waiting for circuit-breaker to close again..."
then after some time, just repeated:
Service is down...
"Waiting for circuit-breaker to close again..."
what circuitBreaker.requestVolumeThreshold actually does here? Why I have more than two attempts of trying to access personsService?
thanks in advance...