In my spring boot application I use multiple feign clients (@FeignClient("hello-service")). In the case of many of them, I need a mechanism of circuit breaker, so I have following line to the configuration.
feign.hystrix.enabled=true
However I'don't know how I can configure specific feign client not to use Hystrix. Is it possible? Has anyone managed to configure the spring applications in this way?
You can create you own configuration with disabled hystrix functionality, and use it for necessary clients.
public class FeignClientConfiguration {
@Bean
@Scope("prototype")
public Feign.Builder feignBuilder() {
return Feign.builder();
}
}
See details in paragraph 7.4
I'd like to extend Roman's answer as I didn't get how to use it at the beginning.
As he mentioned you need to have a configuration class like this
public class MyFeignConfiguration {
@Bean
@Scope("prototype")
public Feign.Builder feignBuilder() {
return Feign.builder();
}
}
And you need to include this configuration class to your @FeignClient, like this
@FeignClient(name = "name", url = "http://example.com", configuration = MyFeignConfiguration .class)
public interface MyApi {
//...
}
With this configuration this client will be built without being wrapped with Hystrix
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With