当前位置:网站首页>Sentinel link mode rule not working
Sentinel link mode rule not working
2022-08-05 16:48:00 【There is no way out of sailing against the current】
前言
如何使用SentinelLink flow control rules?
How to solve the link mode rule does not take effect?
解决方案
Version information for the current project
SpringBoot 版本2.3.2.RELEASE
spring-cloud版本Hoxton.SR8
spring-cloud-alibaba版本2.2.5.RELEASE
- 引入依赖
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-web-servlet</artifactId>
</dependency>
- 关闭sentinel的过滤器(If not set or not closed,Duplicate statistics problems occur)
spring:
cloud:
sentinel:
filter:
enabled: false
- Add context filter
import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class FilterContextConfig {
@Bean
public FilterRegistrationBean sentinelFilterRegistration() {
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
registrationBean.setFilter(new CommonFilter());
registrationBean.addUrlPatterns("/*");
registrationBean.addInitParameter(CommonFilter.WEB_CONTEXT_UNIFY, "false");
registrationBean.setName("sentinelFilter");
registrationBean.setOrder(1);
return registrationBean;
}
}
编写测试代码

启动服务器,Ask for the two interfaces edited above,查看sentinel-dashboard控制台,Two links are shown

Write link rules,并保存
The following figure represents the link/hello1对findByIdAccess to this resource is per second1次.
请求/hello1这个接口,频繁刷新,会出现失败.while frequently requesting/hello2This link will not fail.



问题
如果不关闭sentinelwhat happens to the filter?
发送一次请求,sentinelTwo requests will be counted.
So please be careful to closesentinel过滤器
边栏推荐
- 【计算讲谈社】第七讲|AI 的价值探索:如何拓展商业边界?
- 阿里百万级Redis小册震撼开源,打开源码新世界
- 详解 SSL(一):网址栏的小绿锁有什么意义?
- 如何用MATLAB对CSI数据进行预处理(卡尔曼滤波篇)
- 8.lnmp架构
- 解决FileZilla 报错“无法和 SFTP 服务器建立 FTP 连接,请选择合适的协议”
- 一个案例搞懂工厂模式和单例模式
- 面向动态图的极低时延 GNN 在线推理采样服务
- Registered less than a week for data security in the British parliament TikTok dispute the substance is discontinued
- ![CDATA[]]和转义字符讲解
猜你喜欢
随机推荐
WPF 截图控件之移除控件(九)「仿微信」
Stream流详解
Redis Series 5: In-depth Analysis of Cluster Cluster Mode
二叉树结点查找
聊聊苹果的M2芯片
[Case] Animation of a bear running
consul安装
华为设备配置Smart Link主备备份
电脑重装系统桌面图标变成白色文件怎么恢复?
接口测试关联讲解
2018-10-14 21点20分
分布式深度学习最佳入门(踩坑)指南
纽约金价反弹 广州黄金产品热销
跨越“S型曲线”,华胜天成如何在数字时代开启第二曲线?
Explain the difference between Oracle DELETE and TRUNCATE
机器人强化学习——COCOI: Contact-aware Online Context Inference for Generalizable Non-planar Pushing(21 ICRA)
基于eureka-server的服务注册与消费案例
企业如何进行企业文档管理?提供3种新思路
Visual Studio Code如何新建一个工程
Fourier transform








