You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2、增加了统一异常处理
`@Component
public class MyBlockExceptionHandler implements BlockExceptionHandler {
private static final Logger log = LoggerFactory.getLogger(MyBlockExceptionHandler.class);
@Override
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse response, BlockException e) throws Exception {
log.info("=====MyBlockExceptionHandler=====");
Result r = null;
if (e instanceof FlowException) {
r = Result.error(100, "限流了");
} else if (e instanceof DegradeException) {
r = Result.error(101, "降级了");
} else if (e instanceof ParamFlowException) {
r = Result.error(102, "热点参数限流了");
} else if (e instanceof SystemBlockException) {
r = Result.error(103, "触发系统保护机制了");
} else if (e instanceof AuthorityException) {
r = Result.error(104, "授权规则不通过");
}
//返回json数据
response.setStatus(500);
response.setCharacterEncoding("utf-8");
response.setContentType("application/json;charset=utf-8");
new ObjectMapper().writeValue(response.getWriter(), r);
}
}`
3、测试查看实时监控,发现确实按照规则QPS通过了2,但是降级处理一直没有走
按照异常统一处理逻辑,应该返回"触发系统保护机制了",但是接口一直正常返回,请问会是什么原因导致?
The text was updated successfully, but these errors were encountered:
1、配置了系统规则
2、增加了统一异常处理
`@Component
public class MyBlockExceptionHandler implements BlockExceptionHandler {
private static final Logger log = LoggerFactory.getLogger(MyBlockExceptionHandler.class);
}`
3、测试查看实时监控,发现确实按照规则QPS通过了2,但是降级处理一直没有走
按照异常统一处理逻辑,应该返回"触发系统保护机制了",但是接口一直正常返回,请问会是什么原因导致?
The text was updated successfully, but these errors were encountered: