Dubbo之多协议、多注册中心、多版本。

多协议

可以自行扩展协议。

不同服务不同协议

比如,不同服务在性能上适用不同协议进行传输,比如大数据用短连接协议,小数据大并发用长连接协议。

<dubbo:application name=“world” />
<dubbo:registry id=“registry” address=“10.20.141.150:9090” username=“admin” password=“hello1234” />

<dubbo:protocol name=“dubbo” port=“20880” />
<dubbo:protocol name=“rmi” port=“1099” />

<dubbo:service interface=“com.alibaba.hello.api.HelloService” version=“1.0.0” ref=“helloService” protocol=“dubbo” />

<dubbo:service interface=“com.alibaba.hello.api.DemoService” version=“1.0.0” ref=“demoService” protocol=“rmi” />

多协议暴露服务

比如:需要与http客户端互操作。

<dubbo:application name=“world” />
<dubbo:registry id=“registry” address=“10.20.141.150:9090” username=“admin” password=“hello1234” />

<dubbo:protocol name=“dubbo” port=“20880” />
<dubbo:protocol name=“hessian” port=“8080” />

<dubbo:service interface=“com.alibaba.hello.api.HelloService” version=“1.0.0” id=“helloService” protocol=“dubbo,hessian” />

多注册中心

可以自行扩展注册中心。

多注册中心注册

比如:中文站有些服务来不及在青岛部署,只在杭州部署,而青岛的其他应用需要引用此服务,就可以将服务同时注册到两个注册中心。

<dubbo:application name=“world” />

<dubbo:registry id=“hangzhouRegistry” address=“10.20.141.150:9090” />
<dubbo:registry id=“qingdaoRegistry” address=“10.20.141.151:9010” default=“false” />

<dubbo:service interface=“com.alibaba.hello.api.HelloService” version=“1.0.0” ref=“helloService” registry=“hangzhouRegistry,qinghaiRegistry” />

不同服务使用不同注册中心

比如:CRM需同时调用中文站和国际站的PC2服务,PC2在中文站和国际站均有部署,接口及版本号都一样,但连的数据库不一样。

<dubbo:application name=“world” />

<dubbo:registry id=“chinaRegistry” address=“10.20.141.150:9090” />
<dubbo:registry id=“intlRegistry” address=“10.20.154.177:9010” default=“false” />

<dubbo:service interface=“com.alibaba.hello.api.HelloService” version=“1.0.0” ref=“helloService” registry=“chinaRegistry” />

<dubbo:service interface=“com.alibaba.hello.api.HelloService” version=“1.0.0” ref=“demoService” registry=“intlRegistry” />

多注册中心引用

比如:CRM需同时调用中心站和国际站的PC2服务,PC2在中文站和国际站均有部署,接口及版本号都一样,但连的数据库不一样。

<dubbo:application name=“world” />

<dubbo:registry id=“chinaRegistry” address=“10.20.141.150:9090” />
<dubbo:registry id=“intlRegistry” address=“10.20.154.177:9010” default=“false” />

<dubbo:reference interface=“com.alibaba.hello.api.HelloService” version=“1.0.0” id=“helloService” registry=“chinaRegistry” />

<dubbo:service interface=“com.alibaba.hello.api.HelloService” version=“1.0.0” id=“demoService” registry=“intlRegistry” />

如果只是测试环境临时需要连接两个不同注册中心,使用竖号分隔多个不同注册中心地址:

<dubbo:application name=“world” />

<dubbo:registry address=“10.20.141.150:9090|10.20.154.177:9010” />

<dubbo:reference id=“helloService” interface=“com.alibaba.hello.api.HelloService” version=“1.0.0” />

多版本

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

  • 在低压力时间段,先升级一半提供者为新版本
  • 再将所有消费者升级为新版本
  • 然后将剩下的一半提供者升级为新版本

<dubbo:service interface=“com.foo.BarService” version=“1.0.0” />
<dubbo:service interface=“com.foo.BarService” version=“2.0.0” />
<dubbo:reference id=“barService” interface=“com.foo.BarService” version=“1.0.0” />
<dubbo:reference id=“barService” interface=“com.foo.BarService” version=“2.0.0” />

不区分版本:(2.2.0以上版本支持)

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值