dubbo 注册多个zookeeper

作为消费端需要同时连接两个dubbo服务(一个是业务相关,一个是权限相关),他们注册在不同的zookeeper服务器上。
解决方法:通过指定id 和 registry属性来实现连接不同的服务。
dubbo连接配置如下:
<dubbo:registry protocol="zookeeper" address="192.168.1.2:2181"  id="permission" file="${dubbo.registry.cache}"
                    client="curator" timeout="${dubbo.timeout}" />
                   
      <dubbo:registry protocol="zookeeper" address="127.0.0.1:2181" id="default" file="${dubbo.registry.cache}"
                    client="curator" timeout="${dubbo.timeout}"/>
  <dubbo:consumer timeout="${dubbo.timeout}" retries="0" check="false" loadbalance="random"/>

consumer配置:
<?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:context="http://www.springframework.org/schema/context" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">


    <dubbo:reference id="tradeFailureService" version="1.0.0" interface="xxx.TradeFailureService"  />
               
  <!-- 指定从id为'permission'的注册地址获取服务-->                 
    <dubbo:reference  id="userPermissionService" registry="permission"  interface="xxxx.UserPermissionService" />
                   
</beans>     

                  

猜你喜欢

转载自evanhuang125.iteye.com/blog/2258652