How to correctly handle “FeignException$ServiceUnavailableException” with fallback and without deprecated @EnableCircuitbreaker annotation

Ended up using resilience4j for spring cloud. Next to feign.circuitbreaker.enabled=true in which sets up a circuitbreaker with a default config.

One can add a custom configuration like this:

public class FeignConfiguration {
    public Customizer<Resilience4JCircuitBreakerFactory> circuitBreakerFactoryCustomizer() {
        CircuitBreakerConfig circuitBreakerConfig =
        return circuitBreakerFactory -> circuitBreakerFactory
                .configure(builder -> builder.circuitBreakerConfig(circuitBreakerConfig),

Also, the resilience4j dependency needs to be in place, here a maven pom.xml is used.

    <!-- .. --> 

That way you can replace the deprecated hystrix implementation and remove the @EnableCircuitBreaker annotation. In case you want a more fine-grained setup, here are is a discussion how to implement fallback with resilience4j via default methods.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top