开发者社区 > 云原生 > 正文

在示例中 catch (SentinelRpcException ex) { System.out.

在示例中 catch (SentinelRpcException ex) { System.out.println("blocked"); }

没有捕获到SentinelRpcException ,而是打印出了异常信息

com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method sayHello in the service com.orange.service.DemoService. Tried 3 times of the providers [192.168.121.110:20880] (1/1) from the registry 127.0.0.1:8848 on the consumer 192.168.121.110 using the dubbo version 2.6.6. Last error is: Failed to invoke remote method: sayHello, provider: dubbo://192.168.121.110:20880/com.orange.service.DemoService?anyhost=true&application=exueyun-bussiness-sit-consumer&bean.name=com.orange.service.DemoService&category=providers&check=false&dubbo=2.0.2&generic=false&interface=com.orange.service.DemoService&methods=sayHello&pid=66416&protocol=dubbo&register.ip=192.168.121.110&remote.timestamp=1555470996198&side=consumer&timeout=60000&timestamp=1555471008919, cause: com.alibaba.csp.sentinel.slots.block.SentinelRpcException: com.alibaba.csp.sentinel.slots.block.flow.FlowException com.alibaba.csp.sentinel.slots.block.SentinelRpcException: com.alibaba.csp.sentinel.slots.block.flow.FlowException Caused by: com.alibaba.csp.sentinel.slots.block.flow.FlowException

这是怎么回事

原提问者GitHub用户CjqDy

展开
收起
码字王 2023-05-19 18:52:50 150 0
1 条回答
写回答
取消 提交回答
  • 这个地方有一个workaround,可以参考一下BlockException.isBlockException的实现,往下找cause,并且比较cause里的detailMessage里是否contains SentinelRpcException,就可以了。

    原回答者GitHub用户elvislou

    2023-05-19 21:28:02
    赞同 展开评论 打赏
问答分类:
问答地址:

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载