zoukankan      html  css  js  c++  java
  • dubbo的配置

    小结:不管提供方还是消费方,都有这个配置

    <!-- 消费方/提供方 应用名,用于计算依赖关系,不是匹配条件,不要与提供方/消费方一样 -->

    <dubbo:application name="checkstand" />



    <!-- 使用zookeeper注册中心暴露发现服务地址 -->
    <dubbo:registry protocol="zookeeper" address="${zk_url}" />

    不同之处:提供方通过这个注解将服务注入到注册中心

    <dubbo:service interface="com.ai.checkstand.service.PayService"    ref="payService" retries="0" timeout="10000"/>
    而消费方通过下面这个注解将服务拿到:
    <dubbo:reference id="partnerService"    interface="com.ai.checkstand.mm.service.PartnerService" />


    提供方:provider.xml

    <?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.xsd        http://code.alibabatech.com/schema/dubbo        http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
    
        <dubbo:application name="checkstand-service" /> <!--服务名称,随便取  -->
    
        <dubbo:registry protocol="zookeeper" address="${zk_url}"   />  <!--服务方名字和地址,名字是指定 -->
    
        <dubbo:protocol name="dubbo" port="${pv_port}" />
    
        <!-- dubbo默认调用失败后会重试2次,超时默认是300毫秒,一旦超时就会重新调用 -->
        <dubbo:service interface="com.ai.checkstand.service.PayService"    ref="payService" retries="0" timeout="10000"/>
    
        <dubbo:service interface="com.ai.checkstand.service.BillService" ref="billService" retries="0" timeout="10000"/>
    
        <dubbo:service interface="com.ai.checkstand.service.LogService" ref="logService" retries="0" timeout="10000"/>
    
        <dubbo:service interface="com.ai.checkstand.service.InterfaceService" ref="interfaceService" retries="0" timeout="10000"/>
    
    </beans>

    消费方:consumer.xml

    <?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.xsd        http://code.alibabatech.com/schema/dubbo        http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
    
        <!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 -->
        <dubbo:application name="checkstand" />
        
        <!-- 使用zookeeper注册中心暴露发现服务地址 -->
        <dubbo:registry protocol="zookeeper" address="${zk_url}" />
    
        <!-- 生成远程服务代理,可以和本地bean一样使用demoService -->
        <!-- <dubbo:reference id="helloService"    interface="com.ai.checkstand.service.HelloService" /> -->
        
        <!-- <dubbo:reference id="userService"    interface="com.ai.checkstand.service.UserService" /> -->
        
        <dubbo:reference id="partnerService"    interface="com.ai.checkstand.mm.service.PartnerService" />
        
        <dubbo:reference id="payService"    interface="com.ai.checkstand.service.PayService" />
        
        <dubbo:reference id="billService"    interface="com.ai.checkstand.service.BillService" />
        
        <dubbo:reference id="logService"    interface="com.ai.checkstand.service.LogService" />
        
        <dubbo:reference id="mmPayService"    interface="com.ai.checkstand.mm.service.MMPayService" />
    
        <dubbo:reference id="interfaceService"    interface="com.ai.checkstand.service.InterfaceService" />
    
    </beans>
  • 相关阅读:
    String判空效率比较
    myeclipse数据库逆向hibernate教程
    博客使用说明和我的学习心得(技术路线和书单)
    【小记】go如何判断key是否在map中
    MySQL必知必会笔记——MySQL其他操作
    MySQL必知必会笔记——查询的进阶知识
    MySQL必知必会笔记——查询的基础知识
    MySQL必知必会笔记-Mysql基本操作
    Linux学习笔记:Linux命令之权限管理命令
    Linux学习笔记:用户与用户组
  • 原文地址:https://www.cnblogs.com/cherishforchen/p/10913234.html
Copyright © 2011-2022 走看看