Dubbo入门详细

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hlw521hxq/article/details/85721952

Dubbo学习图纸

  • dubbo简介
  • dubbo能做什么?优点?
  • dubbo核心内容
  • 两种方式使用Dubbo:API和Spring配置
  • 应用场景:未来方向:扩展思路
  • 总结

dubbo简介


Dubbo是 阿里巴巴公司开源的一个高性能优秀的服务框架,使得应用可通过高性能的 RPC 实现服务的输出和输入功能,可以和Spring框架无缝集成。

Dubbo是一款高性能、轻量级的开源Java RPC框架,它提供了三大核心能力:面向接口的远程方法调用,智能容错和负载均衡,以及服务自动注册和发现。

dubbo能做什么?优点?

服务治理

优点:

  • 透明化的远程方法调用
    像调用本地方法一样调用远程方法;只需简单配置,没有任何API侵入。比如:手机可以让你远距离撩妹

  • 软负载均衡及容错机制
    可在内网替代nginx lvs等硬件负载均衡器。比如:你可以区分你撩妹是哪个妹子,不会有叫错名字的尴尬

  • 服务注册中心自动注册 & 配置管理
    不需要写死服务提供者地址,注册中心基于接口名自动查询提供者ip。
    使用类似zookeeper等分布式协调服务作为服务注册中心,可以将绝大部分项目配置移入zookeeper集群。比如:有的妹子离你而去,自动删除联系方式,有的来了,自动获取妹子信息

  • 服务接口监控与治理
    Dubbo-admin与Dubbo-monitor提供了完善的服务接口管理与监控功能,针对不同应用的不同接口,可以进行 多版本,多协议,多注册中心管理。比如:发现有的妹子爱答不理,可能是在生气,你需要哄哄,有的妹子太剽悍了,你要离远点,时刻关注,省的被妹子埋怨!

dubbo核心内容

参考百度:

核心部件

  • 网络通信框架,实现了 sync-over-async 和request-response 消息机制.
  • RPC: 一个远程过程调用的抽象,支持负载均衡容灾集群功能
  • Registry: 服务目录框架用于服务的注册和服务事件发布和订阅

工作原理

  • provider:服务提供者
  • Consumer:服务消费者
  • Register:服务注册中心
  • Monitor:服务监控中心,记录日志

特性

  • 连通性:注册中心提供目录服务,与生产者消费者是长连接,与监控中心并非长连接
  • 健壮性,注册中心挂了,消费者有缓存的服务地址,依旧可以消费服务
  • 伸缩性,可以多注册中心,主动发现新服务,推送新的服务提供给消费者

参考博客:https://www.jianshu.com/p/527e2944034c

两种方式使用Dubbo:API和Spring配置

API调用:

maven引入jar包:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.o2o.duboo</groupId>
    <artifactId>dubboDemo</artifactId>
    <version>1.0-SNAPSHOT</version>
        <dependencies>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo</artifactId>
                <version>2.6.1</version>
                <exclusions>
                    <exclusion>
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.javassist</groupId>
                <artifactId>javassist</artifactId>
                <version>3.20.0-GA</version>
            </dependency>
            <dependency>
                <groupId>io.netty</groupId>
                <artifactId>netty</artifactId>
                <version>3.6.10.Final</version>
            </dependency>
            <dependency>
                <groupId>org.apache.curator</groupId>
                <artifactId>curator-framework</artifactId>
                <version>2.9.1</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.7.22</version>
            </dependency>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>1.1.3</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>1.7.22</version>
            </dependency>
        </dependencies>


    </project>

service接口代码:

package dubbo.api;

public interface demoService {
    public String say();
}

serviceImpl实现接口方法:

package dubbo.api;

public class demoServiceImpl implements demoService{
    public String say() {
        System.out.println("hello,world!");
        return "haha";
    }
}

生产者代码:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.o2o.duboo</groupId>
    <artifactId>dubboDemo</artifactId>
    <version>1.0-SNAPSHOT</version>
        <dependencies>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo</artifactId>
                <version>2.6.1</version>
                <exclusions>
                    <exclusion>
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.javassist</groupId>
                <artifactId>javassist</artifactId>
                <version>3.20.0-GA</version>
            </dependency>
            <dependency>
                <groupId>io.netty</groupId>
                <artifactId>netty</artifactId>
                <version>3.6.10.Final</version>
            </dependency>
            <dependency>
                <groupId>org.apache.curator</groupId>
                <artifactId>curator-framework</artifactId>
                <version>2.9.1</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.7.22</version>
            </dependency>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>1.1.3</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>1.7.22</version>
            </dependency>
        </dependencies>


    </project>

消费者:

package dubbo.api;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ReferenceConfig;
import com.alibaba.dubbo.config.RegistryConfig;

public class ConsumerService {
    public static void main(String[] args) {

// 当前应用配置
        ApplicationConfig application = new ApplicationConfig();
        application.setName("demo");

// 连接注册中心配置
        RegistryConfig registry = new RegistryConfig();
        registry.setAddress("localhost:2181");
        registry.setProtocol("zookeeper");
        registry.setUsername("root");
        registry.setPassword("root");

// 注意:ReferenceConfig为重对象,内部封装了与注册中心的连接,以及与服务提供方的连接

// 引用远程服务
        ReferenceConfig<demoService> reference = new ReferenceConfig<demoService>(); // 此实例很重,封装了与注册中心的连接以及与提供者的连接,请自行缓存,否则可能造成内存和连接泄漏
        reference.setApplication(application);
        reference.setRegistry(registry); // 多个注册中心可以用setRegistries()
        reference.setInterface(demoService.class);
        reference.setVersion("1.0.0");

// 和本地bean一样使用xxxService
        demoService demoService = reference.get(); // 注意:此代理对象内部封装了所有通讯细节,对象较重,请缓存复用
        String say = demoService.say();
        System.out.println("输出结果"+say);
        reference.destroy();
    }
}

Spring引入Dubbo

目录架构

1546520655619

  1. 准备工作,引入jar包,

    总项目pom文件

    <!--
      Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements.  See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version 2.0
      (the "License"); you may not use this file except in compliance with
      the License.  You may obtain a copy of the License at
    
          http://www.apache.org/licenses/LICENSE-2.0
    
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
      -->
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-parent</artifactId>
            <version>2.7.0-SNAPSHOT</version>
        </parent>
        <artifactId>dubbo-demo</artifactId>
        <packaging>pom</packaging>
        <name>${project.artifactId}</name>
        <description>The demo module of dubbo project</description>
        <properties>
            <skip_maven_deploy>true</skip_maven_deploy>
        </properties>
        <modules>
            <module>dubbo-demo-api</module>
            <module>dubbo-demo-provider</module>
            <module>dubbo-demo-consumer</module>
        </modules>
    
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.apache.dubbo</groupId>
                    <artifactId>dubbo-bom</artifactId>
                    <version>${project.parent.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
    
    </project>
    
    

    生产者依赖:

    <!--
      Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements.  See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version 2.0
      (the "License"); you may not use this file except in compliance with
      the License.  You may obtain a copy of the License at
    
          http://www.apache.org/licenses/LICENSE-2.0
    
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
      -->
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-demo</artifactId>
            <version>2.7.0-SNAPSHOT</version>
        </parent>
        <artifactId>dubbo-demo-provider</artifactId>
        <packaging>jar</packaging>
        <name>${project.artifactId}</name>
        <description>The demo provider module of dubbo project</description>
        <properties>
            <skip_maven_deploy>true</skip_maven_deploy>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-demo-api</artifactId>
                <version>${project.parent.version}</version>
            </dependency>
            <!--dubbo-spring配置-->
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-config-spring</artifactId>
            </dependency>
            <!--zookeeper注册中心-->
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-registry-zookeeper</artifactId>
            </dependency>
            <!--注册广播-->
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-registry-multicast</artifactId>
            </dependency>
            <!--rpc整合-->
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-rpc-dubbo</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-remoting-netty4</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-serialization-hessian2</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-configcenter-zookeeper</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-metadata-report-zookeeper</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-metadata-report-redis</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-qos</artifactId>
            </dependency>
        </dependencies>
    </project>
    
    

    消费者依赖:

    <!--
      Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements.  See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version 2.0
      (the "License"); you may not use this file except in compliance with
      the License.  You may obtain a copy of the License at
    
          http://www.apache.org/licenses/LICENSE-2.0
    
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
      -->
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-demo</artifactId>
            <version>2.7.0-SNAPSHOT</version>
        </parent>
        <artifactId>dubbo-demo-consumer</artifactId>
        <packaging>jar</packaging>
        <name>${project.artifactId}</name>
        <description>The demo consumer module of dubbo project</description>
        <properties>
            <skip_maven_deploy>true</skip_maven_deploy>
        </properties>
        <dependencies>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-demo-api</artifactId>
                <version>${project.parent.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-config-spring</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-registry-zookeeper</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-registry-multicast</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-rpc-dubbo</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-remoting-netty4</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-serialization-hessian2</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-configcenter-zookeeper</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-metadata-report-redis</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-metadata-report-zookeeper</artifactId>
            </dependency>
        </dependencies>
    </project>
    
    

    api的依赖:

    <!--
      Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements.  See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version 2.0
      (the "License"); you may not use this file except in compliance with
      the License.  You may obtain a copy of the License at
    
          http://www.apache.org/licenses/LICENSE-2.0
    
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
      -->
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-demo</artifactId>
            <version>2.7.0-SNAPSHOT</version>
        </parent>
        <artifactId>dubbo-demo-api</artifactId>
        <packaging>jar</packaging>
        <name>${project.artifactId}</name>
        <description>The demo module of dubbo project</description>
        <properties>
            <skip_maven_deploy>true</skip_maven_deploy>
        </properties>
    </project
    
  2. 配置springapplication的xml文件

    配置消费者文件

    <?xml version="1.0" encoding="UTF-8"?>
    <!--
      Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements.  See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version 2.0
      (the "License"); you may not use this file except in compliance with
      the License.  You may obtain a copy of the License at
    
          http://www.apache.org/licenses/LICENSE-2.0
    
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
      -->
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
           xmlns="http://www.springframework.org/schema/beans"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
           http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
    
        <dubbo:application name="demo-consumer"/>
    
        <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
    
        <!-- generate proxy for the remote service, then demoService can be used in the same way as the
        local regular interface -->
        <dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.demo.DemoService"/>
    
    </beans>
    
    

    配置生产者的xml文件

    <?xml version="1.0" encoding="UTF-8"?>
    <!--
      Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements.  See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version 2.0
      (the "License"); you may not use this file except in compliance with
      the License.  You may obtain a copy of the License at
    
          http://www.apache.org/licenses/LICENSE-2.0
    
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
      -->
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
           xmlns="http://www.springframework.org/schema/beans"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
           http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
    
        <!-- provider's application name, used for tracing dependency relationship -->
        <dubbo:application name="demo-provider"/>
        <!--multicast://224.5.6.7:1234-->
        <dubbo:registry address="zookeeper://localhost:2181" />
    
        <!-- use dubbo protocol to export service on port 20880 -->
        <dubbo:protocol name="dubbo" port="-1"/>
    
        <!-- service implementation, as same as regular local bean -->
        <bean id="demoService" class="org.apache.dubbo.demo.provider.DemoServiceImpl"/>
    
        <!-- declare the service interface to be exported -->
        <dubbo:service interface="org.apache.dubbo.demo.DemoService" ref="demoService"/>
    
    </beans>
    
    
  3. 编写生产者类和消费者类

    生产者类:

    /*
     * Licensed to the Apache Software Foundation (ASF) under one or more
     * contributor license agreements.  See the NOTICE file distributed with
     * this work for additional information regarding copyright ownership.
     * The ASF licenses this file to You under the Apache License, Version 2.0
     * (the "License"); you may not use this file except in compliance with
     * the License.  You may obtain a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    package org.apache.dubbo.demo.provider;
    
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    public class Provider {
    
        /**
         * To get ipv6 address to work, add
         * System.setProperty("java.net.preferIPv6Addresses", "true");
         * before running your application.
         */
        public static void main(String[] args) throws Exception {
    //        加载配置
            ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/dubbo-demo-provider.xml"});
            context.start();
            System.in.read(); // press any key to exit
        }
    }
    
    

    消费者:

    /*
     * Licensed to the Apache Software Foundation (ASF) under one or more
     * contributor license agreements.  See the NOTICE file distributed with
     * this work for additional information regarding copyright ownership.
     * The ASF licenses this file to You under the Apache License, Version 2.0
     * (the "License"); you may not use this file except in compliance with
     * the License.  You may obtain a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    package org.apache.dubbo.demo.consumer;
    
    import org.apache.dubbo.demo.DemoService;
    
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    public class Consumer {
    
        /**
         * To get ipv6 address to work, add
         * System.setProperty("java.net.preferIPv6Addresses", "true");
         * before running your application.
         */
        public static void main(String[] args) {
            ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/dubbo-demo-consumer.xml"});
            context.start();
            DemoService demoService = (DemoService) context.getBean("demoService"); // get remote service proxy
            while (true) {
                try {
                    Thread.sleep(1000);
                    String hello = demoService.sayHello("world"); // call remote method
                    System.out.println(hello); // get result
                } catch (Throwable throwable) {
                    throwable.printStackTrace();
                }
            }
        }
    }
    
  4. 总结细节:

    • api是作为一个服务接口层,消费者和生产者通过jar包的方式共享依赖它
    • 消费层调用服务的时候,可能会出现异常,要将异常进行处理,否则在开发中会有问题
    • 注册中心zookeeper按照配置配置,简单注册中心使用

应用场景:未来方向:扩展思路

应用场景:O2O,购物等对于并发高,服务多,这个项目庞大的使用该技术于分布式企业级的架构

未来方向:开发-部署-生产的服务在一个环境下,开发不会影响到生产环境,可以在生产环境下开发,提高代码质量。更容易部署开发。未来的方向是基础设施就是服务,服务的伸缩性和健壮性会更高

扩展思路:服务治理的概念很好,但是作为一个虚拟的管理中心,好像是一个公司的政务部门,统计各个部门的进度,协调工作。高内聚,低耦合,以后可能会出现一个总的注册中心,所有的注册中心到总注册中心登记一个类别的服务,然后所有的服务都是阶梯式的架构。

### 总结

Dubbo的核心内容还有很多,这些只是一个入门的。还要继续努力!

猜你喜欢

转载自blog.csdn.net/hlw521hxq/article/details/85721952
今日推荐