目录
官网文档 https://dromara.org/zh/projects/soul/sentinel-plugin/
sentinel 插件是网关用来对流量进行限流与熔断的可选选择之一。
1.启动
在网关的 pom.xml 文件中添加 sentinel的支持。
<!-- soul sentinel plugin start-->
<dependency>
<groupId>org.dromara</groupId>
<artifactId>soul-spring-boot-starter-plugin-sentinel</artifactId>
<version>${project.version}</version>
</dependency>
<!-- soul sentinel plugin end-->
把 soul-admin、soul-bootstrap、soul-examples-http 启动:
2.开启 sentinel 插件
3.添加选择器和规则
添加选择器:
添加规则:
4.验证
通过 postman 连续点击调用接口 localhost:9195/http/order/findById?id=95,会报如下错误,429 Too Many Requests: