java - chaos-monkey 和 spring hystrix 不兼容?
问题描述
我想用 Chaos Monkey 攻击我的微服务,我想用 hystrix 来处理故障。当我单独使用 Chaos Monkey 时,我的应用程序会受到攻击,但是当我使用 hystrix 时,Chaos Monkey 不会进行任何攻击。
为什么我不能同时使用?是版本问题吗?
@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
解决方案
推荐阅读
- node.js - 当库有 index.d.ts 文件时,为什么我的应用程序代码会显示“找不到模块的声明文件...”?
- c# - 如何将插入符号添加到表单控件?
- c++ - 标量类型的初始化程序中的错误指示符
- c# - Windows 窗体测验跟踪单选按钮
- python - 如何使用“upsert”使用 SQLAlchemy 执行批量插入,因此现有密钥被忽略(或更新)并且不会使执行崩溃?
- python - 先前初始化的变量声称“未定义”
- flutter - 如何在不设置路由的情况下导航到新屏幕
- ios - 如何在 Swift 中显示这个 html 结构的 json 响应
- javascript - 将匹配重音字符并将 - 替换为 ' ' 的正则表达式
- python - 带有OOP的python中的KMeans实现?