本文为 Spring Cloud Alibaba 系列 的第二篇文章,系列文章持续更新,点此 查看更多
前言
在上一篇博文中,笔者使用 Nacos + Dubbo 实现了远程服务调用,文章请见 《Spring Cloud Alibaba——使用 Nacos + Dubbo 实现的远程服务调用》
实际上,由于网络或是其他各种原因,服务提供方可能无法被消费方访问,此时消费方便会抛出如下异常信息:
org.apache.dubbo.rpc.RpcException: No provider available from registry localhost:9090 for service com.shawearn.spring.cloud.alibaba.api.HelloService on consumer 192.168.1.113 use dubbo version 2.7.6, please check status of providers(disabled, not registered or in blacklist).
at org.apache.dubbo.registry.integration.RegistryDirectory.doList(RegistryDirectory.java:599) ~[dubbo-2.7.6.jar:2.7.6]
......
我们可以通过 try-catch
捕获