我想用混乱的猴子来攻击我的微服务,我想用hystrix来处理失败。当我单独使用混沌猴子时,我的应用程序会受到攻击,但是当我将hystrix与它一起使用时,混沌猴子就不会进行任何攻击。
为什么我不能同时使用两者?是版本问题吗?
@SpringBootApplication
@EnableCircuitBreaker
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
@RestController
public class Controller {
@Autowired
private Service service;
@RequestMapping("/list")
public List<String> getList() {
return service.getList();
}
}
@Service
public class Service {
@Autowired
private Repo repo;
@HystrixCommand(fallbackMethod = "reliable")
public List<String> getList() {
return repo.getList();
}
public List<String> reliable() {
return Arrays.asList("ONE", "TWO", "THREE");
}
}
@Repository
public class Repo {
public List<String> getList() {
return Arrays.asList("Java", "PHP", "C++");
}
}
Application.properties
spring.profiles.active=chaos-monkey
chaos.monkey.enabled=true
chaos.monkey.watcher.controller=false
chaos.monkey.watcher.restController=false
chaos.monkey.watcher.service=true
chaos.monkey.watcher.repository=false
chaos.monkey.assaults.latencyActive=false
chaos.monkey.assaults.exceptions-active=true