Hystrix is one of the recommendable library when it comes to design Latency and Fault tolerance distributed system. It handles cascading failure, supports greaceful degradation.
1. When circuit trips, for duration set as execution.isolation.thread.timeoutInMilliseconds, it stops the command invocation.
2. When Fallback method is declared, client will never get any or original exception. Unless fallback is also throwing exception.
3. If fallback is throwing exception, clint will receive the original exception.As the fallback invocation takes place in some other interal command managed by the library.
4. When circuit opens then fallback will again be invoked. But client will never get exception as long fallback is not throwing error.
5. The original exception is still recieved by the client when circuit trips in open state.
6. Minimum number of requests in a rolling window that will trip the circuit :circuitBreaker.requestVolumeThreshold . For example, if the value is 20, then if only 19 requests are received in the rolling window (say a window of 10 seconds) the circuit
will not trip open even if all 19 failed.
7. Maximum thread-pool size:hystrix.threadpool.HystrixThreadPoolKey.maximumSize. This is the maximum amount of concurrency that can be
supported without starting to reject HystrixCommands. Setting only takes effect allowMaximumSizeToDivergeFromCoreSize is set.
8. Force the circuit breaker into an open (tripped) state in which it will reject all requests: circuitBreaker.forceOpen.

hystrix.threadpool.<HystrixThreadPoolKey>.allowMaximumSizeToDivergeFromCoreSize=true
//allows the configuration for maximumSize to take effect
hystrix.threadpool.<HystrixThreadPoolKey>.coreSize=10 //default vaue
hystrix.threadpool.<HystrixThreadPoolKey>.maximumSize=10 // default value
@Servicepublic class HelloService { private final RestTemplate restTemplate; private static int i =0; public HelloService(RestTemplateBuilder restTemplateBuilder) { this.restTemplate = restTemplateBuilder.build(); } @HystrixCommand(commandKey = "GreetCommand",groupKey="GreetKey", threadPoolKey="Greet", fallbackMethod = "greetFallback", commandProperties = { @HystrixProperty(name="execution.isolation.thread.timeoutInMilliseconds" ,value ="110"),@HystrixProperty( name="execution.isolation.thread.interruptOnTimeout",value="false"),
@HystrixProperty(name="circuitBreaker.forceOpen",value="false")},
threadPoolProperties = { @HystrixProperty(name = "coreSize", value = "30"), @HystrixProperty(name = "maxQueueSize", value = "101"), @HystrixProperty(name = "keepAliveTimeMinutes", value = "2"), @HystrixProperty(name = "metrics.rollingStats.numBuckets", value = "12"), @HystrixProperty(name = "queueSizeRejectionThreshold", value = "15"), @HystrixProperty(name="metrics.rollingStats.timeInMilliseconds",value="1440") }) public String greet(String name) throws SQLDataException { throw new RuntimeException("This command always fails."); /* String test= restTemplate.getForEntity( "http://localhost:1511/greet?greet=Hello&name={name}",String.class,name).getBody(); System.out.println("========================"); */ // return test; } private String greetFallback(String name, Throwable th)throws SQLDataException { System.out.println(" ===" + th.getMessage()); i++; if (i >15 ) // throw new SQLDataException("si dummy sql exception"); } return "Sorry " + name + ". Service is currently unavailable."; } //Client call: @RestControllerpublic class HelloResource { private final HelloService service; public HelloResource(HelloService service) { this.service = service; } static Logger LOGGER = LoggerFactory.getLogger(HelloResource.class); @GetMapping("/hello") public String greet(@RequestParam String name) { try { return service.greet(name); } catch (Exception e) { LOGGER.error("client received error in controller :" + e.getMessage()); LOGGER.error("Error cause :" + e.getCause()); } return null; } } Output: ===this command always fails ............................... ===this command always fails c.n.h.c.javanica.command.GenericCommand : failed to processed fallback is the method: 'greetFallback'. HelloResource : client received error in controller :this command always fails com.thetechiehouse.client.web.HelloResource : Error cause :null ===Hystrix circuit short-circuited and is OPEN javanica.command.GenericCommand:failed to processed fallback is the method: 'greetFallback'. HelloResource : client received error in controller :this command always fails HelloResource : Error cause :null Dependencies: <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> </dependency <dependency <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId> </dependency>
More:https://github.com/Netflix/Hystrix https://github.com/Netflix/Hystrix/wiki/Configuration com/netflix/hystrix/contrib/javanica/conf/HystrixPropertiesManager.java