zoukankan      html  css  js  c++  java
  • Dubbo的三种连接方式

    1、采用zookeeper作为注册中心

    <?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/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
    <!-- 声明应用名称 -->
        <dubbo:application name="platform-service"  organization="test"/>
    <!--注册中心为zk -->
        <dubbo:registry protocol="zookeeper" address="zk.test.com:2181"  file="./.dubbo-platform"/>
    <!--把服务暴露在dubbo的21884端口-->
        <dubbo:protocol name="dubbo" port="21884" serialization="hessian2" />
        <dubbo:protocol name="rest" port="8888"/>
    </beans>

    2,无注册中心,采用直连的方式

      <dubbo:registry protocol="zookeeper" address="N/A"  file="./.dubbo-platform"/>

    直连的方式使用时,消费者引用的url要配置成本地

    <dubbo:reference id="userService" url="dubbo://127.0.0.1:21884" interface="com.test.platform.api.UserService" check="true"/>

    3,通过广播的方式

    <dubbo:registry address="multicast://xxx.5x.x.x:1234?unicast=false" />

    注意组播地址段: 224.0.0.0 - 239.255.255.255

  • 相关阅读:
    java字符串的遍历以及字符串中各类字符的统计
    Java Jvm运行机制原理
    为什么面试要问 hashmap 的原理
    HashMap的实现原理
    redis两种持久化方式的优缺点
    2018No-java面试知识
    从架构演进的角度聊聊spring cloud都做了些什么?
    MySQL索引优化
    2018java面试知识汇总
    多线程—7种同步方法
  • 原文地址:https://www.cnblogs.com/minixiong/p/10168712.html
Copyright © 2011-2022 走看看