SpringCloud: sentinel热点参数限制

一、定义controller

复制代码
package cn.edu.tju.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HotParamController {
    @RequestMapping("/getHotParam/{id}")
    @SentinelResource(value = "getHotParam", blockHandler = "myBlockHandler")
    public String getHotParam(@PathVariable String id){
        return "get: " + id;
    }

    public String myBlockHandler(@PathVariable String id, BlockException ex){
        return "get: 热点数据";
    }
}

二、配置热点参数限制规则

然后编辑规则:

相关推荐
devilnumber18 分钟前
Oracle 与 MySQL substr 函数差异总结
java·数据库·mysql·oracle
cfm_291428 分钟前
线程池阻塞队列
java·开发语言
YOU OU36 分钟前
优雅实现远程调用-OpenFeign
spring cloud
坐吃山猪1 小时前
【多线程】ThreadPool线程池参数说明
java·网络
YOU OU1 小时前
Spring Cloud概述
后端·spring·spring cloud
evans在进步1 小时前
Java 常用设计模式(二):装饰器、适配器、责任链、模板方法、策略与观察者
java·开发语言·设计模式
jvmind_dev2 小时前
频繁 new JedisCluster 之后,对象池为什么回不去了?
java·后端
AKA__Zas2 小时前
文件 I/O(速通版
java·intellij-idea·学习方法
学长毕业设计2 小时前
基于SpringBoot的咖啡馆管理系统的设计与实现(源码+文档+讲解视频)
java·spring boot·后端
骇客野人2 小时前
SpringBoot业财一体化系统设计和落地实施方案
java·spring boot·后端