springcloud学习第四天

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监控数据
连接多台服务器 抓取日志数据 进行聚合
交给仪表盘在同一个监控界面进行监控

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值