The HystrixCommandAspect
bean is declared in the HystrixCircuitBreakerConfiguration
class but I would like to use my own custom implementation of HystrixCommandAspect
and inject a different bean.
Application:
@SpringBootApplication
@EnableAspectJAutoProxy
@EnableCircuitBreaker
@Import(HystrixConfiguration.class)
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
Configuration:
@Configuration
public class HystrixConfiguration {
@Bean
@Primary
public HystrixCommandAspect hystrixCommandAspect(){
return new com.hystrix.HystrixCommandAspect();
}
}
Custom HystrixCommandAspect:
package com.hystrix;
@Aspect
public class HystrixCommandAspect extends com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect {
...
}
However, when I use the annotation @EnableCircuitBreaker
it uses the HystrixCircuitBreakerConfiguration
and doesn't even load my own @Bean
definition.
I upgraded spring to the latest release and this fixed the problem. I also noticed in the logs that it said it was overriding the bean provided in HystrixCircuitBreakerConfiguration
.