So what if requests keep coming for the service which experiences the circuit-break?
1. Throw an error – It is not recommended
2. Return a fallback default response
3. Save previous responses (cache) and use when possible
We need fallback mechanism
Implementing Fallback with Hystrix
@HystrixCommand(fallbackMethod = "getUserDetailsFallback") public UserDetails getUserDetails() { return restTemplate.getForObject("http://user-details-service/userdetails/" + 1, UserDetails.class); } public UserDetails getUserDetailsFallback() { return new UserDetails();; }
Accessing values in Java code from property files.
@Value("$(api.key)") private String apiKey;