转:sentinel设置blockHandlerClass和blockHandler不生效的坑
问题描述:
使用@SentinelResource进行限流
@SentinelResource(value = "mobile/getPreliminarySwitch" ,blockHandler = "switchHandleException", blockHandlerClass = {SentinelHandleException.class}) @GetMapping("/getPreliminarySwitch") public AjaxResult getPreliminarySwitch(){ if("true".equals(mobileService.getSwitch("finalsSwitch","000002"))){ return new AjaxResult(0,"success"); }else{ return new AjaxResult(-1,"初赛尚未开启,敬请期待"); } }
sentinel 进行nacos持久化,设置的是 @GetMapping("/getPreliminarySwitch"),方法名称进行限流的
解决 使用了 @SentinelResource(value = "mobile/getPreliminarySwitch")的value配置,资源名称应该是mobile/getPreliminarySwitch,
标签:blockHandler,AjaxResult,SentinelResource,getPreliminarySwitch,blockHandlerClass, From: https://www.cnblogs.com/nextgg/p/17263059.html