provider端怎么处理dubbo.cloud.subscribed-services
springCloudAlibaba+dubbo+nacos环境下,重启服务提供者或先启动服务消费者后启动服务提供者的情况下,消费者有时候会出现找不到服务的问题及解决方案(In the spring cloud Alibaba + Dubbo + Nacos environment, when the service provider is restarted or the service consumer is started first and then the service provider, sometimes the consumer can not find the service when calling) · Issue #1805 · alibaba/spring-cloud-alibaba · GitHub
在使用 dubbo 进行服务间调用
服务如果不指定 dubbo.cloud.subscribed-services ,默认会去订阅注册中心所有服务。
即:会因其他订阅的服务无法正常启动,导致服务连接超时,无法正常启动,无法正常连接nacos。
以下日志可以确定,不指定服务的话,会默认订阅许多无关的服务
[2022-03-14 14:40:03:255] [main] [WARN ] [c.a.c.d.m.r.DubboServiceMetadataRepository] The Spring application[name : consumers:com.xxx.app.cart.api.CartServiceApi::] does not expose The REST metadata in the Dubbo services.
[2022-03-14 14:40:03:270] [main] [WARN ] [c.a.c.d.m.r.DubboServiceMetadataRepository] The Spring application[name : consumers:com.xxx.app.main.api.delivery.DeliveryServiceApi::] does not expose The REST metadata in the Dubbo services.
[2022-03-14 14:40:03:286] [main] [WARN ] [c.a.c.d.m.r.DubboServiceMetadataRepository] The Spring application[name : consumers:com.xxx.app.main.api.goldcard.PayMemberPayPackageServiceApi::] does not expose The REST metadata in the Dubbo services.
[2022-03-14 14:40:03:301] [main] [WARN ] [c.a.c.d.m.r.DubboServiceMetadataRepository] The Spring application[name : consumers:com.xxx.app.main.api.member.AddressServiceApi::] does not expose The REST metadata in the Dubbo services.
[2022-03-14 14:40:03:323] [main] [WARN ] [c.a.c.d.m.r.DubboServiceMetadataRepository] The Spring application[name : consumers:com.xxx.app.main.api.member.DictServiceApi::] does not expose The REST metadata in the Dubbo services.
[2022-03-14 14:40:03:339] [main] [WARN ] [c.a.c.d.m.r.DubboServiceMetadataRepository] The Spring application[name : consumers:com.xxx.app.main.api.member.StoreHomeServiceApi::] does not expose The REST metadata in the Dubbo services.
[2022-03-14 14:40:03:359] [main] [WARN ] [c.a.c.d.m.r.DubboServiceMetadataRepository] The Spring application[name : consumers:com.xxx.app.main.api.member.UserInfoServiceApi::] does not expose The REST metadata in the Dubbo services.
[2022-03-14 14:40:03:372] [main] [WARN ] [c.a.c.d.m.r.DubboServiceMetadataRepository] The Spring application[name : consumers:com.xxx.app.sku.api.hd.HdGoodIdServiceApi::] does not expose The REST metadata in the Dubbo services.
[2022-03-14 14:40:03:383] [main] [WARN ] [c.a.c.d.m.r.DubboServiceMetadataRepository] The Spring application[name : consumers:com.xxx.app.sku.api.hotSell.HotSellServiceApi::] does not expose The REST metadata in the Dubbo services.
[2022-03-14 14:40:03:393] [main] [WARN ] [c.a.c.d.m.r.DubboServiceMetadataRepository] The Spring application[name : consumers:com.xxx.app.sku.api.newPeople.NewPeopleServiceApi::] does not expose The REST metadata in the Dubbo services.
其实出现这么多 WARN 级别的日志应该引起重视了。
最终发现是有某个服务出问题,导致连接超时了
org.apache.dubbo.remoting.RemotingException:client(urL:dubbo://10.130.24.33:20881/com.xxx.app.skU.api.sku.SkuServiceApi?
由于 网关服务 只是依赖某个特定的服务,所以通过配置
dubbo.cloud.subscribed-services="xxx-app-main-service"
即可解决问题! SpringBoot 使用 dubbo 进行服务间调用可参考:https://blog.csdn.net/mikelv01/article/details/121858934
|