Sentinel在整合Dubbo的时候,如何在Provider端进行全局统一处理BlockException流控异常
@Component
public class CustomerUrlBlockHandler implements BlockExceptionHandler {
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, BlockException e) throws Exception {
String msg = "";
if (e instanceof FlowException) {
msg = "限流了,请稍后再试";
} else if (e instanceof DegradeException) {
msg = "降级了,请稍后再试";
} else if (e instanceof ParamFlowException) {
msg = "热点参数限流,请稍后再试";
} else if (e instanceof SystemBlockException) {
msg = "系统规则(负载、、...)不满足规则";
} else if (e instanceof AuthorityException) {
msg = "授权规则不通过";
}
response.setContentType("application/json;charset=UTF-8");
response.setStatus(500);
response.getWriter().print(JSONObject.toJSONString(msg));
}
}
该配置放在消费者端可以生效,但是在生产者端并不会生效,为啥呀?