My SpringBoot app has Hystrix enabled with fallback defined for some of the Feign clients and undefined for the rest them.
Now, I wanted to disable Hystrix for the ones that did not have a fallback defined as yet. So I followed the steps listed in [paragraph 7.4] https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-feign.html which is to create a separate Feign configuration with a vanilla Feign.Builder. However adding the new @Bean Feign.Builder disables my Hystrix functionality across all Feign clients which I don't want. If I remove the @Bean Feign.Builder, Hystrix fallback kicks in like usual in myhystrixclient. A similar SO question here How to disable hystrix in one of multiple feign clients is still open. What am I doing wrong?
public class MyFeignClientConfiguration {
@Bean
public FeignErrorDecoder feignErrorDecoder() {
return new FeignErrorDecoder();
}
@Bean
@Scope("prototype")
public Feign.Builder feignBuilder() {
return Feign.builder();
}
}
My Feign Client looks like below:
@FeignClient(name = "myregularclient", configuration = MyFeignClientConfiguration.class)
public interface MyRegularClient {
//my APIs here
}
My Hystrix Feign Configuration looks like the below:
public class MyFeignClientHystrixConfiguration {
@Bean
public FeignErrorDecoder feignErrorDecoder() {
return new FeignErrorDecoder();
}
}
And here is my Feign client where Hystrix fallback is implemented
@FeignClient(name = "myhystrixclient", configuration = MyFeignClientHystrixConfiguration.class, fallback = MyFallbackService.class)
public interface MyHystrixClient {
//my APIs here
}
UPDATE
Adding my Application.java for further review of the component scan aspects.
@ComponentScan(basePackages ="com.demo.xyz")
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class,
MetricFilterAutoConfiguration.class,
MetricRepositoryAutoConfiguration.class})
@EnableDiscoveryClient
@EnableFeignClients
@EnableCircuitBreaker
public class MyApplication {
/** Start the app **/
}