dubbo 参数杂谈

1. 统一注册中心的隔离:dubbo

1). dubbo 可以通过register group 进行zk 空间隔离, register 隔离是物理隔离, 也就是在zk 上的节点隔离, 不在的情况下默认是在dubbo 节点下面。
2). 服务提供和服务发现的 service group 和 reference group 进行隔离,这主要用于区分同一个接口的不同实现。

注 : 在dubbo中,group, version, interface是服务的匹配条件,也只有这三个参数来决定是不是同一个服务,其他的配置均为调优和治理参数。
对于dubbo service的分组一般是针对, 一个接口有多个实现类的时候使用的, 也可以有其他的业务划分使用。

  • 服务提供和服务发现 使用案例:
<dubbo:service group="feedback" interface="com.zzf.IndexService" />
<dubbo:reference id="feedbackIndexService" group="feedback" interface="com.zzf.IndexService" />


2. 注册协议和服务暴露协议

<dubbo:registry id="registry" address="localhost:2181" username="admin" password="admin" protocol="zookeeper"/>
<!-- 多协议配置 -->
<dubbo:protocol name="dubbo" port="20880" />
<dubbo:protocol name="rmi" port="1099" />
<dubbo:protocol name="hessian" port="8080" />

<!-- 使用dubbo协议暴露服务 -->
<dubbo:service interface="com.zzf.api.HelloService" version="1.0.0" ref="helloService" protocol="dubbo" />
<!-- 使用rmi协议暴露服务 -->
<dubbo:service interface="com.zzf.api.DemoService" version="1.0.0" ref="demoService" protocol="rmi" />

<!-- 使用dubbo、hessian 两个协议暴露 -->
<dubbo:service id="helloService" interface="com.alibaba.hello.api.HelloService" version="1.0.0" protocol="dubbo,hessian" />

解释:

3. 服务和注册中心问题

  • 多注册中心注册
<!-- 多注册中心配置 -->
<dubbo:registry id="hangzhouRegistry" address="192.1681.1:9090" />
<dubbo:registry id="qingdaoRegistry" address="192.168.1.2:9091" default="false" />

<!-- 向多个注册中心注册 -->
<dubbo:service interface="com.zzf.api.HelloService" version="1.0.0" ref="helloService" registry="hangzhouRegistry,qingdaoRegistry" />
  • 不同服务使用不同注册中心
<!-- 多注册中心配置 -->
<dubbo:registry id="hangzhouRegistry" address="192.1681.1:9090" />
<dubbo:registry id="qingdaoRegistry" address="192.168.1.2:9091" default="false" />
<!-- 注册到杭州注册中心 -->
<dubbo:service interface="com.alibaba.hello.api.HelloService" version="1.0.0" ref="helloService" registry="hangzhouRegistry" />
<!-- 注册到青岛注册中心 -->
<dubbo:service interface="com.alibaba.hello.api.DemoService" version="1.0.0" ref="demoService" registry="qingdaoRegistry" />


  • 多版本
    一个接口实现,出现不兼容升级时,可以用版本号过渡,版本号不同的服务相互间不引用。
<dubbo:service interface="com.zzf.api.HelloService" version="1.0.0" />
<dubbo:service interface="com.zzf.api.HelloService" version="2.0.0" />

<dubbo:reference id="helloService" interface="com.zzf.api.HelloService" version="1.0.0" />
<dubbo:reference id="helloService" interface="com.zzf.api.HelloService" version="2.0.0" />

不区分版本:(dubbo 2.2.0以上版本支持)
<dubbo:reference id="helloService" interface="com.zzf.api.HelloService" version="*" />
  • 分组聚合
    从2.1.0版本开始支持, 具体图示:
    这里写图片描述

具体的案例, 可以看里面的:
https://github.com/apache/incubator-dubbo/tree/master/dubbo-test/dubbo-test-examples

配置信息:

<!-- 搜索所有分组, 并且指明合并 -->
<dubbo:reference interface="com.zzf.MenuService" group="*" merger="true" />

<!-- 合并指定分组, 并且合并-->
<dubbo:reference interface="com.zzf.MenuService" group="aaa,bbb" merger="true" />

未完
成。。。。。待续。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值