Feign集成Hystrix
Feign默认不启用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);}
降级类须要实现申明式客户端接口,在实现的形象办法中增加降级代码
降级类须要增加@Component
注解
Feign集成Hystrix,增加监控
1、增加actuator依赖
2、裸露hystrix.stream监控端点
3、查看监控日志
1、重启092、拜访http://localhost:3001/actuator
订单中增加Feign,调用商品和用户
1、增加依赖
* Feign* Hystrix* actuator
2、yml配置
* Feign.hystrix.enabled=true #开启hystrix* m.e.w.e.i=hystrix.stream #裸露监控数据
3、启动类注解
* @EnableFeignClients* @EnableCircuitBreaker
Turbine
聚合Hystrix监控数据
连贯多态服务器,抓取日志数据,进行聚合
交给仪表盘在同一个监控界面进行展示
搭建Turbine服务
1、增加Turbine、eureka client依赖
2、yml配置
- 聚合的服务id:order-service,aa,bb,cc(能够增加多个)
- 为聚合的监控数据命名:cluster-name=new String("defaule")
3、启动类增加注解@EnableTurbine
音讯服务器
分布式系统中广泛应用信息服务
音讯服务器:
- rebbitmq
- activemq
- rocketmq
- tubemq