• 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>
  • 相关阅读:
    动态代理:JDK动态代理和CGLIB代理的区别
    关于国密算法 SM1,SM2,SM3,SM4 的笔记
    加密算法比较3DES AES RSA ECC MD5 SHA1等
    通过mybatis向数据库中插入日期数据
    mapreduce流程中的几个关键点
    MapReduce二次排序
    Hadoop自定义分组Group
    编译hadoop2.6.0
    ERROR [org.apache.hadoop.security.UserGroupInformation]
    Java集合分组
  • 原文地址:https://www.cnblogs.com/cherishforchen/p/10913234.html
Copyright © 2020-2023  润新知