liveBook · Manning

Resilience4j

As explained in Microservices Patterns, Second Edition

Resilience4j is a Java library that provides fault-tolerance mechanisms such as circuit breakers, retries, rate limiters, and time limiters.

Resilience4j applies fault-tolerance patterns to synchronous service calls, helping limit downstream failures and latency so callers can protect their SLOs. section 8.2.4

Choose mechanisms according to the failure or load risk:

  • Use bulkheads, rate limiters, and time limiters to constrain outstanding calls, call frequency, and wait time. section 8.2.4
  • Use retries, circuit breakers, caches, and fallbacks to respond to failures; fallbacks can return default or cached data. section 8.2.4

Annotating a client proxy

In Spring Boot, Resilience4j annotations on a client proxy method let Spring AOP wrap calls with circuit-breaker, time-limiter, and retry behavior. The example supplies a fallback that returns false. section 8.2.4

Figure 8.7 A circuit breaker implements a state machine. Initially it is in the closed state, which allows requests. But if there are too many errors, it transitions to the open state, which fails requests. After a timeout period, it then transitions to a half-open state, which allows a test request to be made. If the test request succeeds, the circuit breaker transitions to the closed state, otherwise it goes back to the open state.
circuit breaker behavior

The diagram shows a circuit breaker moving from closed to open after repeated errors, then testing recovery in half-open state. section 8.2.4

How Microservices Patterns, Second Edition covers it

How deep it goes
Describes several resilience mechanisms, circuit-breaker states, and annotated integration, without showing configuration.
Examples
Uses an API Gateway calling an Order Service, a delivery-information fallback, and an annotated authorization client.
What you can do after
Apply it via Spring Boot annotations to wrap client proxy calls with resilience logic.
How it connects
Connects circuit breakers and fallbacks with retries, bulkheads, caches, rate limiters, and time limiters.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.