InterviewSolution
| 1. |
What is Hystrix? |
|
Answer» HYSTRIX is Netflix implementation for CIRCUIT breaker pattern, that ALSO employs bulkhead design pattern by operating each circuit breaker within its own thread pool. It also collects many useful metrics about the circuit breaker’s internal state, including -
All these metrics can be aggregated using another Netflix OSS project called Turbine. Hystrix dashboard can be used to VISUALIZE these aggregated metrics, providing excellent visibility into the overall health of the distributed system. 1) Enable Circuit Breaker in main application @EnableCircuitBreaker @RestController @SpringBootApplication public class ReadingApplication { ... }2) Using HystrixCommand fallback method execution @HystrixCommand(fallbackMethod = "reliable") public String readingList() { URI uri = URI.create("http://localhost:8090/recommended"); return this.restTemplate.getForObject(uri, String.class); } public String reliable() { 2 return "Cached recommended response"; }
|
|