记一次使用Dubbo踩的坑
错误信息:
Failed to check the status of the service
com.yaya.configuration.dubbo.service.RpcConfigurationService. No provider available for the service
com.yaya.configuration.dubbo.service.RpcConfigurationService from the url spring-
cloud://localhost:9090/org.apache.dubbo.registry.RegistryService?application=playlist-
service&dubbo=2.0.2&init=false&interface=com.yaya.configuration.dubbo.service.RpcConfigurationService&methods=getAreaConfig,getVersionUpdated,ge
tAllConfig,getChannelConfig&pid=8520&qos.enable=false®ister.ip=192.16
8.0.110&release=2.7.6&side=consumer&sticky=false×tamp=1595218876108
to the consumer 192.168.0.110 use dubbo version 2.7.6
要问错误缘由,便是我想通过一个消费者访问多个生产者,可是当我调用第二个生产者时,发现项目启动就报错
起初,查资料以为是第二个生产者是懒加载的原因,因此我在@Reference(check = false)加上了个check=false参数,然后项目顺利启动。
等我一调用ConfigurationService这个服务的接口时
"Failed to invoke the method getChannelConfig in the service
com.yaya.configuration.dubbo.service.RpcConfigurationService. No
provider available for the service
com.yaya.configuration.dubbo.service.RpcConfigurationService from
registry localhost:9090 on the consumer 192.168.0.110 using the dubbo
version 2.7.6. Please check if the providers have been started and
registered.",
emmm…
我就知道事情没那么简单,于是乎度娘。。。谷歌。。。找了一大堆论坛博客,然并卵
然后只能翻书找资料,皇天不负有心人原来是需要加上订阅服务,并且默认是“*”表示所有在注册中心所注册的生产者都能找到
原来是我写了服务订阅,并且只订阅了一个生产者
于是乎,我加上了另外一个服务的订阅,接下来又可以愉快了划水了,2333
果然是书到用时方恨少