Feign and Hystrix

To create a resilient system, we have to implement reactive patterns, such as circuit-breaker patterns. The Feign client supports the circuit-breaker pattern by using Hystrix. We will discuss Hystrix and how we can write fallback methods in Chapter 10, Building Resilient Systems Using Hystrix and Turbine. Feign clients have direct support for fallbacks. If Hystrix is on the classpath and feign.hystrix.enabled=true, Feign will wrap all methods with a circuit-breaker. Returning com.netflix.hystrix.HystrixCommand is also available.

To implement the Feign client with Hystrix, just implement the interface with the fallback code, which will then be used when the actual call to the endpoint delivers an error.

Let's see the following ...

Get Mastering Spring Boot 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.