分布式服务框架 Dubbo 入门(一)

有话想说

之前的博文,每每写到一个新的东西都会在最前头写上 xx 是啥?今天想换一种方式,今天先不说 Dubbo 是啥?因为这玩意一时半会儿写不明白,也有可能是博主愚昧,看了半天官方文档也没能理解这到底是干嘛的一个玩意儿阿。直到跟着官方给出的 Demo 程序写出第一个 Dubbo 应用(没错,是 Hello World 程序),后来又有幸和使用过 Dubbo 的同事讨论了一下 Dubbo 才云消雾散。
所以这次我们先不去看那些概念了,先实现一个应用(不要小瞧 Hello World)

思考

首先一起思考一个问题,如何把应用从单机扩展到分布式?不妨先自己思考几分钟后再去利用搜索引擎。

HelloWorld 程序

不知道大家对于生产消费模型熟不熟悉,消息队列(RabbitMQ、Apache ActiveMQ 等)的架构就是这样的。接着我们要实现的这个 Demo 也可以类比这种模型去理解,我们写一个 Server 作为服务提供者(Provider),写一个Client 作为服务消费者(Consumer)通过 Dubbo 来调用 Server 上提供的一个服务。

0. 使用 Maven 构建 Provider

  • pom.xml
    采用 Spring 加载 Dubbo 的配置的方式,所以依赖了 Spring 和 Dubbo,需要注意的是在构建消费者程序时同样依赖 Spring 和 Dubbo
<dependency>
    <groupId>com.alibabagroupId>
    <artifactId>dubboartifactId>
    <version>2.6.2version>
dependency>

<dependency>
    <groupId>org.springframeworkgroupId>
    <artifactId>spring-contextartifactId>
    <version>5.0.7.RELEASEversion>
dependency>

1. 定义服务提供者的服务接口

  • com.xiaoping.dubbotest.HelloService.java
public interface HelloService {
    String sayHello(String name);
}

2. 服务接口的实现类

  • com.xiaoping.dubbotest.HelloServiceImpl.java
public class HelloServiceImpl implements HelloService {
    Logger logger = LoggerFactory.getLogger(HelloServiceImpl.class);
    public String sayHello(String name) {
        logger.info("From Provider" + name);
        return "Hello " + name;
    }
}

3. 服务提供者的配置文件

  • application.xml
    这里的配置文件是直接放在 resources 根目录下的。

<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="demo-provider"/>
    
    <dubbo:registry address="multicast://224.5.6.7:1234"/>
    
    <dubbo:protocol name="dubbo" port="20880"/>
    
    <dubbo:service interface="com.xiaoping.dubbotest.HelloService" ref="helloService"/>
    
    <bean id="helloService" class="com.xiaoping.dubbotest.HelloServiceImpl"/>
beans>

4. 服务提供者的入口程序

  • ProviderApp.java
public class ProviderApp {
    public static void main(String[] args) throws IOException {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                new String[] {"application.xml"});
        context.start();
        System.in.read(); // press any key to exit
    }
}

5. 消费者程序的配置文件

  • application.xml

<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="demo-consumer"/>
    
    <dubbo:registry address="multicast://224.5.6.7:1234"/>
    
    <dubbo:reference id="helloService" interface="com.xiaoping.dubbotest.HelloService"/>
beans>

6. 消费者的入口程序

  • Consumer.java
public class Consumer {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                new String[]{"application.xml"});
        context.start();
        // obtain proxy object for remote invocation
        HelloService helloService = (HelloService) context.getBean("helloService"); 
        // 注: 这里的 HelloService 可以是依赖自 Provider 中的接口,也可以是一个和他一样的副本
        String hello = helloService.sayHello("world"); // execute remote invocation
        System.out.println(hello); // show the result
    }
}

7. 先启动 ProviderApp,再启动 Consumer

Consumer 输出:

725, 2018 9:51:39 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@13a5fe33: startup date [Wed Jul 25 21:51:39 CST 2018]; root of context hierarchy
725, 2018 9:51:39 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [application.xml]
725, 2018 9:51:39 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息: using logger: com.alibaba.dubbo.common.logger.jcl.JclLoggerAdapter
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by javassist.ClassPool (file:/Users/xiaop1ng/apache-maven-3.5.3/repo/org/javassist/javassist/3.20.0-GA/javassist-3.20.0-GA.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of javassist.ClassPool
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Register: consumer://192.168.2.184/com.xiaoping.dubbotest.HelloService?application=demo-consumer&category=consumers&check=false&dubbo=2.6.2&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1039&side=consumer×tamp=1532526700351, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Send broadcast message: register consumer://192.168.2.184/com.xiaoping.dubbotest.HelloService?application=demo-consumer&category=consumers&check=false&dubbo=2.6.2&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1039&side=consumer×tamp=1532526700351 to /224.5.6.7:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Receive multicast message: register consumer://192.168.2.184/com.xiaoping.dubbotest.HelloService?application=demo-consumer&category=consumers&check=false&dubbo=2.6.2&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1039&side=consumer×tamp=1532526700351 from /192.168.2.184:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Subscribe: consumer://192.168.2.184/com.xiaoping.dubbotest.HelloService?application=demo-consumer&category=providers,configurators,routers&dubbo=2.6.2&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1039&side=consumer×tamp=1532526700351, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Send broadcast message: subscribe consumer://192.168.2.184/com.xiaoping.dubbotest.HelloService?application=demo-consumer&category=providers,configurators,routers&dubbo=2.6.2&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1039&side=consumer×tamp=1532526700351 to /224.5.6.7:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Receive multicast message: subscribe consumer://192.168.2.184/com.xiaoping.dubbotest.HelloService?application=demo-consumer&category=providers,configurators,routers&dubbo=2.6.2&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1039&side=consumer×tamp=1532526700351 from /192.168.2.184:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Receive multicast message: register dubbo://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590 from /192.168.2.184:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Notify urls for subscribe url consumer://192.168.2.184/com.xiaoping.dubbotest.HelloService?application=demo-consumer&category=providers,configurators,routers&dubbo=2.6.2&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1039&side=consumer×tamp=1532526700351, urls: [dubbo://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590], dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Successed connect to server /192.168.2.184:20880 from NettyClient 192.168.2.184 using dubbo version 2.6.2, channel is NettyChannel [channel=[id: 0x6911f93f, /192.168.2.184:50565 => /192.168.2.184:20880]], dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Start NettyClient bogon/192.168.2.184 connect to the server /192.168.2.184:20880, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Notify urls for subscribe url consumer://192.168.2.184/com.xiaoping.dubbotest.HelloService?application=demo-consumer&category=providers,configurators,routers&dubbo=2.6.2&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1039&side=consumer×tamp=1532526700351, urls: [dubbo://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590], dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Refer dubbo service com.xiaoping.dubbotest.HelloService from url multicast://224.5.6.7:1234/com.alibaba.dubbo.registry.RegistryService?anyhost=true&application=demo-consumer&check=false&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1039®ister.ip=192.168.2.184&remote.timestamp=1532526254590&side=consumer×tamp=1532526700351, dubbo version: 2.6.2, current host: 192.168.2.184
Hello world

ProviderApp 输出:

725, 2018 9:44:13 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@13a5fe33: startup date [Wed Jul 25 21:44:13 CST 2018]; root of context hierarchy
725, 2018 9:44:13 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [application.xml]
725, 2018 9:44:13 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息: using logger: com.alibaba.dubbo.common.logger.jcl.JclLoggerAdapter
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by javassist.ClassPool (file:/Users/xiaop1ng/apache-maven-3.5.3/repo/org/javassist/javassist/3.20.0-GA/javassist-3.20.0-GA.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of javassist.ClassPool
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
725, 2018 9:44:14 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] The service ready on spring started. service: com.xiaoping.dubbotest.HelloService, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:44:14 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Export dubbo service com.xiaoping.dubbotest.HelloService to local registry, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:44:14 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Export dubbo service com.xiaoping.dubbotest.HelloService to url dubbo://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&bind.ip=192.168.2.184&bind.port=20880&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:44:14 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Register dubbo service com.xiaoping.dubbotest.HelloService url dubbo://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&bind.ip=192.168.2.184&bind.port=20880&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590 to registry registry://224.5.6.7:1234/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&dubbo=2.6.2&pid=1027®istry=multicast×tamp=1532526254536, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:44:15 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Start NettyServer bind /0.0.0.0:20880, export /192.168.2.184:20880, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:44:15 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Register: dubbo://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:44:15 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Send broadcast message: register dubbo://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590 to /224.5.6.7:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:44:15 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Receive multicast message: register dubbo://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590 from /192.168.2.184:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:44:15 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Subscribe: provider://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&category=configurators&check=false&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:44:15 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Send broadcast message: subscribe provider://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&category=configurators&check=false&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590 to /224.5.6.7:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:44:15 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Receive multicast message: subscribe provider://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&category=configurators&check=false&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590 from /192.168.2.184:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:44:16 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger warn
警告:  [DUBBO] Ignore empty notify urls for subscribe url provider://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&category=configurators&check=false&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Receive multicast message: register consumer://192.168.2.184/com.xiaoping.dubbotest.HelloService?application=demo-consumer&category=consumers&check=false&dubbo=2.6.2&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1039&side=consumer×tamp=1532526700351 from /192.168.2.184:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Receive multicast message: subscribe consumer://192.168.2.184/com.xiaoping.dubbotest.HelloService?application=demo-consumer&category=providers,configurators,routers&dubbo=2.6.2&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1039&side=consumer×tamp=1532526700351 from /192.168.2.184:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Send broadcast message: register dubbo://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590 to /224.5.6.7:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Receive multicast message: register dubbo://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&dubbo=2.6.2&generic=false&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590 from /192.168.2.184:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] From Providerworld, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Receive multicast message: unregister consumer://192.168.2.184/com.xiaoping.dubbotest.HelloService?application=demo-consumer&category=consumers&check=false&dubbo=2.6.2&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1039&side=consumer×tamp=1532526700351 from /192.168.2.184:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Receive multicast message: unregister consumer://192.168.2.184/com.xiaoping.dubbotest.HelloService?application=demo-consumer&category=providers,configurators,routers&dubbo=2.6.2&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1039&side=consumer×tamp=1532526700351 from /192.168.2.184:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] Receive multicast message: unsubscribe consumer://192.168.2.184/com.xiaoping.dubbotest.HelloService?application=demo-consumer&category=providers,configurators,routers&dubbo=2.6.2&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1039&side=consumer×tamp=1532526700351 from /192.168.2.184:1234, dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger warn
警告:  [DUBBO] All clients has discontected from /192.168.2.184:20880. You can graceful shutdown now., dubbo version: 2.6.2, current host: 192.168.2.184
725, 2018 9:51:40 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info
信息:  [DUBBO] disconnected from /192.168.2.184:50565,url:dubbo://192.168.2.184:20880/com.xiaoping.dubbotest.HelloService?anyhost=true&application=demo-provider&bind.ip=192.168.2.184&bind.port=20880&channel.readonly.sent=true&codec=dubbo&dubbo=2.6.2&generic=false&heartbeat=60000&interface=com.xiaoping.dubbotest.HelloService&methods=sayHello&pid=1027&side=provider×tamp=1532526254590, dubbo version: 2.6.2, current host: 192.168.2.184

写在后头

在跑通了 Demo 程序之后我们来看一下 Dubbo 的架构

分布式服务框架 Dubbo 入门(一)_第1张图片

Provider 暴露服务的服务提供方
Consumer 调用远程服务的服务消费方
Registry 服务注册与发现的注册中心
Monitor 统计服务的调用次数和调用时间的监控中心
Container 服务运行容器

现在来看这张架构图应该清晰一些,ProviderConsumer 使用接口作为服务的契约,通过注册中心 Registry 来完成服务的注册和发现,远程通讯的细节通过代理类来屏蔽。

了解更多

  • 官方文档

  • Dubbo 用户手册

  • Dubbo 开发手册

  • Dubbo 管理手册

你可能感兴趣的:(JavaEE)