Microservices – Fallback

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;

Author: Mahesh

Technical Lead with 10 plus years of experience in developing web applications using Java/J2EE and web technologies. Strong in design and integration problem solving skills. Ability to learn, unlearn and relearn with strong written and verbal communications.