dubbo中的group与version

group

当一个接口有多种实现时,可以用group区分

<!-- dubbo group 使用示例 -->
<bean id="demoA" class="com.xxx.IndexServiceImpl1" />
<dubbo:service group="feedback" interface="com.xxx.IndexService" ref="demoA" />

<bean id="demoB" class="com.xxx.IndexServiceImpl2" />
<dubbo:service group="member" interface="com.xxx.IndexService" ref="demoB" />

此外,dubbo消费者也可以设置为:消费任意一个group的服务。

<dubbo:reference id="barService" interface="com.foo.BarService" group="*" />

version

当一个接口的实现,出现不兼容升级时,可以用版本号过渡,版本号不同的服务相互间不引用

<!-- 机器A提供1.0.0版本服务 -->
<dubbo:service interface="com.foo.BarService" version="1.0.0" />
<!-- 机器B提供2.0.0版本服务 -->
<dubbo:service interface="com.foo.BarService" version="2.0.0" />
<!-- 机器C消费1.0.0版本服务 -->
<dubbo:reference id="barService" interface="com.foo.BarService" version="1.0.0" />
<!-- 机器D消费2.0.0版本服务 -->
<dubbo:reference id="barService" interface="com.foo.BarService" version="2.0.0" />

此外,消费者消费服任意版本的服务时:

<dubbo:reference id="barService" interface="com.foo.BarService" version="*" />

另外 
接口升级时,要注意方法: 
* 在低压力时间段,先升级一半的提供者为新版本; 
* 再将所有的消费者升级为新版本; 
* 然后将剩下的一半提供者升级为新版本;

https://blog.csdn.net/silencecarrot/article/details/66981333

猜你喜欢

转载自my.oschina.net/u/3705388/blog/1797021
今日推荐