项目场景:
Dubbo消费者注册失败
问题描述
一大早到公司,就收到运维的消息,服务器cpu飙升,看日志发下报如下错误:
Caused by: org.apache.dubbo.rpc.RpcException: Failed to invoke the method getAllCustomLogCrawlInfos in the service
com.oppo.moa.facade.service.CustomLogCrawlService. Tried 3 times of the providers [*] (2/2) from the registry *
on the consumer * using the dubbo version 2.7.3. Last error is: Failed to invoke remote method: *
Caused by: org.apache.dubbo.remoting.RemotingException: message can not send,
because channel is closed ....
原因分析:
先去百度,结果都是说2.7.1版本的bug,需要配置
dubbo.provider.dynamic=true
但是我的是2.7.3,已经不存在这个问题,并且看到配置中心有这个配置,对比代码如下
//public abstract class AbstractServiceConfig
-- dubbo-2.7.3
Whether to register as a dynamic service or not on register center, the value is true, the status will be enabled after the service registered,and it needs to be disabled manually; if you want to disable the service, you also need manual processing.
(baidu翻译:是否在注册中心注册为动态服务,值为true,服务注册后状态为启用,需要手动禁用;如果要禁用该服务,还需要手动处理。)
protected Boolean dynamic = true;
-- dubbo-2.7.1
Whether to register as a dynamic service or not on register center, it the value is false, the status will be disabled after the service registered,and it needs to be enabled manually; if you want to disable the service, you also need manual processing.
(baidu翻译:是否在注册中心注册为动态服务,如果值为false,则服务注册后状态为禁用,需要手动启用;如果要禁用该服务,还需要手动处理。)
protected Boolean dynamic = false;
消费者回滚也没效果,就分析是不是生产者有问题,结果发现生产者的配置中,6月份添加了分组配置:
dubbo.provider.group=prod
但是消费者没有添加这个配置,导致消费者一直是在无分组里面进行注册,一直无法注册服务。
解决方案:
无法注册的消费者也添加分组,然后重新部署服务即可
dubbo.provider.group=prod