SpringBoot + SpringCloud + Feign + Sentinel 集成实现接口限流监控-Demo

SpringBoot + SpringCloud + Feign + Sentinel 集成实现接口限流监控

SpringBoot版本:1.5.13.RELEASE

SpringCloud版本:Edgware.SR4

Sentinel详情介绍版本:0.1.2.RELEASE 是集成了spring-cloud-alibaba

注册中心-eureka

服务提供-producer

服务消费-consumer

Sentinel Dashbord

Demo使用说明:

  1. Dashboard启动:
    java -Dserver.port=8080 -jar sentinel-dashboard.jar
    官网参考
  2. 启动erueka --> 启动Producer --> 启动Consumer
  3. 展示图片:
    [外链图片转存失败(img-nHZ3Jf9h-1564655959756)(https://github.com/Xlinlin/SpringCloud-Demo/blob/master/SpringCloud-Sentinel/img/sentinel-dashbord-producer.png)]
    [外链图片转存失败(img-HTUtBRua-1564655959762)(https://github.com/Xlinlin/SpringCloud-Demo/blob/master/SpringCloud-Sentinel/img/sentinel-dashbord-consumer.png)]

简要配置说明:

  1. dashboard启动后,客户端接入:
     properties配置:
     # Sentinel dashbord 数据交互端口,注意单机多服务部署端口冲突
     spring.cloud.sentinel.transport.port=8729
     # sentinel  dashbord地址
     spring.cloud.sentinel.transport.dashboard=192.168.206.212:8880
     
     pom文件引入(自动引入相关依赖包):
     <dependency>
         <groupId>org.springframework.cloud</groupId>
         <artifactId>spring-cloud-alibaba-sentinel</artifactId>
         <version>0.1.2.RELEASE</version>
     </dependency>
    
    
  2. producer和consumer使用sentinel仅引入 上一步中的pom文件即可
  3. feign的支持:
     pom引入:
     <dependency>
         <groupId>org.springframework.cloud</groupId>
         <artifactId>spring-cloud-starter-openfeign</artifactId>
         <version>1.4.7.RELEASE</version>
     </dependency>
    
     开启sentinel支持
     # 使用阿里 sentinel监控
     feign.sentinel.enabled=true
    
    

重要提示:

  1. Sentinel版本要与springboot和springcloud大版本一致,否则会出现不可预见的异常
  2. 接入到dashbord后,要请求下url,然后稍等等个1分钟左右才能到控制台,不要着急

Github地址

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值