Sentinel
Sentinel copied to clipboard
这个熔断似乎并不生效,熔断时长无效。 浏览器一直刷新请求该接口,虽然可以跳到熔断方法内(但是设定的熔断时间为 70秒并没有生效,再次刷新,又重新正常返回。)
/**
* 获取当前用户信息
*/
//@InnerAuth
@GetMapping("/info/{username}")
@SentinelResource(value = "ruoyi-system", fallback = "selectUserByNameFallback")
public Object info(@PathVariable("username") String username)
{
int count = atomicInteger.getAndIncrement();//先取值,再递增
if (count %2 == 0) {
int x = 1/0;
}
//return userService.selectUserByName(username);
return "aaaaa";
}
// 服务流量控制处理,参数最后多一个 BlockException,其余与原函数一致。
public Object selectUserByNameBlockHandler(String username)
{
System.out.println("selectUserByNameBlockHandler异常信息");
return "{\"code\":\"500\",\"msg\": \"" + username + "服务流量控制处理\"}";
}
// 服务熔断降级处理,函数签名与原函数一致或加一个 Throwable 类型的参数
public Object selectUserByNameFallback(String username, Throwable throwable)
{
System.out.println("selectUserByNameFallback异常信息:" + throwable.getMessage());
return "{\"code\":\"500\",\"msg\": \"" + username + "服务熔断降级处理\"}";
}
我和的想法是一样的,目前没有解决
@1083 请问一下,你的熔断策略是,在 70 秒内异常请求数大于阈值触发熔断,还是 70 内慢调用的比例大于阈值触发熔断?是前者还是后者?