Skip to content
samples for Apache Dubbo
Java TSQL Scala HTML Dockerfile Thrift
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows simple github action Aug 20, 2019
.mvn optimize travis Aug 20, 2019
codestyle change groupId, packageName to org.apache.dubbo Oct 22, 2018
dubbo-maven-address-plugin introduce a maven plugin to detect dubbo local address to register Jun 5, 2019
dubbo-samples-annotation move configuration class to a seperated packagee Aug 22, 2019
dubbo-samples-api Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-async Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-attachment Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-basic Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-cache Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-callback Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-chain Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-compatible Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-configcenter add apollo docker support Jul 23, 2019
dubbo-samples-consul Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-context Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-direct integration test for apache/dubbo#4889 Aug 20, 2019
dubbo-samples-docker Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-echo Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-edas Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-environment-keys Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-gateway clean up dubbo-samples-gateway Aug 6, 2019
dubbo-samples-generic make test case more reasonable. Jul 25, 2019
dubbo-samples-governance Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-group Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-http Fix failed dubbo-samples-http test (#116) Sep 2, 2019
dubbo-samples-jetty Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-local Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-merge Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-metadata-report Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-metrics Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-mock Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-monitor Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-multi-registry Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-nacos move nacos tests into another profile Aug 13, 2019
dubbo-samples-notify Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-protostuff protostuff samples Jul 29, 2019
dubbo-samples-resilience4j Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-rest Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-scala Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-sentinel add samples for sentinel Jul 23, 2019
dubbo-samples-serialization add samples for java serialization Jul 23, 2019
dubbo-samples-simplified-registry Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-spi-compatible Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-spring-boot-hystrix Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-spring-hystrix Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-stub Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-switch-serialization-thread Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-tengine add dubbo samples for tengine dubbo Aug 16, 2019
dubbo-samples-thrift Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-transaction Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-validation Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-version Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-zipkin Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
dubbo-samples-zookeeper Upgrade version <dubbo.version> and <dubbo.rpc.version> to 2.7.3 Jul 23, 2019
.gitignore update gitignore Apr 28, 2018
.travis.yml optimize travis Aug 20, 2019
LICENSE Create LICENSE Jul 9, 2018
README.md update README Jun 25, 2019
killall.sh make sure all samples processes end completely after integration test… Jul 9, 2019
mvnw upgrade mvn to 3.5.4 Sep 11, 2018
mvnw.cmd upgrade mvn to 3.5.4 Sep 11, 2018
pom.xml introduce local settings to config apache snapshot repository Aug 19, 2019

README.md

Dubbo Samples

Samples for Apache Dubbo

Build Status license

This repository contains a number of projects to illustrate various usages of Dubbo from basic to advanced, pls. check README in each individual sub projects. It is also helpful to cross reference to Dubbo User Manual to understand the features demoed in this project.

Build and Run Samples

To compile all samples, run the following command in the top directory of this project, or step into the sub directories to compile one single sample:

mvn clean package

You may need to read each individual README under the sub directories if it has to understand how to build and run.

Integration Test

This project is also used for integration test for dubbo.

How to build and run a integration test

Most of integration tests will reply on a home-brew maven plugin to perform correctly when dubbo service is deployed in docker environment. This maven plugin is provided in 'dubbo-maven-address-plugin' module and should be installed before running any integration test:

cd dubbo-maven-address-plugin
mvn clean install

It is as simple as stepping into a sub directory and then executing the following command, for example:

cd dubbo-samples-annotation
mvn -Pdubbo-integration-test clean verify

If docker container fails to startup successfully in any case, you can use -Ddocker.showLogs to check its logging output to understand what happens.

mvn -Ddocker.showLogs -Pdubbo-integration-test clean verify

Pls. note integration test relies on docker environment, make sure docker environment is available before run it.

How to add more integration test

If you are interested in contributing more integration test for dubbo, pls. read further to understand how to enable integration test for one particular sample from the scratch.

  1. Related maven properties relevant to integration test:
<spring.version>4.3.16.RELEASE</spring.version>
<junit.version>4.12</junit.version>
<docker-maven-plugin.version>0.30.0</docker-maven-plugin.version>
<jib-maven-plugin.version>1.2.0</jib-maven-plugin.version>
<maven-failsafe-plugin.version>2.21.0</maven-failsafe-plugin.version>
<image.name>${artifactId}:${dubbo.version}</image.name>
<dubbo.port>20880</dubbo.port>
<main-class>org.apache.dubbo.samples.attachment.AttachmentProvider</main-class>

Integration test leverages docker to setup test environment, more accurately, to start dubbo provider instance, and any other supporting systems like registry center if necessary, in docker. Therefore, there are two maven plugins required for composing docker image and start-and-stop the docker instances before-and-after the integration test: 1. jib-maven-plugin from google 2. docker-maven-plugin from fabric8.

  1. Configure maven profile:

Since we use profile 'dubbo-integration-test' to enable integration test, make sure the following plugins are configured under the desire profile, which is 'dubbo-integration-test':

<profiles>
    <profile>
    <id>dubbo-integration-test</id>
    <build>
        <plugins><!-- declare maven plugins here --></plugins>
    </build> 
    </profile>
</profiles>
  1. Configure dubbo-maven-address-plugin
<plugin>
    <groupId>org.apache.dubbo</groupId>
    <artifactId>dubbo-maven-address-plugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <executions>
        <execution>
            <goals>
                <goal>local-address</goal>
            </goals>
            <configuration>
                <localAddress>dubbo-local-address</localAddress>
            </configuration>
            <phase>initialize</phase>
        </execution>
    </executions>
</plugin>

'dubbo-local-address' is a maven property in which dubbo provider's IP address is stored.

  1. Configure jib-maven-plugin
<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>jib-maven-plugin</artifactId>
    <version>${jib-maven-plugin.version}</version>
    <configuration>
        <from>
            <image>${java-image.name}</image>
        </from>
        <to>
            <image>${image.name}</image>
        </to>
        <container>
            <mainClass>${main-class}</mainClass>
            <ports>
                <port>${dubbo.port}</port> <!-- dubbo provider's port -->
                <port>2181</port> <!-- zookeeper's port -->
            </ports>
            <environment>
                <DUBBO_IP_TO_REGISTRY>${dubbo-local-address}</DUBBO_IP_TO_REGISTRY>
            </environment>
        </container>
   </configuration>
    <executions>
        <execution>
            <phase>package</phase>
                <goals>
                    <goal>dockerBuild</goal>
                </goals>
        </execution>
    </executions>
</plugin>

'<DUBBO_IP_TO_REGISTRY>' is an environment variable to instruct dubbo provider the IP address used for registering to service registration center. Since the dubbo provider will run within a docker instance, a host's IP address (detected from dubbo-maven-address-plugin) must be used in order to allow it discovered by the dubbo client running outside docker instance.

  1. Configure docker-maven-plugin
<plugin>
    <groupId>io.fabric8</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>${docker-maven-plugin.version}</version>
    <configuration>
        <images>
            <image>
                <name>${image.name}</name>
                <run>
                    <ports>
                        <port>${dubbo.port}:${dubbo.port}</port> <!-- expose dubbo port -->
                        <port>2181:2181</port> <!-- expose zookeeper port -->
                    </ports>
                    <wait>
                        <!-- wait until the message output in stdout, and it requires dubbo's provider 
                        explicitly prints out this message at the very end of main() -->
                        <log>dubbo service started</log> 
                    </wait>
                </run>
            </image>
        </images>
    </configuration>
    <executions>
        <execution>
            <id>start</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>start</goal>
            </goals>
        </execution>
        <execution>
            <id>stop</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>stop</goal>
            </goals>
        </execution>
    </executions>
</plugin>

'docker-maven-plugin' will start the specified docker image before integration test (phase 'pre-integration-test') and stop it after integration test (phase 'post-integration-test').

  1. Configure maven-failsafe-plugin
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>${maven-failsafe-plugin.version}</version>
    <executions>
        <execution>
            <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
            </goals>
            <configuration>
                <includes>
                    <include>**/*IT.java</include>
                </includes>
            </configuration>
        </execution>
    </executions>
</plugin>

A integration test is basically a JUnit based test class, but with its name suffixed by 'IT'.

That's it, then feel free to add more integration test for the Dubbo project. You may need to refer to 'dubbo-samples-annotation' or 'dubbo-samples-attachment' for more details, have fun.

You can’t perform that action at this time.