微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

SpringCloud: Sentinel

 java -jar --add-exports=java.base/sun.net.util=ALL-UNNAMED .\sentinel-dashboard-1.8.4.jar --server.port=9090

注解支持 · alibaba/Sentinel Wiki · GitHub

introduction (sentinelguard.io)

Warm up: 冷启动

 

 

 

 

 

 

排队等待

 

 

 

 

 

 

关联:

 

 

 

 

 

 

 

 

 

 

 

 

 

 热点规则:

 

 

 

 

@RequestMapping(value = "exception")
  @SentinelResource(value = "resourceName", blockHandler = "blockHandler", fallback = "fallback")
  public String ex(Integer id, HttpServletRequest httpServletRequest){
    if(id % 2 == 1)
      throw new RuntimeException(String.format("%s is odd", id));
    return httpServletRequest.getRequestdispatcher("").toString();
  }

  public String blockHandler(Integer id, HttpServletRequest httpServletRequest, BlockException blockException){
    if(blockException instanceof FlowException){
      return "FlowException";
    }
    if(blockException instanceof DegradeException){
      return "DegradeException";
    }
    if(blockException instanceof ParamFlowException){
      return "ParamFlowException";
    }
    if(blockException instanceof SystemBlockException){
      return "SystemBlockException";
    }
    if(blockException instanceof AuthorityException){
      return "AuthorityException";
    }
    return "BlockException";
  }

  public String fallback(Integer id, HttpServletRequest httpServletRequest, Throwable throwable){
    return throwable.getMessage();
  }

  

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐