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

要求完成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调用超时时间

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容