一:注册中心

1.场景

  Dubbo 支持同一服务向多注册中心同时注册,

  或者不同服务分别注册到不同的注册中心上去,

  甚至可以同时引用注册在不同注册中心上的同名服务。

2.多注册中心注册

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

 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
     xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://code.alibabatech.com/schema/dubbohttp://code.alibabatech.com/schema/dubbo/dubbo.xsd">
     <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,qingdaoRegistry" />
 </beans>

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

  CRM 有些服务是专门为国际站设计的,有些服务是专门为中文站设计的。

 <beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
     xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://code.alibabatech.com/schema/dubbohttp://code.alibabatech.com/schema/dubbo/dubbo.xsd">
     <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.DemoService" version="1.0.0" ref="demoService" registry="intlRegistry" />
 </beans>

4.多注册中心引用

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

 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
     xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://code.alibabatech.com/schema/dubbohttp://code.alibabatech.com/schema/dubbo/dubbo.xsd">
     <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 id="chinaHelloService" interface="com.alibaba.hello.api.HelloService" version="1.0.0" registry="chinaRegistry" />
     <!-- 引用国际站站服务 -->
     <dubbo:reference id="intlHelloService" interface="com.alibaba.hello.api.HelloService" version="1.0.0" registry="intlRegistry" />
 </beans>

二:服务分组

1.场景

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

2.服务

  这里的ref属性没写。如果写上ref就可以表明每个组里有哪些实现了。

  <dubbo:service group="feedback" interface="com.xxx.IndexService" />
  <dubbo:service group="member" interface="com.xxx.IndexService" />

3.引用

  <dubbo:reference id="feedbackIndexService" group="feedback" interface="com.xxx.IndexService" />
  <dubbo:reference id="memberIndexService" group="member" interface="com.xxx.IndewxService" />任意组:  <dubbo:reference id="barService" interface="com.foo.BarService" group="*" />

Dubbo中多注册中心问题与服务分组的更多相关文章

  1. 【DUBBO】zookeeper在dubbo中作为注册中心的原理结构

    [一]原理图 [二]原理图解释 流程:1.服务提供者启动时向/dubbo/com.foo.BarService/providers目录下写入URL2.服务消费者启动时订阅/dubbo/com.foo. ...

  2. dubbo与zk注册中心如何对接,如何做到服务自动发现

    先看下consumer端发起调用时的链路流程: +---------------------------+ +---------------------------+ +--------------- ...

  3. dubbo支持的注册中心

    dubbo支持的注册中心 Dubbo提供的注册中心有如下几种类型可供选择: Multicast注册中心 Zookeeper注册中心 Redis注册中心 Simple注册中心 ZooKeeper是一个开 ...

  4. SpringCloud Alibaba实战(7:nacos注册中心管理微服务)

    源码地址:https://gitee.com/fighter3/eshop-project.git 持续更新中-- 在上一节我们已经完成了Nacos Server的本地部署,这一节我们学习如何将Nac ...

  5. 【Java】Web 服务编程技巧与窍门: 在 UDDI 注册中心为 Web 服务注册开发 UDDI Java 应用程序

    本技巧建立了一个使用统一描述.发现和集成 (Universal Description, Discovery, and Integration,UDDI) 来注册应用程序级消费的 Web 服务实例.作 ...

  6. 80%面试官不知道的dubbo → 【redis注册中心】

    dubbo的redis注册中心配置和注意事项 配置provider和consumer项目的pom.xml,增加如下2个依赖: org.apache.commons commons-pool2 2.4. ...

  7. springCloud中的注册中心Nacos

    springCloud中的注册中心Nacos 三个模块: 1.注册中心 2.服务提供者(生产者) 提供服务 3.服务消费者(消费者)调用服务 流程:消费者和生产者都要向注册中心注册,注册的是二者中服务 ...

  8. Dubbo多注册中心和Zookeeper服务的迁移

    一.Dubbo多注册中心 1. 应用场景 例如阿里有些服务来不及在青岛部署,只在杭州部署,而青岛的其它应用需要引用此服务,就可以将服务同时注册到两个注册中心. consumer.xml <?xm ...

  9. dubbo服务端,dubbo客户端,注册中心(zk)之间的心跳

    dubbo客户端和dubbo服务端之间存在心跳,由dubbo客户端主动发起,可参见dubbo源码 HeartbeatTask. dubbo服务端和注册中心(zk)存在心跳,由dubbo服务端发起,这是 ...

随机推荐

  1. vue-router 实践

    1. vue-router2学习实践笔记 2. router.push() 3. 使用vue-router跳转页面

  2. [Luogu 3275] SCOI2011 糖果

    [Luogu 3275] SCOI2011 糖果 第一道差分约束.感谢 AZe. 我的理解是根据一些不等关系建一个图,在图上边跑一个最长路(有时候是最短路). 因为可能存在负环,所以必须用 SPFA! ...

  3. Redis实战(三)CentOS 7上Redis主从复制

    一主二从架构 1.一主二从架构图 2.通过命令 mkdir redisCluster创建redis集群文件夹 3.通过命令mkdir 6380   mkdir 6381   mkdir 6382在re ...

  4. Could not parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location

    spring-boot项目,生产环境运行一段时间后,上传图片报错,如下: threw exception [Request processing failed; nested exception is ...

  5. .net WebService 大数据量时性能的提高

    1.直接返回DataSet对象 [WebMethod(Description = "直接返回DataSet对象")] public DataSet GetUserListDateS ...

  6. 【CodeForces】600 E. Lomsat gelral (dsu on tree)

    [题目]E. Lomsat gelral [题意]给定n个点的树,1为根,每个点有一种颜色ci,一种颜色占领一棵子树当且仅当子树内没有颜色的出现次数超过它,求n个答案——每棵子树的占领颜色的编号和Σc ...

  7. Is It A Tree? 挂着并查集的帽子招摇撞骗

    Description A tree is a well-known data structure that is either empty (null, void, nothing) or is a ...

  8. SQL Server 将Id相同的字段合并,并且以逗号隔开

    例如:有表MO_Cook,字段:FoodRoom,name   有如下数据: 要求:将FoodRoom中值相同的字段合并成一行,并将name的值用逗号隔开. 需要用到:STUFF函数. 查询语句如下: ...

  9. hdu 1716 排列2(DFS搜索)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1716 排列2 Time Limit: 1000/1000 MS (Java/Others)    Me ...

  10. win10+anaconda虚拟环境python3.6+cuda9.0+cudnn7+pytorch0.4.1

    anaconda下jupyter notebook的打开目录的修改:参考:https://www.cnblogs.com/amberdata/p/7907845.html pytorch官网:http ...