SpringBoot 2.0 + Apache Dubbo 2.7.3 Latest Version Integration Scheme

Keywords: Java Dubbo Apache Spring Zookeeper

Preface

On February 16, 2018, Apache Dubbo joined the Apache Foundation incubator. On May 16, 2019, the board of directors of the Apache Software Foundation approved the graduation application of Apache Dubbo, which means that Apache Dubbo has officially become Apache's top project.

To configure

When Dubbo donates sperm to Apache, it means that the coordinates of Dubbo and spring-boot-starter have changed. Of course, the former ones are still available, but it's recommended here to use the new version.

Zookeeper Registry Edition

pom.xml introduces coordinates:

<!-- upgrade apache dubbo -->
<dependency>
    <groupId>org.apache.dubbo</groupId>
    <artifactId>dubbo</artifactId>
    <version>2.7.3</version>
</dependency>
<!-- Zookeeper -->
<dependency>
    <groupId>org.apache.zookeeper</groupId>
    <artifactId>zookeeper</artifactId>
    <version>3.5.3-beta</version>
</dependency>
<dependency>
    <groupId>org.apache.curator</groupId>
    <artifactId>curator-framework</artifactId>
    <version>4.2.0</version>
</dependency>
<dependency>
    <groupId>org.apache.curator</groupId>
    <artifactId>curator-recipes</artifactId>
    <version>4.2.0</version>
</dependency>
<!-- Newest starter -->
<dependency>
    <groupId>org.apache.dubbo</groupId>
    <artifactId>dubbo-spring-boot-starter</artifactId>
    <version>2.7.3</version>
</dependency>

Configuration file:

dubbo.application.id=mail
dubbo.application.name=mail
dubbo.registry.address=zookeeper://106.13.122.117:2181
dubbo.provider.threads=10
dubbo.provider.threadpool=fixed
dubbo.provider.loadbalance=roundrobin
dubbo.server=true
dubbo.protocol.name=dubbo
dubbo.protocol.port=-1

Startup class:

@SpringBootApplication
//Packet scanning must be configured, otherwise Dubbo can't register services, and class plus scanning can't be achieved, Japanese dog can't.
@DubboComponentScan(basePackages = "com.itstyle.mail.service.impl")
public class Application  {
    private static final Logger logger = LoggerFactory.getLogger(Application.class);
    
    public static void main(String[] args){
        SpringApplication.run(Application.class, args);
        logger.info("Mail Service Project Start");
    }
}

Provider interface implementation:

# The introduction of apache packages, which were previously available, is outdated
import org.apache.dubbo.config.annotation.Service;

@Service(version = "1.0.0")
public class MailServiceImpl implements IMailService {

}

Consumption citation:

import org.apache.dubbo.config.annotation.Reference;

@RestController
@RequestMapping("/mail")
public class mailController {

    @Reference(version = "1.0.0")
    private IMailService mailService;

}

Nacos Registry Edition

<!-- upgrade apache dubbo -->
<dependency>
    <groupId>org.apache.dubbo</groupId>
    <artifactId>dubbo</artifactId>
    <version>2.7.3</version>
</dependency>
<dependency>
    <groupId>org.apache.dubbo</groupId>
    <artifactId>dubbo-registry-nacos</artifactId>
    <version>2.7.3</version>
</dependency>
<dependency>
    <groupId>com.alibaba.nacos</groupId>
    <artifactId>nacos-client</artifactId>
    <version>1.1.3</version>
</dependency>

Configuration file:

nacos.config.server-addr=47.104.197.9:8848
dubbo.application.name = spring-boot-mail
dubbo.registry.address = nacos://47.104.197.9:8848
dubbo.protocol.name=dubbo
dubbo.protocol.port=-1

Startup class:

@SpringBootApplication
//Package scanning must be configured, otherwise Dubbo cannot register services
@EnableDubbo(scanBasePackages  = "com.itstyle.mail.service.impl")
public class Application  {
    private static final Logger logger = LoggerFactory.getLogger(Application.class);
    
    public static void main(String[] args){
        SpringApplication.run(Application.class, args);
        logger.info("Mail Service Project Start");
    }
}

Reference case

https://gitee.com/52itstyle/spring-boot-mail

https://gitee.com/52itstyle/spring-boot-mail/tree/spring-boot-mail-nacos

Dubbo Milestones

  • In 2008, Alibaba began using Dubbo internally.

  • In early 2009, version 1.0 was released.

  • In October 2011, Alibaba announced an open source version of 2.0.7.

  • In 2014, Dangdang fork launched the Dubbo version, dubbox-2.8.0, and supported the HTTP REST protocol.

  • In October 2014, version 2.3.11 was released.

  • In September 2017, Alibaba restarted maintenance, focusing on updating the JDK and component versions it relied on, releasing version 2.5.4/5;

  • In February 2018, Alibaba announced that it would donate Dubbo to Apache and enter the Apache incubator.

  • In June 2018, Apache Dubbo released version 2.6.2, the first version to join Apache incubator, and the first committer to develop, from the praised @yiji classmates.

  • In July 2018, the official domain name of Dubbo was updated to dubbo.apache.org, the page was refreshed, and a new logo was launched to upgrade the brand in an all-round way.

  • Since joining the incubator in November 2018, the first PPMC member has been developed from the @yiji students who have been praised.

  • In December 2018, at the 8th Conference on Cloud Computing Standards and Applications, Dubbo won the first prize for China's outstanding open source projects and the 2018 China Outstanding Open Source Project Award held by Open Source China, ranking third in the list.

  • In January 2019, 2.7.0 was released, supporting Java 1.8, changing the package name to org.apache, and supporting Restful services.

  • In January 2019, Dubbo Community officially released Dubbo Ecosystem to upgrade to a complete micro-service solution.

  • Dubbo graduated from Apache on May 21, 2019.

Reference resources

https://yq.aliyun.com/articles/705347

https://mvnrepository.com/artifact/org.apache.dubbo/dubbo

https://mvnrepository.com/artifact/org.apache.dubbo/dubbo-spring-boot-starter

Posted by Diceman on Sun, 15 Sep 2019 22:43:18 -0700