JAVA全系列 教程
3762个小节阅读:7092.4k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
sentinel是一个面向云原生微服务的流量控制、熔断组件。通过sentinel控制台进行新增、修改设置流控、熔断规则,保证系统高可用。
xxxxxxxxxx
java -jar .\sentinel-dashboard-1.8.2.jar --server.port=8078
执行上面的命令,启动sentinel-dashboard-1.8.2.jar,启动后的主界面:
在nacos中持久化配置
进入编辑配置页面
详细配置如下
xxxxxxxxxx
[
{
"resource":"checkVerifyCode",
"limitApp":"default",
"grade":1,
"count":1,
"strategy":0,
"controlBehavior":0,
"clusterMode":false
},{
"resource":"/erp/medicines/updateMedicines",
"limitApp":"default",
"grade":1,
"count":1,
"strategy":0,
"controlBehavior":0,
"clusterMode":false
}
]
修改MedicinesController,在要流控的方法上添加sentinel注解
xxxxxxxxxx
/**
* 修改
*/
@PutMapping("updateMedicines")
@Log(title = "修改药品信息",businessType = BusinessType.UPDATE)
@SentinelResource(value = "/erp/medicines/updateMedicines",blockHandlerClass = BaseController.class, blockHandler = "handleUpdate")
public AjaxResult updateMedicines(@Validated MedicinesDto medicinesDto) {
medicinesDto.setSimpleUser(ShiroSecurityUtils.getCurrentSimpleUser());
return AjaxResult.toAjax(this.medicinesService.updateMedicines(medicinesDto));
}
效果演示
连续发送修改药品请求/erp/medicines/updateMedicines,返回结果提示:Blocked by Sentinel (flow limiting)