0
点赞
收藏
分享

微信扫一扫

五 sentinel 集成 gateway

参考文档:https://github.com/alibaba/Sentinel/wiki/%E7%BD%91%E5%85%B3%E9%99%90%E6%B5%81

在第四章 的 gateway、 nacosa 的基础上,完成两者的适配。

(1)gateway pom.xml文件

(2) gateway 新建 GatewayConfiguration 类

GatewayConfiguration 

(3)在GatewayConfiguration 中配置限流控制

流量控制

(4)连接 控制台

gateway

(5)至于 -Dcsp.sentinel.app.type=1 ,在gateway 项目 启动的时候 需要加上去。用于标记 使用gateway 进行 网关控制。

(6)nacosa  新加pom.xml依赖

nacosa  pom

(7)nacosa  新加properties配置

nacosa  properties

(8)在 nacosa 项目 新加 TestNacosaController,helloWorld 加上 注解SentinelResource

TestNacosaController

(11)分别启动 nacosa 和gateway,在sentinel 控制台 看到

sentinel 控制台

nacos 服务台 看到

nacos 服务台

(11)访问http://localhost:9000/nacosa/test/helloWorld看到

访问

http://localhost:9000/nacosa/test/helloWorld2也出现这个

说明,在gateway 中配置,限流是对 整个 nacosa 生效的

(12)在刚刚的controller 里面,给 helloWorld 方法加了 @SentinelResource 注解,在 sentinel 控制台 nacosa 项目 里加入流程控

sentinel 

(13)再次访问http://localhost:9000/nacosa/test/helloWorld出现这个,说明 整个项目的流控与单个流控 是相互生效的

request

项目地址:https://github.com/renzheyizhe/demo(nacosa、gateway)

举报

相关推荐

0 条评论