问题
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?
回答1:
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
回答2:
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
来源:https://stackoverflow.com/questions/55200113/how-to-disable-hystrix-in-one-of-multiple-feign-clients