【Bug】同一接口多实现类下dubbo调用服务错乱

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/quan20111992/article/details/87869103

有两个项目A、B,各自有一定数量实现了CommonService接口的实现类,而当将这些实现类配置成dubbo服务供彼此消费时,会出现实际消费的服务并不符合预期
A项目提供两个服务并消费三个服务

<dubbo:service interface=“com.xxx.CommonService” ref=“receiveService” />
<dubbo:service interface=“com.xxx.CommonService” ref=“sendService” />
<dubbo:reference id=“asyncService” interface=“com.xxx.CommonService” />
<dubbo:reference id=“syncService” interface=“com.xxx.CommonService” />
<dubbo:reference id=“analysisService” interface=“com.xxx.CommonService” />

B项目提供三个服务并消费两个服务

<dubbo:reference interface=“com.xxx.CommonService” id=“receiveService” />
<dubbo:reference interface=“com.xxx.CommonService” id=“sendService” />
<dubbo:service ref=“asyncService” interface=“com.xxx.CommonService” />
<dubbo:service ref=“syncService” interface=“com.xxx.CommonService” />
<dubbo:service ref=“analysisService” interface=“com.xxx.CommonService” />

当在A项目中消费asyncService服务时发现实际调用的是analysisService在这里插入图片描述
针对每个服务提供者一个分组,以实现区分同一接口的不同实现类

A项目修改后的配置如下:

<dubbo:service interface=“com.xxx.CommonService” ref=“sendService”  group="sendService"/>
<dubbo:reference id=“asyncService” interface=“com.xxx.CommonService” group="asyncService"/>

B项目修改后的配置如下:

<dubbo:reference interface=“com.xxx.CommonService” id=“sendService” group="sendService"/>
<dubbo:service ref=“asyncService” interface=“com.xxx.CommonService” group="asyncService"/>

在调试过程中发现在dubbo控制台只能找到服务的提供者却看不到该服务的消费者

猜你喜欢

转载自blog.csdn.net/quan20111992/article/details/87869103
今日推荐