美文网首页
通达科技机试题-dubbo服务发布

通达科技机试题-dubbo服务发布

作者: 告小辞 | 来源:发表于2018-02-28 23:03 被阅读0次

    要求完成demo,pub和sub

    1.配置需要发布的服务的Bean

    <beanid="service" class="com.eoncloud.HellowWorldServiceImpl"/>
    

    2.配置发布服务的应用名称

    <dubbo:application name="esf-manager"/>
    

    3.配置注册中心地址

    <dubbo:registryid="registry" address="zookeeper://10.6.14.16:2181" client="zkclient"/>
    

    id属性表示注册中心bean的ID
    address 表示zookeeper注册中心的地址
    client 配置zookeeper注册中心实现策略

    4.指定发布服务端口

    <dubbo:protocolname="dubbo" port="60001"/>
    

    5.发布服务

    <dubbo:serviceinterface="cn.eoncloud.HellowWorldService" 
    ref="service" 
    version="1.0.0" 
    timeout="500"/>
    

    interface 接口名
    ref 接口实例为Spring的bean对象
    version 指定当前服务版本
    timeout 配置响应超时

    服务订阅
    1.通过maven引入服务接口包

    <dependency>
        <groupId>pub-demon-export</groupId>
        <artifactId>pub-demon-export</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
    

    2.配置应用名

    <dubbo:applicationname="esf-web"/>
    

    3.配置注册中心地址

    <dubbo:registryaddress=" zookeeper://10.6.14.16:2181" client="zkclient"/>
    

    4.订阅并消费服务

    <dubbo:referenceid="appService"
    interface="cn.eoncloud.HellowWorldService" 
    version="1.0.0"
    timeout="500"/>
    

    id服务代理的bean的Id
    interface 接口名称
    version消费服务的版本
    timeout调用超时时间

    相关文章

      网友评论

          本文标题:通达科技机试题-dubbo服务发布

          本文链接:https://www.haomeiwen.com/subject/guzixftx.html