GithubHelp home page GithubHelp logo

nathanyun / dubbo-examples Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 391 KB

Based on Apache Dubbo version 3.2.x, Dubbo application and advanced features of various uses.

License: Apache License 2.0

Java 100.00%
dubbo spring springboot zookeeper

dubbo-examples's Introduction

快速开始

本项目是基于Dubbo官方文档提供的对应参考程序,补充了apache/dubbo-samples中没有包含的特性案例演示,建议认真看每个模块中的 README 说明.

版本说明

  • JDK 1.8及以上
  • Apache dubbo 3.2.2
  • ZooKeeper 3.6.2
  • SpringBoot 2.7.8

项目介绍

整体项目结构:

.
├── README.md
├── dubbo-accesslog //dubbo调用日志
├── dubbo-async //异步调用
├── dubbo-attachment //链路调用传递隐式参数
├── dubbo-cluster-fault-tolerance//集群容错
├── dubbo-echo-test//回声测试
├── dubbo-generic//泛化调用
├── dubbo-merge//分组聚合
├── dubbo-notify//远程调用触发事件通知
├── dubbo-quickstart//快速入门(DubboAPI,注解,springboot,springXML)
├── dubbo-service-downgrade//服务降级
├── dubbo-specify-ip//指定IP访问, 一致性哈希选址
├── dubbo-thread-pool-isolation//线程池隔离
├── dubbo-triple-reactor//响应式编程
├── dubbo-validation//参数校验
├── dubbo-version//服务版本
└── pom.xml

FAQ

  1. 为什么把Dubbo端口配置成-1?
设置端口为 -1 表示 dubbo 自动扫描并使用可用端口(从20880开始递增),避免了端口冲突的问题。
 (扩展:dubbo 默认端口是20880,网络中端口范围:1-65535)
  1. 为什么使用@DubboService和@DubboReference注解?
@Service 注解从 3.0 版本开始就已经废弃,改用 @DubboService,以区别于 Spring 的 @Service 注解,
@Reference 注解从 3.0 版本开始就已经废弃,改用 @DubboReference,以区别于 Spring 的 @Reference 注解
  1. 在API模式下, 为什么要用使用 Java Config 代替注解?
//Java Config 是 DubboService 或 DubboReference 的替代方式,对于有复杂配置需求的服务建议使用这种方式。
//但是要注意!!! ServiceConfig为重对象,内部封装了与注册中心的连接,请自行缓存,否则可能造成内存和连接泄漏
@Configuration
public class ProviderConfiguration {
    @Bean
    public ServiceConfig demoService() {
        ServiceConfig service = new ServiceConfig();
        service.setInterface(DemoService.class);
        service.setRef(new DemoServiceImpl());
        service.setGroup("dev");
        service.setVersion("1.0.0");
        Map<String, String> parameters = new HashMap<>();
        service.setParameters(parameters);
        // 暴露及注册服务
        service.export();
        return service;
    }
}

要学习关于dubbo更多的内容,推荐阅读Dubbo官方文档 : http://dubbo.apache.org/

dubbo-examples's People

Contributors

nathanyun avatar

Stargazers

 avatar 张得山 avatar

Watchers

 avatar

Forkers

lifeng98ol

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.