Summary
In this chapter, we saw Resilience4j and its circuit breaker, time limiter, and retry mechanism in action.
A microservice that has synchronous dependencies to other services can become unresponsive or even crash if these services stop responding as expected, especially under a high load. These types of error scenarios can be avoided by using a circuit breaker, which applies fail-fast logic and calls fallback methods when it is open. A circuit breaker can also make a microservice resilient by allowing requests when it is half-open to see whether the failing service is operating normally again and close the circuit if so. To support a circuit breaker in handling unresponsive services, a time limiter can be used to maximize the time a circuit breaker waits before it kicks in.
A retry mechanism can retry requests that randomly fail from time to time, for example, due to temporary network problems. It is very important to only apply retry requests on idempotent services...