feign 代替 hystrix+ribbon 是一种集成工具
默认不启用hystrix 不推荐启用hystrix
启用hystrix基础配置:
1.hystrix起步依赖
2.yml中配置启用hystrix
feign.hystrix.enabled=true
3.启动类添加注解@EnableCircuitBreaker
添加降级代码
@FeignClient(name = "item-service",fallback = 降级类.class)
public interface ItemClient {
@GetMapping("/{orderId}")
JsonResult<List<Item>> getItems(@PathVariable String orderId);
@PostMapping("/decreaseNumber")
JsonResult<?> decreaseNumber(@RequestBody List<Item> items);
}
降级类需要实现声明式客户端接口,在实现的抽象方法中添加降级代码,降级类需要添加@Componen t注解
Feign集成Hystrix,添加监控
1.添加actuator依赖
2.暴露hystrix.stream监控端点
3.查看监控日志
1.重启09
2.访问 http://localhost:3001/actuator/
订单添加feign,调用商品和用户
1.添加依赖
- List item
- feign
- hystrix
2.yml
Turbine
聚合Hystrix监控数据
连接多台服务器 抓取日志数据 进行聚合
交给仪表盘在同一个监控界面进行监控