blob: 48d95d7f4cf67283338af28882804a07fb880629 [file] [log] [blame]
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Apache Dubbo – Apache Dubbo</title><link>https://dubbo.apache.org/en/</link><description>Recent content on Apache Dubbo</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="https://dubbo.apache.org/en/index.xml" rel="self" type="application/rss+xml"/><item><title>Blog: Serialization Protocol Security</title><link>https://dubbo.apache.org/en/blog/1/01/01/serialization-protocol-security/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/1/01/01/serialization-protocol-security/</guid><description>
&lt;p>Dubbo 3 has enhanced the security aspects of serialization protocols and recommends using the Triple protocol in non-Wrapper mode. This protocol is secure by default but requires developers to write IDL files.&lt;/p>
&lt;p>In the Triple protocol&amp;rsquo;s Wrapper mode, compatibility with other serialization data is allowed, offering good compatibility. However, other protocols may have deserialization security flaws. For the Hessian2 protocol, users who require high-security attributes should enable whitelist mode according to the sample code. The framework will enable blacklist mode by default to block malicious calls.&lt;/p>
&lt;p>Using other serialization protocols is not recommended. When an attacker can access the Provider interface, security flaws in other serialization protocols may lead to command execution through the Provider interface.&lt;/p>
&lt;p>If you must use other serialization protocols and wish to maintain some level of security, you should enable the Token authentication mechanism. This will prevent threats to the Provider&amp;rsquo;s security from unauthenticated and untrusted request sources. When enabling Token authentication, you should also enable the authentication feature in the registry.&lt;/p>
&lt;h2 id="notice">Notice&lt;/h2>
&lt;p>The following serializations are proved that not safe enough to transfer on network and not recommend to use.&lt;/p>
&lt;ul>
&lt;li>native-hessian&lt;/li>
&lt;li>native-java (Java ObjectOutputStream and ObjectInputStream)&lt;/li>
&lt;/ul></description></item><item><title>Blog: Introduction to Apache Dubbo plugin for IntelliJ IDEA</title><link>https://dubbo.apache.org/en/blog/2023/10/23/introduction-to-apache-dubbo-plugin-for-intellij-idea/</link><pubDate>Mon, 23 Oct 2023 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2023/10/23/introduction-to-apache-dubbo-plugin-for-intellij-idea/</guid><description>
&lt;p>The most popular Java IDE, IntelliJ IDEA, has collaborated with the open-source microservice framework Apache Dubbo community, bringing good news to microservice developers. Along with IntelliJ IDEA version 2023.2, Jetbras has officially released the new &lt;strong>Apache Dubbo in Spring Framework&lt;/strong> plugin version.&lt;/p>
&lt;p>This plugin can help developers with Dubbo project initialization and facilitate the identification of Dubbo services and their dependencies during the project development process. Developing microservices based on Apache Dubbo will become very simple.&lt;/p>
&lt;h2 id="how-to-install">How to install&lt;/h2>
&lt;p>Before installing the Apache Dubbo plugin, please ensure that you are using IntelliJ IDEA version 2023.2 and above.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/2023/10/plugin/img.png" alt="image.png">&lt;/p>
&lt;p>There are two ways to complete the installation of the Apache Dubbo plugin&lt;/p>
&lt;h3 id="method-1">Method 1&lt;/h3>
&lt;p>Open &lt;a href="https://plugins.jetbrains.com/plugin/20938-apache-dubbo-in-spring-framework">the Apache Dubbo in Spring Framework plugin page&lt;/a> with browser, and in the upper right corner of the page, click the &amp;ldquo;Install to IntelliJ IDEA 2023.2&amp;rdquo; button to complete the plugin installation.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/2023/10/plugin/img_1.png" alt="image.png">&lt;/p>
&lt;h3 id="method-2">Method 2&lt;/h3>
&lt;p>Open &amp;lsquo;Preferences -&amp;gt;Plugins&amp;rsquo;, enter &amp;lsquo;Apache Dubbo&amp;rsquo; to search for plugins, and then install them.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/2023/10/plugin/img_2.png" alt="image.png">&lt;/p>
&lt;h2 id="create-a-new-dubbo-application">Create a new Dubbo application&lt;/h2>
&lt;p>Next, let&amp;rsquo;s take a look at how to use the plugin to create and develop an Apache Dubbo microservice application.&lt;/p>
&lt;h3 id="the-new-project-pop-up-window">The &amp;lsquo;New Project&amp;rsquo; pop-up window&lt;/h3>
&lt;p>Open the &amp;lsquo;New Project&amp;rsquo; window through &amp;lsquo;File&amp;gt;New&amp;gt;Project&amp;rsquo;. In the pop-up window, you can see that the Apache Dubbo plugin has appeared in the generators list on the left. Click to select it.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/2023/10/plugin/img_3.png" alt="image.png">&lt;/p>
&lt;p>According to the application needs, enter the project name, save path, coordinates, JDK version, and other information. Click &amp;ldquo;Next&amp;rdquo; to proceed to the next step.&lt;/p>
&lt;h3 id="select-components">Select Components&lt;/h3>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/2023/10/plugin/img_4.png" alt="image.png">&lt;/p>
&lt;p>The plugin will use dubbo spring boot starter to create a Spring Boot project, so we&lt;/p>
&lt;ul>
&lt;li>Firstly, you need to choose the versions of Dubbo and Spring Boot.&lt;/li>
&lt;li>Secondly, select the corresponding Dubbo and business components according to the project needs&lt;/li>
&lt;/ul>
&lt;p>Finally, click &amp;ldquo;Create&amp;rdquo; to complete the project creation.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/2023/10/plugin/img_5.png" alt="image.png">&lt;/p>
&lt;h2 id="summary">Summary&lt;/h2>
&lt;p>The release of the official IntelliJ IDEA plugin greatly simplifies the cost of initializing the Dubbo project.
In addition to the plugin format, you can also directly open the start.dubbo.apache.org online service to quickly create Dubbo projects through a browser.&lt;/p></description></item><item><title>Blog: Advanced cloud native - Dubbo 3.2 officially released</title><link>https://dubbo.apache.org/en/blog/2023/04/15/advanced-cloud-native-dubbo-3.2-officially-released/</link><pubDate>Sat, 15 Apr 2023 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2023/04/15/advanced-cloud-native-dubbo-3.2-officially-released/</guid><description>
&lt;h2 id="background-introduction">Background introduction&lt;/h2>
&lt;p>Apache Dubbo is an RPC service development framework, which is used to solve service governance and communication problems under the microservice architecture. It officially provides multi-language SDK implementations such as Java and Golang. The microservices developed using Dubbo are natively capable of remote address discovery and communication with each other. Using the rich service governance features provided by Dubbo, service governance demands such as service discovery, load balancing, and traffic scheduling can be realized. Dubbo is designed to be highly scalable, and users can easily implement various custom logics for traffic interception and location selection.&lt;/p>
&lt;h2 id="rest-protocol-support">Rest protocol support&lt;/h2>
&lt;h3 id="1-why-rest">1. Why Rest?&lt;/h3>
&lt;p>With the popularization of mobile Internet, more and more applications need to be integrated with different systems. And these systems may use different communication protocols, which requires the application program to be able to flexibly adapt to various protocols. The Rest protocol is a very flexible protocol that communicates using HTTP and can be integrated with almost any system.&lt;/p>
&lt;p>In the past, RPC frameworks typically communicated using a binary protocol, which was very efficient but not flexible enough. In contrast, the Rest protocol uses HTTP for communication, which is more convenient to integrate with other systems, and also easier to integrate with modern web and mobile applications.&lt;/p>
&lt;p>Besides flexibility, the Rest protocol is also readable and easy to use. Using the Rest protocol, developers can test and debug services using common HTTP tools such as cURL or Postman, without the need for specific tools. Also, since the REST protocol uses standard HTTP methods such as GET, POST, PUT, and DELETE, it becomes easier for developers to understand and use the service.&lt;/p>
&lt;h3 id="2-how-to">2. How To?&lt;/h3>
&lt;p>In previous Dubbo versions, Rest protocol support was also provided, but there were the following problems:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>Only supports JAX-RS annotation fields, which is more complex than the more widely adopted Spring Web annotations&lt;/p>
&lt;/li>
&lt;li>
&lt;p>It needs to rely on many external components, such as Resteasy, tomcat, jetty, etc., to work normally, which greatly increases the cost of use.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>Therefore, in Dubbo version 3.2, we introduced the support of Spring Web annotation domain and the native support of Rest protocol without relying on any external components.&lt;/p>
&lt;p>The most intuitive difference is that if you upgrade to Dubbo 3.2, services published through Spring Web can also be published directly through Dubbo. All you need to do is change the @Controller annotation to @DubboService annotation.&lt;/p>
&lt;p>In addition, for users who originally used Spring Boot or Spring Cloud as a service split, they can also migrate smoothly to Dubbo based on this function, and obtain the powerful capabilities of Dubbo at a very low cost.&lt;/p>
&lt;h3 id="3-whats-next">3. What&amp;rsquo;s next?&lt;/h3>
&lt;p>In the future, Dubbo will continue to improve. In addition to the existing features, we will also add the following new features to better meet the needs:&lt;/p>
&lt;ol>
&lt;li>
&lt;p>Native support for HTTP/2 and HTTP/3 protocols. This means that you can use Dubbo to communicate with other systems more easily without worrying about protocol compatibility.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Referring to Spring Web annotations, Dubbo natively provides support for Web annotations, so that users can get the same experience as using Spring Web without relying on Spring Web.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Support zero transformation of existing services and publish them with the Rest protocol. This feature allows you to manage your services more flexibly without making any changes to existing services. You can publish your services through the Rest protocol, so that your services can be used by other systems more easily.&lt;/p>
&lt;/li>
&lt;/ol>
&lt;h2 id="observable-system">Observable system&lt;/h2>
&lt;p>Under the microservice architecture, the business system is composed of more and more services, and the services call each other. The ensuing problem is how to quickly locate the fault and solve it in time. In order to solve this problem, we need more tools and techniques to ensure the reliability of the whole system. One of the solutions is to use logging and analytics so that you can better track how your application is doing, find potential problems and fix them in a timely manner. In addition, using visual monitoring tools can help us better understand the status of the entire system, so as to better predict and solve problems. Finally, we can also use automated testing to ensure the quality of each service, as well as the stability and reliability of the entire system, so as to better meet customer needs.&lt;/p>
&lt;p>A complete observable system should include the following functions:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>Metrics indicator monitoring, used to collect and analyze various indicator data, including system performance, resource consumption, etc. Through indicator monitoring, users can keep abreast of the operation of the system, find abnormalities and take corresponding measures.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Tracing Distributed tracing, used to trace the call links between various services in the system, to help users discover and locate potential performance problems, bottlenecks, etc. Through distributed tracing, users can deeply understand the operation process of the system, identify possible problems and make effective optimization and adjustment.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Logging log management, used to record various events and operations in the system, including error logs, access logs, transaction logs, etc. Through log management, users can learn about the running status of the system, fault information, etc., and help users quickly locate problems and handle them accordingly.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>To sum up, the above three functions can not only help users quickly locate faults, improve system reliability and stability, but also help users deeply understand the operation and performance of the system, and provide users with comprehensive monitoring and protection.&lt;/p>
&lt;p>In Dubbo version 3.2, we mainly enhanced Metrics and Tracing.&lt;/p>
&lt;h3 id="1-metrics">1. Metrics&lt;/h3>
&lt;p>In terms of metrics, we use Micrometer to greatly increase the buried points of indicators, including but not limited to core service indicators such as QPS, RT, total number of calls, number of successes, number of failures, and failure reason statistics. In order to better monitor the running status of services, Dubbo also provides monitoring of the status of core components, such as the number of thread pools, service health status, etc. In addition, Dubbo also supports the standard Prometheus Pull and Push modes, and provides several official native Grafana panels to achieve production-oriented Metrics all-weather observation.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/32-release/Untitled.png" alt="img">&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/32-release/Untitled%201.png" alt="Untitled">&lt;/p>
&lt;p>For all users, only need to upgrade to Dubbo 3.2 version and add dubbo-spring-boot-observability-starter dependency to get Metrics capability. After the application starts, relevant indicators will be exposed under the metrics command of Dubbo QoS, which can be obtained locally through &lt;code>http://127.0.0.1:22222/metrics&lt;/code>. In addition, for users who use Spring Actuator, Dubbo will also expose these data by default.&lt;/p>
&lt;h3 id="tracing">Tracing&lt;/h3>
&lt;p>In terms of Tracing, we also implemented tracking of buried points during request runtime based on Micrometer. We implement this function natively through the Filter interceptor. We support exporting trace data to some mainstream implementations, such as Zipkin, Skywalking, Jaeger, etc. In this way, the analysis and visual display of the full link tracking data can be realized.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/32-release/Untitled%202.png" alt="Untitled">&lt;/p>
&lt;h3 id="logging">Logging&lt;/h3>
&lt;p>In addition, for Logging, Dubbo has introduced an error code mechanism since version 3.1, realizing full coverage of WARN and ERROR level logs. In abnormal scenarios, it supports quick indexing of official website resolution documents.&lt;/p>
&lt;h2 id="native-image-native-support">Native Image native support&lt;/h2>
&lt;p>In terms of Native Image, Dubbo will officially support Native Image based on GraalVM starting from 3.2. Starting from Dubbo3.0, Dubbo has already explored some Native Image support, but the ease of use and support are not ideal. From 3.2 Starting from version 1, Dubbo will simplify the way users access Native Image. It can be mainly divided into three aspects:&lt;/p>
&lt;ol>
&lt;li>Compile plugin configuration upgrade: from the original native-image-maven-plugin to dubbo-maven-plugin +native-maven-plugin, which distinguishes the native image configuration officially provided by Graalvm from the native image configuration required by Dubbo, simplifying The native image configuration that users need to care about&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;plugin&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.graalvm.nativeimage&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>native-image-maven-plugin&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>21.0.0.2&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;executions&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;execution&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;goals&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;goal&amp;gt;&lt;/span>native-image&lt;span style="color:#268bd2">&amp;lt;/goal&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/goals&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;phase&amp;gt;&lt;/span>package&lt;span style="color:#268bd2">&amp;lt;/phase&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/execution&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/executions&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;configuration&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;skip&amp;gt;&lt;/span>false&lt;span style="color:#268bd2">&amp;lt;/skip&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;imageName&amp;gt;&lt;/span>demo-native-provider&lt;span style="color:#268bd2">&amp;lt;/imageName&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;mainClass&amp;gt;&lt;/span>org.apache.dubbo.demo.graalvm.provider.Application&lt;span style="color:#268bd2">&amp;lt;/mainClass&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;buildArgs&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --no-fallback
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.slf4j.MDC
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.slf4j.LoggerFactory
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.slf4j.impl.StaticLoggerBinder
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.apache.log4j.helpers.Loader
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.apache.log4j.Logger
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.apache.log4j.helpers.LogLog
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.apache.log4j.LogManager
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.apache.log4j.spi.LoggingEvent
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.slf4j.impl.Log4jLoggerFactory
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.slf4j.impl.Log4jLoggerAdapter
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.eclipse.collections.api.factory.Sets
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.epoll.Epoll
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.epoll.Native
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.epoll.EpollEventLoop
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.epoll.EpollEventArray
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.DefaultFileRegion
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.kqueue.KQueueEventArray
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.kqueue.KQueueEventLoop
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.kqueue.Native
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.unix.Errors
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.unix.IovArray
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.unix.Limits
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.util.internal.logging.Log4JLogger
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.unix.Socket
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.ChannelHandlerMask
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --report-unsupported-elements-at-runtime
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --allow-incomplete-classpath
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --enable-url-protocols=http
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> -H:+ReportExceptionStackTraces
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/buildArgs&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/configuration&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/plugin&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>becomes:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;plugin&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.graalvm.buildtools&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>native-maven-plugin&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>0.9.20&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;configuration&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;classesDirectory&amp;gt;&lt;/span>${project.build.outputDirectory}&lt;span style="color:#268bd2">&amp;lt;/classesDirectory&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;metadataRepository&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;enabled&amp;gt;&lt;/span>true&lt;span style="color:#268bd2">&amp;lt;/enabled&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/metadataRepository&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;requiredVersion&amp;gt;&lt;/span>22.3&lt;span style="color:#268bd2">&amp;lt;/requiredVersion&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;mainClass&amp;gt;&lt;/span>org.apache.dubbo.demo.graalvm.provider.Application&lt;span style="color:#268bd2">&amp;lt;/mainClass&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/configuration&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/plugin&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;plugin&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.apache.dubbo&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>dubbo-maven-plugin&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>${project.version}&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;configuration&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;mainClass&amp;gt;&lt;/span>org.apache.dubbo.demo.graalvm.provider.Application&lt;span style="color:#268bd2">&amp;lt;/mainClass&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/configuration&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;executions&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;execution&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;phase&amp;gt;&lt;/span>process-sources&lt;span style="color:#268bd2">&amp;lt;/phase&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;goals&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;goal&amp;gt;&lt;/span>dubbo-process-aot&lt;span style="color:#268bd2">&amp;lt;/goal&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/goals&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/execution&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/executions&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/plugin&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>In the old version, users were required to manually generate and complete the unique Adaptive code in Dubbo. Users of the new version do not need to care about these details.&lt;/li>
&lt;li>The configuration file under META-INF.native-image generated by the Dubbo framework in the old version will be directly generated in the user&amp;rsquo;s project directory, and the new version 3.2 will be compiled into the target without affecting the user&amp;rsquo;s project structure. In addition, the Dubbo framework will no longer use the method of manually completing the native image, but will automatically detect and generate the required configuration files, which simplifies the experience of Dubbo developers. This can also reduce the size of the final compiled binary package and improve compilation speed.&lt;/li>
&lt;/ol>
&lt;p>In addition to improving ease of use, Dubbo will support API, annotations, and XML configuration methods in native image scenarios in version 3.2, and support compatibility with native in SpringBoot3.&lt;/p>
&lt;h2 id="other">other&lt;/h2>
&lt;h3 id="jdk-17--spring-boot-3-native-support">JDK 17 &amp;amp; Spring Boot 3 native support&lt;/h3>
&lt;p>JDK 17 is the latest LTS version of Java after JDK 11, including many new features and improvements, such as Sealed classes, garbage collector improvements, and more.&lt;/p>
&lt;p>Since JDK 16 began to restrict Java internal class reflection, Dubbo&amp;rsquo;s serialization and dynamic proxy have been affected to a certain extent. In Dubbo 3.2, we solved the compatibility problem from the bottom through the optimization of Fastjson2 and Javassist. At present, Dubbo can run perfectly on JDK17, and all unit tests and most integration tests have also been tested on the JDK 17 platform.&lt;/p>
&lt;p>For the upcoming JDK 21 LTS, Dubbo is intensively adapting it. We will add support for JDK 21 and Dubbo coroutines (Project Loom) in version 3.3.&lt;/p>
&lt;h3 id="rpc-performance-greatly-improved">RPC performance greatly improved&lt;/h3>
&lt;p>In version 3.2, we have optimized the performance of RPC calls, and the optimized content is as follows.&lt;/p>
&lt;ul>
&lt;li>
&lt;p>Eliminates synchronization lock contention and blocking code (&lt;code>triple&lt;/code>)&lt;/p>
&lt;ol>
&lt;li>When creating an HTTP/2 Stream Channel in version 3.1, the method of synchronously blocking user threads is used to wait for the Stream Channel to be created, and the remote call is initiated after the creation is completed. In 3.2, we will create the behavior of HTTP/2 Stream Channel &lt;code>asynchronous&lt;/code> and ensure that the request is initiated after the creation is completed, so as to &lt;code>reduce unnecessary waiting for user threads&lt;/code>.&lt;/li>
&lt;li>In version 3.1, there is a synchronization lock competition between the user thread and the Netty I/O thread. The IO thread will check the Socket availability for each write request, and the Socket availability check method is also used in the user thread, but the Socket availability in the JDK The implementation of the check uses &lt;code>synchronized&lt;/code> to ensure concurrency safety. In order to reduce this part of the time-consuming, we remove the user thread check and eliminate this part of the time-consuming.&lt;/li>
&lt;/ol>
&lt;/li>
&lt;li>
&lt;p>Reduced request response delay with synchronous blocking calls (&lt;code>dubbo&lt;/code>, &lt;code>triple&lt;/code>)&lt;/p>
&lt;p>In the RPC call in SYNC mode in version 3.1, we use a blocking queue to wait for the response written back by the remote service. When the response is written back, it will be added to the queue and wake up the blocked user thread. In 3.2, we replaced the blocking queue with a concurrent queue, and used its CAS mechanism to greatly reduce the number of threads entering blocking, improve CPU utilization and reduce response processing delay&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Reduced the number of thread switches (&lt;code>triple&lt;/code>)&lt;/p>
&lt;p>In version 3.1, the RPC call in SYNC mode uses a consumer thread pool for processing when receiving the response, and wakes up the user thread to receive the response after the processing is completed. However, through the analysis of the consumer thread pool in SYNC mode is unnecessary, an additional layer of consumer thread pool processing not only wastes server resources but also reduces performance, so we removed the consumer thread pool in SYNC mode in version 3.2 , the interaction model changed from &lt;code>NettyEventLoop → ConsumerThread → UserThread&lt;/code> to &lt;code>NettyEventLoop → UserThread&lt;/code>, so as to reduce the waste of server resources and improve performance&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Optimized I/O performance (&lt;code>dubbo&lt;/code>, &lt;code>triple&lt;/code>)&lt;/p>
&lt;p>In version 3.1, we used the Netty framework to achieve network communication, but every time we wrote a message to the peer, we directly flashed it to the peer, resulting in a very high number of system calls and reducing the communication performance. For this reason, we have optimized it in version 3.2. Every time a message is sent, the message is first submitted to a write queue, and multiple messages are written out at the right time, thereby improving I/O Utilization rate greatly improves RPC communication performance.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Support serialization of messages on user threads (&lt;code>dubbo&lt;/code>, &lt;code>triple&lt;/code>)&lt;/p>
&lt;p>In version 3.1, the deserialization of messages in RPC communication is performed in a single I/O thread, which makes it impossible to take advantage of the advantages of multi-core CPUs. For this reason, in version 3.2, we support time-consuming tasks such as deserialization on user threads, and evenly distribute the pressure of I/O threads to multiple CPU cores, thereby improving the performance of large packets. `Scenario RPC performance.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>The performance improvement of 3.2 compared with 3.1 is as follows:&lt;/p>
&lt;p>Triple protocol: In the scenarios of createUser, existUser, and getUser with small packets, the improvement rate is about &lt;code>40-45%&lt;/code>, and the improved performance is basically the same as that of gRPC in the same scenario. The increase of about &lt;code>17%&lt;/code> in the large message scenario listUser, compared to &lt;code>11%&lt;/code> lower than that of gRPC in the same scenario.&lt;/p>
&lt;p>Dubbo protocol: The improvement rate is about &lt;code>180%&lt;/code> in the case of createUser and getUser in small message scenarios. The improvement rate of the very small message existUser (only one boolean value) is about &lt;code>24%&lt;/code>, while the improvement rate of the larger message listUser is the highest, reaching &lt;code>1000%&lt;/code>!&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/32-release/Untitled%203.png" alt="Untitled">&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/32-release/Untitled%204.png" alt="Untitled">&lt;/p>
&lt;h2 id="how-to-upgrade-to-dubbo-32">How to upgrade to Dubbo 3.2&lt;/h2>
&lt;h3 id="pom-upgrade">Pom upgrade&lt;/h3>
&lt;p>The latest Dubbo Maven coordinates are:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.apache.dubbo&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>dubbo&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>3.2.0&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="compatibility">Compatibility&lt;/h3>
&lt;p>For the vast majority of users, upgrading to Dubbo 3.2.0 is completely smooth, and only needs to modify the version of the dependent package.&lt;/p>
&lt;ol>
&lt;li>
&lt;p>Enhancement of serialization verification logic (&lt;strong>important&lt;/strong>)&lt;/p>
&lt;p>As mentioned above, in Dubbo 3.2.0 version, Dubbo will enable the strong verification of the serialization whitelist by default to improve the security of Dubbo and avoid the problem of remote command execution. The current mechanism automatically trusts some classes through the package name recursive mechanism, but for some users who use generics and may have incomplete scanning, we recommend that you upgrade to Dubbo 3.1.9 or add &lt;code>-Ddubbo.application.serialize- check-status=WARN&lt;/code> configuration. After observing for a period of time (via logs and QoS commands), if no security alarm is triggered, you can configure the strong check mode.&lt;/p>
&lt;p>For the configuration of custom whitelist, please refer to &lt;code>Documentation/SDK Manual/Java SDK/Advanced Features and Usage/Improve Security/Class Inspection Mechanism&lt;/code> on the official website for configuration.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Modification of default serialization&lt;/p>
&lt;p>Starting from version 3.2.0 of Dubbo, the default serialization method is switched from &lt;code>hessian2&lt;/code> to &lt;code>fastjson2&lt;/code>. For applications upgraded to 3.2.0, Dubbo will automatically try to use &lt;code>fastjson2&lt;/code> for serialization. Please note that whether it is the client or the server, as long as one end has not been upgraded to 3.2.0, it will be downgraded to &lt;code>hessian2&lt;/code> serialization to ensure compatibility.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Push short protection is disabled by default&lt;/p>
&lt;p>The purpose of push empty protection is that when the registration center fails and actively pushes empty addresses, Dubbo keeps the last batch of provider information to ensure service availability. However, in most cases, even if the registry fails, empty addresses will not be pushed, only in some special cases. If push short protection is turned on, it will have a greater impact on Dubbo&amp;rsquo;s Fallback logic, heartbeat logic, etc., and bring troubles to developers when using Dubbo.&lt;/p>
&lt;p>If you need to enable empty protection in the production environment to achieve high availability, you can configure &lt;code>dubbo.application.enable-empty-protection&lt;/code> to &lt;code>true&lt;/code>. However, please note that it is known that turning on the push protection will cause the server application to roll back to the original version after upgrading from &lt;code>2.6.x&lt;/code> and &lt;code>2.7.x&lt;/code> versions that only support interface-level service discovery to &lt;code>3.x&lt;/code> An exception occurs, which may cause the service call to fail in extreme cases.&lt;/p>
&lt;/li>
&lt;/ol>
&lt;h2 id="summarize">Summarize&lt;/h2>
&lt;p>Dubbo 3.2 is a very important version, it brings many new features and improvements, making Dubbo more powerful and easy to use. We are very grateful for the support and contributions of the community, and hope that everyone can experience Dubbo 3.2 as soon as possible and enjoy the convenience and advantages it brings.&lt;/p></description></item><item><title>Blog: How to proxy Dubbo service in Apache ShenYu Gateway</title><link>https://dubbo.apache.org/en/blog/2022/05/04/how-to-proxy-dubbo-service-in-apache-shenyu-gateway/</link><pubDate>Wed, 04 May 2022 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2022/05/04/how-to-proxy-dubbo-service-in-apache-shenyu-gateway/</guid><description>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/ApacheShenYu-Dubbo-en.png" alt="img">&lt;/p>
&lt;h2 id="1-introduction">1. Introduction&lt;/h2>
&lt;ul>
&lt;li>Apache ShenYu&lt;/li>
&lt;/ul>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/shenyu.png" alt="img">&lt;/p>
&lt;p>&lt;a href="https://shenyu.apache.org/docs/index">Apache ShenYu(Incubating)&lt;/a> is an asynchronous, high-performance, cross-language, responsive &lt;code>API&lt;/code> gateway. Compatible with a variety of mainstream framework systems, support for hot-plugging, users can customize the development to meet the current and future needs of users in a variety of scenarios, experienced large-scale scenarios hammered.&lt;/p>
&lt;p>In May 2021, &lt;code>ShenYu&lt;/code> was donated to the &lt;code>Apache&lt;/code> Software Foundation, and the Apache Foundation voted unanimously to enter the incubator.&lt;/p>
&lt;ul>
&lt;li>Apache Dubbo&lt;/li>
&lt;/ul>
&lt;p>&lt;code>Apache Dubbo&lt;/code> is a microservice development framework that provides two key capabilities, &lt;code>RPC&lt;/code> communication and microservice governance. This means that microservices developed with &lt;code>Dubbo&lt;/code> will have the ability to discover and communicate with each other remotely, and take advantage of the rich service governance capabilities provided by Dubbo to achieve service governance requirements such as service discovery, load balancing, traffic scheduling, and so on. At the same time &lt;code>Dubbo&lt;/code> is highly scalable, users can customize their own implementation at almost any point to change the default behavior of the framework to meet their business needs.&lt;/p>
&lt;h2 id="2-quick-start-with-dubbo">2. Quick Start with Dubbo&lt;/h2>
&lt;p>This section describes how to connect the &lt;code>Dubbo&lt;/code> service to the &lt;code>Shenyu&lt;/code> gateway. You can find the [sample code] for this section directly under the project (&lt;a href="https://github.com/apache/shenyu/tree/master/shenyu-examples/shenyu-examples-dubbo">https://github.com/apache/shenyu/tree/master/shenyu-examples/shenyu-examples-dubbo&lt;/a> -examples-dubbo/shenyu-examples-apache-dubbo-service).&lt;/p>
&lt;h3 id="21-start-shenyu-admin">2.1 Start shenyu-admin&lt;/h3>
&lt;p>&lt;code>shenyu-admin&lt;/code> is the &lt;code>Apache ShenYu&lt;/code> backend management system, there are various ways to start it, this article is started by &lt;code>[local deployment](https://shenyu.apache.org/docs/deployment/deployment-local)&lt;/code> way. After successful startup, you need to set the &lt;code>dubbo&lt;/code> plugin to be on and set your registered address in the base configuration &lt;code>-&amp;gt;&lt;/code>Plugin Management&amp;rsquo;, please make sure the registration center has been opened.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/dubbo-enable-en.png" alt="img">&lt;/p>
&lt;h3 id="22-start-shenyu-gateway">2.2 Start ShenYu Gateway&lt;/h3>
&lt;p>Here it is started by way of &lt;a href="https://github.com/apache/incubator-shenyu/tree/master/shenyu-bootstrap">source&lt;/a> and runs directly &lt;code>shenyu-bootstrap&lt;/code> in &lt;code>shenyu-bootstrap&lt;/code>. ShenyuBootstrapApplication`.&lt;/p>
&lt;p>Make sure the gateway has introduced the relevant dependencies before starting. If the client is &lt;code>apache dubbo&lt;/code> and the registry uses &lt;code>zookeeper&lt;/code>, please refer to the following configuration.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;!--&lt;/span> apache shenyu apache dubbo plugin start&lt;span style="color:#719e07">--&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>dependency&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>groupId&lt;span style="color:#719e07">&amp;gt;&lt;/span>org.apache.shenyu&lt;span style="color:#719e07">&amp;lt;/&lt;/span>groupId&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>artifactId&lt;span style="color:#719e07">&amp;gt;&lt;/span>shenyu&lt;span style="color:#719e07">-&lt;/span>spring&lt;span style="color:#719e07">-&lt;/span>boot&lt;span style="color:#719e07">-&lt;/span>starter&lt;span style="color:#719e07">-&lt;/span>plugin&lt;span style="color:#719e07">-&lt;/span>apache&lt;span style="color:#719e07">-&lt;/span>dubbo&lt;span style="color:#719e07">&amp;lt;/&lt;/span>artifactId&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>version&lt;span style="color:#719e07">&amp;gt;&lt;/span>${project.version}&lt;span style="color:#719e07">&amp;lt;/&lt;/span>version&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;/&lt;/span>dependency&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>dependency&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>groupId&lt;span style="color:#719e07">&amp;gt;&lt;/span>org.apache.dubbo&lt;span style="color:#719e07">&amp;lt;/&lt;/span>groupId&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>artifactId&lt;span style="color:#719e07">&amp;gt;&lt;/span>dubbo&lt;span style="color:#719e07">&amp;lt;/&lt;/span>artifactId&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>version&lt;span style="color:#719e07">&amp;gt;&lt;/span>2.7.5&lt;span style="color:#719e07">&amp;lt;/&lt;/span>version&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;/&lt;/span>dependency&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;!--&lt;/span> Dubbo zookeeper registry dependency start &lt;span style="color:#719e07">--&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>dependency&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>groupId&lt;span style="color:#719e07">&amp;gt;&lt;/span>org.apache.curator&lt;span style="color:#719e07">&amp;lt;/&lt;/span>groupId&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>artifactId&lt;span style="color:#719e07">&amp;gt;&lt;/span>curator&lt;span style="color:#719e07">-&lt;/span>client&lt;span style="color:#719e07">&amp;lt;/&lt;/span>artifactId&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>version&lt;span style="color:#719e07">&amp;gt;&lt;/span>4.0.1&lt;span style="color:#719e07">&amp;lt;/&lt;/span>version&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>exclusions&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>exclusion&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>artifactId&lt;span style="color:#719e07">&amp;gt;&lt;/span>log4j&lt;span style="color:#719e07">&amp;lt;/&lt;/span>artifactId&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>groupId&lt;span style="color:#719e07">&amp;gt;&lt;/span>log4j&lt;span style="color:#719e07">&amp;lt;/&lt;/span>groupId&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;/&lt;/span>exclusion&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;/&lt;/span>exclusions&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;/&lt;/span>dependency&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>dependency&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>groupId&lt;span style="color:#719e07">&amp;gt;&lt;/span>org.apache.curator&lt;span style="color:#719e07">&amp;lt;/&lt;/span>groupId&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>artifactId&lt;span style="color:#719e07">&amp;gt;&lt;/span>curator&lt;span style="color:#719e07">-&lt;/span>framework&lt;span style="color:#719e07">&amp;lt;/&lt;/span>artifactId&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>version&lt;span style="color:#719e07">&amp;gt;&lt;/span>4.0.1&lt;span style="color:#719e07">&amp;lt;/&lt;/span>version&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;/&lt;/span>dependency&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>dependency&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>groupId&lt;span style="color:#719e07">&amp;gt;&lt;/span>org.apache.curator&lt;span style="color:#719e07">&amp;lt;/&lt;/span>groupId&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>artifactId&lt;span style="color:#719e07">&amp;gt;&lt;/span>curator&lt;span style="color:#719e07">-&lt;/span>recipes&lt;span style="color:#719e07">&amp;lt;/&lt;/span>artifactId&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>version&lt;span style="color:#719e07">&amp;gt;&lt;/span>4.0.1&lt;span style="color:#719e07">&amp;lt;/&lt;/span>version&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;/&lt;/span>dependency&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;!--&lt;/span> Dubbo zookeeper registry dependency end &lt;span style="color:#719e07">--&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;!--&lt;/span> apache dubbo plugin end&lt;span style="color:#719e07">--&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="23-start-shenyu-examples-dubbo">2.3 Start shenyu-examples-dubbo&lt;/h3>
&lt;p>Take the example provided on the official website &lt;a href="https://github.com/apache/shenyu/tree/master/shenyu-examples/shenyu-examples-dubbo">shenyu-examples-dubbo&lt;/a>. Suppose the &lt;code>dubbo&lt;/code> service is defined as follows.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;beans&lt;/span> /* ...... * &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:application&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;test-dubbo-service&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:registry&lt;/span> address=&lt;span style="color:#2aa198">&amp;#34;${dubbo.registry.address}&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:protocol&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;dubbo&amp;#34;&lt;/span> port=&lt;span style="color:#2aa198">&amp;#34;20888&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:service&lt;/span> timeout=&lt;span style="color:#2aa198">&amp;#34;10000&amp;#34;&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;org.apache.shenyu.examples.dubbo.api.service.DubboTestService&amp;#34;&lt;/span> ref=&lt;span style="color:#2aa198">&amp;#34;dubboTestService&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/beans&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Declare the application service name, register the center address, use the &lt;code>dubbo&lt;/code> protocol, declare the service interface, and the corresponding interface implementation class.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * DubboTestServiceImpl.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Service&lt;/span>(&lt;span style="color:#2aa198">&amp;#34;dubboTestService&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DubboTestServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> DubboTestService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@ShenyuDubboClient&lt;/span>(path &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;/findById&amp;#34;&lt;/span>, desc &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;Query by Id&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> DubboTest &lt;span style="color:#268bd2">findById&lt;/span>(&lt;span style="color:#268bd2">final&lt;/span> String id) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#719e07">new&lt;/span> DubboTest(id, &lt;span style="color:#2aa198">&amp;#34;hello world shenyu Apache, findById&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">//......&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In the interface implementation class, use the annotation &lt;code>@ShenyuDubboClient&lt;/code> to register the service with &lt;code>shenyu-admin&lt;/code>.&lt;/p>
&lt;p>Configuration information in the configuration file &lt;code>application.yml&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">server&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">port&lt;/span>: &lt;span style="color:#2aa198">8011&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">address&lt;/span>: &lt;span style="color:#2aa198">0.0.0.0&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">servlet&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">context-path&lt;/span>: /
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">spring&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">main&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">allow-bean-definition-overriding&lt;/span>: &lt;span style="color:#cb4b16">true&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">dubbo&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">registry&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">address&lt;/span>: zookeeper://localhost:2181 &lt;span style="color:#586e75"># The registry used by dubbo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">shenyu&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">register&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">registerType&lt;/span>: http &lt;span style="color:#586e75">#Registration Method&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">serverLists&lt;/span>: http://localhost:9095 &lt;span style="color:#586e75">#Registration Address&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">props&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">username&lt;/span>: admin
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">password&lt;/span>: &lt;span style="color:#2aa198">123456&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">client&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">dubbo&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">props&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">contextPath&lt;/span>: /dubbo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">appName&lt;/span>: dubbo
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In the configuration file, declare the registry address used by &lt;code>dubbo&lt;/code>. The &lt;code>dubbo&lt;/code> service registers with &lt;code>shenyu-admin&lt;/code>, using the method &lt;code>http&lt;/code>, and the registration address is &lt;code>http://localhost:9095&lt;/code>.&lt;/p>
&lt;p>See &lt;code>[Application Client Access](https://shenyu.apache.org/docs/design/register-center-design/)&lt;/code> for more information on the use of the registration method.&lt;/p>
&lt;h3 id="24-invoke-the-dubbo-service">2.4 Invoke the Dubbo service&lt;/h3>
&lt;p>The &lt;code>shenyu-examples-dubbo&lt;/code> project will automatically register the interface methods annotated with &lt;code>@ShenyuDubboClient&lt;/code> to the gateway after it is successfully started.&lt;/p>
&lt;p>Open &lt;code>Plugins List -&amp;gt; Proxy -&amp;gt; dubbo&lt;/code> to see the list of plugin rules configuration.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/dubbo-service-list-en.png" alt="img">&lt;/p>
&lt;p>Information on the selectors for successful registration.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/dubbo-selector-en.png" alt="img">&lt;/p>
&lt;p>Information on the rules for successful registration.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/dubbo-rule-en.png" alt="img">&lt;/p>
&lt;blockquote>
&lt;p>Selectors and rules are the soul of the &lt;code>Apache ShenYu&lt;/code> gateway. Mastering it well, you can manage any traffic. Corresponding to the matching conditions (conditions) inside the selectors and rules, we can handle various complex scenarios according to different traffic filtering rules. Traffic filtering can get data from &lt;code>Header&lt;/code>, &lt;code>URI&lt;/code>, &lt;code>Query&lt;/code>, &lt;code>Cookie&lt;/code> and so on Http requests.&lt;/p>
&lt;p>Then you can use &lt;code>Match&lt;/code>, &lt;code>=&lt;/code>, &lt;code>Regex&lt;/code>, &lt;code>Groovy&lt;/code>, &lt;code>Exclude&lt;/code> and other matching methods to match the data you expect. Multi-group match additions can use the &lt;code>And/Or&lt;/code> matching strategy.&lt;/p>
&lt;p>See: &lt;code>[Selector and Rule Management](https://shenyu.apache.org/docs/user-guide/admin-usage/selector-and-rule)&lt;/code> for details and usage.&lt;/p>
&lt;/blockquote>
&lt;p>Initiate a &lt;code>GET&lt;/code> request to invoke the &lt;code>dubbo&lt;/code> service through the &lt;code>ShenYu&lt;/code> gateway.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>GET http://localhost:9195/dubbo/findById?id=100
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Accept: application/json
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>After a successful response, the result is as follows.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;#34;name&amp;#34;: &amp;#34;hello world shenyu Apache, findById&amp;#34;,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;#34;id&amp;#34;: &amp;#34;100&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>At this point, you can successfully access the &lt;code>dubbo&lt;/code> service via &lt;code>http&lt;/code> requests. The &lt;code>ShenYu&lt;/code> gateway converts the &lt;code>http&lt;/code> protocol to the &lt;code>dubbo&lt;/code> protocol via the &lt;code>shenyu-plugin-dubbo&lt;/code> module.&lt;/p>
&lt;h2 id="3-understanding-of-dubbo-plugin">3. Understanding of Dubbo plugin&lt;/h2>
&lt;p>During the process of running the above &lt;code>demo&lt;/code>, are there any questions about&lt;/p>
&lt;ul>
&lt;li>How does the &lt;code>dubbo&lt;/code> service register with &lt;code>shenyu-admin&lt;/code>?&lt;/li>
&lt;li>How does &lt;code>shenyu-admin&lt;/code> synchronize data to the &lt;code>ShenYu&lt;/code> gateway?&lt;/li>
&lt;li>How does the &lt;code>DubboPlugin&lt;/code> convert the &lt;code>http&lt;/code> protocol to the &lt;code>dubbo&lt;/code> protocol?&lt;/li>
&lt;/ul>
&lt;p>With these questions in mind, let&amp;rsquo;s dive into understanding the &lt;code>dubbo&lt;/code> plugin.&lt;/p>
&lt;h3 id="31-application-client-access">3.1 Application Client Access&lt;/h3>
&lt;p>Application client access refers to accessing microservices to the &lt;code>Apache ShenYu&lt;/code> gateway, which currently supports access to &lt;code>Http&lt;/code>, &lt;code>Dubbo&lt;/code>, &lt;code>Spring Cloud&lt;/code>, &lt;code>gRPC&lt;/code>, &lt;code>Motan&lt;/code>, &lt;code>Sofa&lt;/code>, &lt;code>Tars&lt;/code> and other protocols.&lt;/p>
&lt;p>Accessing application clients to the &lt;code>Apache ShenYu&lt;/code> gateway is achieved through the registry, which involves client-side registration and server-side synchronization of data. The registry supports &lt;code>Http&lt;/code>, &lt;code>Zookeeper&lt;/code>, &lt;code>Etcd&lt;/code>, &lt;code>Consul&lt;/code> and &lt;code>Nacos&lt;/code>. The default is to register by &lt;code>Http&lt;/code>.&lt;/p>
&lt;p>Please refer to &lt;code>[Client Access Configuration](https://shenyu.apache.org/docs/user-guide/register-center-access)&lt;/code> for client access related configuration.&lt;/p>
&lt;h4 id="311-client-side-registration">3.1.1 Client-side Registration&lt;/h4>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/register-client.png" alt="img">&lt;/p>
&lt;p>Declare the registry client type, such as &lt;code>Http&lt;/code> or &lt;code>Zookeeper&lt;/code>, in your microservice configuration.
Load and initialize the corresponding registry client using the &lt;code>SPI&lt;/code> method when the application starts, and get the service interface information that needs to be registered in it by implementing the post-processor interface related to the &lt;code>Spring Bean&lt;/code>, and put the obtained information into the &lt;code>Disruptor&lt;/code>.&lt;/p>
&lt;p>The registry client reads the data from &lt;code>Disruptor&lt;/code> and registers the interface information to &lt;code>shenyu-admin&lt;/code>, where &lt;code>Disruptor&lt;/code> plays the role of decoupling data and operations, which is convenient for extension.&lt;/p>
&lt;h4 id="312-server-side-registration">3.1.2 Server-side Registration&lt;/h4>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/register-server.png" alt="img">&lt;/p>
&lt;p>Declare the registry server type, such as &lt;code>Http&lt;/code> or &lt;code>Zookeeper&lt;/code>, in the &lt;code>shenyu-admin&lt;/code> configuration. When &lt;code>shenyu-admin&lt;/code> starts, it will read the configuration type, load and initialize the corresponding registry server, and when the registry server receives the interface information registered by &lt;code>shenyu-client&lt;/code>, it will put it into &lt;code>Disruptor&lt;/code>, and then it will trigger the registration processing logic to update the service interface information and publish the synchronization event.&lt;/p>
&lt;p>The &lt;code>Disruptor&lt;/code> plays a role in decoupling data and operation, which is good for extension. It also has a data buffering role if too many registration requests lead to registration exceptions.&lt;/p>
&lt;h3 id="32-data-synchronization-principle">3.2 Data Synchronization Principle&lt;/h3>
&lt;p>Data synchronization refers to the policy used to synchronize data to the &lt;code>Apache ShenYu&lt;/code> gateway after the &lt;code>shenyu-admin&lt;/code> backend has manipulated the data. The &lt;code>Apache ShenYu&lt;/code> gateway currently supports &lt;code>ZooKeeper&lt;/code>, &lt;code>WebSocket&lt;/code>, &lt;code>Http long polling&lt;/code>, &lt;code>Nacos&lt;/code>, &lt;code>Etcd&lt;/code> and &lt;code>Consul&lt;/code> for data synchronization. The default is to synchronize data via &lt;code>WebSocket&lt;/code>.&lt;/p>
&lt;p>Please refer to &lt;code>[Data Synchronization Configuration](https://shenyu.apache.org/docs/user-guide/use-data-sync)&lt;/code> for the configuration of data synchronization.&lt;/p>
&lt;h4 id="321-the-significance-of-data-synchronization">3.2.1 The Significance of Data Synchronization&lt;/h4>
&lt;p>The gateway is the entry point for traffic requests and plays a very important role in the microservices architecture, and the importance of high availability of the gateway is self-evident. In the process of using the gateway, in order to meet the business requirements, it is often necessary to change the configuration, such as flow control rules, routing rules and so on. Therefore, the dynamic configuration of the gateway is an important factor to ensure the high availability of the gateway.&lt;/p>
&lt;p>The current data synchronization characteristics are as follows.&lt;/p>
&lt;ul>
&lt;li>All configurations are cached in the &lt;code>Apache ShenYu&lt;/code> gateway memory, and each request uses the local cache, which is very fast.&lt;/li>
&lt;li>Users can change any data in the &lt;code>shenyu-admin&lt;/code> backend and it will be synchronized to the gateway memory immediately.&lt;/li>
&lt;li>Supports data synchronization of plugins, selectors, rule data, metadata, signature data, etc. for &lt;code>Apache ShenYu&lt;/code>.&lt;/li>
&lt;li>All plug-in selectors and rules are dynamically configured and take effect immediately, without restarting the service.&lt;/li>
&lt;li>Data synchronization method supports &lt;code>Zookeeper&lt;/code>, &lt;code>Http long polling&lt;/code>, &lt;code>Websocket&lt;/code>, &lt;code>Nacos&lt;/code>, &lt;code>Etcd&lt;/code> and &lt;code>Consul&lt;/code>.&lt;/li>
&lt;/ul>
&lt;h4 id="322-data-synchronization-principle-analysis">3.2.2 Data Synchronization Principle Analysis&lt;/h4>
&lt;p>The following diagram shows the flow of &lt;code>Apache ShenYu&lt;/code> data synchronization. The &lt;code>Apache ShenYu&lt;/code> gateway synchronizes configuration data from the configuration service when it starts, and supports push-pull mode to get configuration change information and then update the local cache. Administrators can change user permissions, rules, plugins, traffic configuration in the administration backend (&lt;code>shenyu-admin&lt;/code>) and synchronize the changes to the &lt;code>Apache ShenYu&lt;/code> gateway via push-pull mode, depending on which synchronization method is used.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/data-sync.png" alt="img">&lt;/p>
&lt;p>In the original version, the configuration service relied on the &lt;code>Zookeeper&lt;/code> implementation, and the management backend &lt;code>pushed&lt;/code> the changes to the gateway. Now we can support &lt;code>WebSocket&lt;/code>, &lt;code>Http long polling&lt;/code>, &lt;code>Zookeeper&lt;/code>, &lt;code>Nacos&lt;/code>, &lt;code>Etcd&lt;/code> and &lt;code>Consul&lt;/code>, by setting &lt;code>shenyu.sync.${strategy}&lt;/code> in the configuration file to specify the corresponding synchronization strategy, the default is to use &lt;code>webosocket&lt;/code> synchronization strategy to achieve second-level data synchronization. However, one thing to note is that the &lt;code>Apache ShenYu&lt;/code> gateway and &lt;code>shenyu-admin&lt;/code> must use the same synchronization strategy.&lt;/p>
&lt;p>As shown in the figure below, &lt;code>shenyu-admin&lt;/code> sends out configuration change notifications through &lt;code>EventPublisher&lt;/code> after a user makes a configuration change, and &lt;code>EventDispatcher&lt;/code> processes the change notification, and then synchronizes the data according to the configured synchronization policy (&lt;code>http, weboscket, zookeeper, naocs, etcd, consul&lt;/code>). etcd, consul`), the configuration is sent to the corresponding event handler.&lt;/p>
&lt;ul>
&lt;li>If it is a &lt;code>websocket&lt;/code> synchronization policy, the changed data will be actively pushed to &lt;code>shenyu-web&lt;/code> and there will be a corresponding &lt;code>WebsocketDataHandler&lt;/code> processor at the gateway layer to handle the data push from &lt;code>shenyu-admin&lt;/code>.&lt;/li>
&lt;li>In case of &lt;code>zookeeper&lt;/code> synchronization policy, the change data will be updated to &lt;code>zookeeper&lt;/code>, and &lt;code>ZookeeperSyncCache&lt;/code> will listen to &lt;code>zookeeper&lt;/code> data changes and process them.&lt;/li>
&lt;li>In case of &lt;code>http&lt;/code> synchronization policy, the gateway initiates a long polling request with &lt;code>90s&lt;/code> timeout by default, if &lt;code>shenyu-admin&lt;/code> has no data change, it will block the &lt;code>http&lt;/code> request, if there is data change, it will respond with the changed data information, if more than &lt;code>60s&lt;/code> there is still no data change, it will respond with empty data, after the gateway layer receives the response After receiving the response, the gateway layer continues to make &lt;code>http&lt;/code> requests, repeating the same requests.&lt;/li>
&lt;/ul>
&lt;h3 id="33-process-analysis">3.3 Process Analysis&lt;/h3>
&lt;p>The process analysis shows the service registration process, data synchronization process and service invocation process from the source code perspective.&lt;/p>
&lt;h4 id="331-service-registration-process">3.3.1 Service Registration Process&lt;/h4>
&lt;ul>
&lt;li>Reading dubbo services&lt;/li>
&lt;/ul>
&lt;p>Use the annotation &lt;code>@ShenyuDubboClient&lt;/code> to mark &lt;code>dubbo&lt;/code> services that need to be registered to the gateway.&lt;/p>
&lt;p>Annotation scanning is done via the &lt;code>ApacheDubboServiceBeanListener&lt;/code>, which implements the &lt;code>ApplicationListener&amp;lt;ContextRefreshedEvent&amp;gt;&lt;/code> interface and starts executing the event handler method when a context refresh event occurs during the &lt;code>Spring&lt;/code> container startup &lt;code>onApplicationEvent()&lt;/code>. In the rewritten method logic, the &lt;code>Dubbo&lt;/code> service &lt;code>ServiceBean&lt;/code> is read, the metadata object and the &lt;code>URI&lt;/code> object are constructed and registered with &lt;code>shenyu-admin&lt;/code>.&lt;/p>
&lt;p>The specific registration logic is implemented by the registry, please refer to &lt;code>[Client Access Principles](https://shenyu.apache.org/docs/design/register-center-design/)&lt;/code> .&lt;/p>
&lt;ul>
&lt;li>Processing registration information&lt;/li>
&lt;/ul>
&lt;p>The metadata and &lt;code>URI&lt;/code> data registered by the client through the registration center are processed at the &lt;code>shenyu-admin&lt;/code> end, which is responsible for storing to the database and synchronizing to the &lt;code>shenyu&lt;/code> gateway. The client-side registration processing logic of the &lt;code>Dubbo&lt;/code> plugin is in the &lt;code>ShenyuClientRegisterDubboServiceImpl&lt;/code>. The inheritance relationship is as follows.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/ShenyuClientRegisterDubboServiceImpl.png" alt="img">&lt;/p>
&lt;ul>
&lt;li>ShenyuClientRegisterService: client registration service, top-level interface.&lt;/li>
&lt;li>FallbackShenyuClientRegisterService: registration failure, provides retry operation.&lt;/li>
&lt;li>AbstractShenyuClientRegisterServiceImpl: abstract class, implements part of the public registration logic.&lt;/li>
&lt;li>ShenyuClientRegisterDubboServiceImpl: implements the registration of &lt;code>Dubbo&lt;/code> plug-ins.&lt;/li>
&lt;/ul>
&lt;p>Registration information including selectors, rules and metadata.&lt;/p>
&lt;p>The overall &lt;code>dubbo&lt;/code> service registration process is as follows.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/dubbo-register-en.png" alt="img">&lt;/p>
&lt;h4 id="332-data-synchronization-process">3.3.2 Data Synchronization Process&lt;/h4>
&lt;ul>
&lt;li>admin update data&lt;/li>
&lt;/ul>
&lt;p>Suppose in the backend management system, a new selector data is added, the request goes to the &lt;code>createSelector()&lt;/code> method in the &lt;code>SelectorController&lt;/code> class, which is responsible for verifying the data, adding or updating the data, and returning the result information.&lt;/p>
&lt;p>In the &lt;code>SelectorServiceImpl&lt;/code> class, the &lt;code>createOrUpdate()&lt;/code> method completes the conversion of the data, saves it to the database, publishes events, and updates the &lt;code>upstream&lt;/code>.&lt;/p>
&lt;p>Persistence of data is done in the &lt;code>Service&lt;/code> class, i.e. saving data to the database. Publishing the changed data is done by &lt;code>eventPublisher.publishEvent()&lt;/code>, the &lt;code>eventPublisher&lt;/code> object is an &lt;code>ApplicationEventPublisher&lt;/code> class, the fully qualified name of this class is &lt;code>org.springframework. ApplicationEventPublisher&lt;/code>, the function of publishing data is exactly what is done through &lt;code>Spring&lt;/code> related functions.&lt;/p>
&lt;p>When the event is published, it automatically goes to the &lt;code>onApplicationEvent()&lt;/code> method in the &lt;code>DataChangedEventDispatcher&lt;/code> class, which handles the event according to the different data types and data synchronization methods.&lt;/p>
&lt;ul>
&lt;li>Gateway data synchronization&lt;/li>
&lt;/ul>
&lt;p>At startup, the gateway loads different configuration classes and initializes data synchronization-related classes according to the specified data synchronization method.&lt;/p>
&lt;p>After receiving the data, it performs deserialization operation to read the data type and operation type. Different data types have different data processing methods, so there are different implementation classes. But they also have the same processing logic between them, so they can be implemented by template method design pattern. The same logic is put in the &lt;code>handle()&lt;/code> method in the abstract class &lt;code>AbstractDataHandler&lt;/code>, and the different logic is given to the respective implementation classes.&lt;/p>
&lt;p>Adding a new selector data is a new operation that goes to the &lt;code>SelectorDataHandler.doUpdate()&lt;/code> concrete data processing logic.&lt;/p>
&lt;p>In the common plugin data subscriber &lt;code>CommonPluginDataSubscriber&lt;/code>, which is responsible for handling all plugin, selector and rule information&lt;/p>
&lt;p>Saves data to the gateway&amp;rsquo;s memory, &lt;code>BaseDataCache&lt;/code> is the class that ultimately caches the data, implemented through the singleton pattern. The selector data is then stored in &lt;code>SELECTOR_MAP&lt;/code>, a &lt;code>Map&lt;/code>. In the subsequent use, the data is also taken from here.&lt;/p>
&lt;p>The above logic is represented in a flowchart as follows.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/data-sync-seq-en.png" alt="img">&lt;/p>
&lt;h4 id="333-service-invocation-process">3.3.3 Service Invocation Process&lt;/h4>
&lt;p>In the &lt;code>Dubbo&lt;/code> plugin system, the class extends relationship is as follows.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/ApacheDubboPlugin.png" alt="img">&lt;/p>
&lt;blockquote>
&lt;p>ShenyuPlugin: top-level interface, defining interface methods.&lt;/p>
&lt;p>AbstractShenyuPlugin: abstract class that implements the common logic of the plugin; &amp;gt; AbstractShenyuPlugin: abstract class that implements the common logic of the plugin.&lt;/p>
&lt;p>AbstractDubboPlugin: dubbo plug-in abstract class, implementing &lt;code>dubbo&lt;/code> common logic (ShenYu gateway supports ApacheDubbo and AlibabaDubbo).&lt;/p>
&lt;p>ApacheDubboPlugin: ApacheDubbo plugin.&lt;/p>
&lt;/blockquote>
&lt;ul>
&lt;li>org.apache.shenyu.web.handler.ShenyuWebHandler.DefaultShenyuPluginChain#execute()&lt;/li>
&lt;/ul>
&lt;p>After passing the &lt;code>ShenYu&lt;/code> gateway proxy, the request entry is &lt;code>ShenyuWebHandler&lt;/code>, which implements the &lt;code>org.springframework.web.server.WebHandler&lt;/code> interface and connects all plugins through the chain-of-responsibility design pattern.&lt;/p>
&lt;ul>
&lt;li>org.apache.shenyu.plugin.base.AbstractShenyuPlugin#execute()&lt;/li>
&lt;/ul>
&lt;p>Determining whether a plugin is executed when a request is made to the gateway is done by the specified matching logic. The matching logic for selectors and rules is executed in the &lt;code>execute()&lt;/code> method.&lt;/p>
&lt;ul>
&lt;li>org.apache.shenyu.plugin.global.GlobalPlugin#execute()&lt;/li>
&lt;/ul>
&lt;p>The first to be executed is the &lt;code>GlobalPlugin&lt;/code> , which is a global plugin that constructs contextual information in the &lt;code>execute()&lt;/code> method.&lt;/p>
&lt;ul>
&lt;li>org.apache.shenyu.plugin.base.RpcParamTransformPlugin#execute()&lt;/li>
&lt;/ul>
&lt;p>Next to be executed is the &lt;code>RpcParamTransformPlugin&lt;/code>, which is responsible for reading the parameters from the &lt;code>http&lt;/code> request, saving them in the &lt;code>exchange&lt;/code> and passing them to the &lt;code>rpc&lt;/code> service. In the &lt;code>execute()&lt;/code> method, the core logic of the plugin is executed: it gets the request information from &lt;code>exchange&lt;/code> and processes the parameters according to the form of the content passed in the request.&lt;/p>
&lt;ul>
&lt;li>org.apache.shenyu.plugin.dubbo.common.AbstractDubboPlugin&lt;/li>
&lt;/ul>
&lt;p>Then what gets executed is the &lt;code>DubboPlugin&lt;/code> . In the &lt;code>doExecute()&lt;/code> method, the main focus is on checking metadata and parameters. In the &lt;code>doDubboInvoker()&lt;/code> method, special context information is set and then the generalized invocation of &lt;code>dubbo&lt;/code> is started.&lt;/p>
&lt;p>In the &lt;code>genericInvoker()&lt;/code> method.&lt;/p>
&lt;ul>
&lt;li>Gets the &lt;code>ReferenceConfig&lt;/code> object.&lt;/li>
&lt;li>obtains the generalization service &lt;code>GenericService&lt;/code> object.&lt;/li>
&lt;li>Constructs the request parameter &lt;code>pair&lt;/code> object.&lt;/li>
&lt;li>Initiate an asynchronous generalization invocation.&lt;/li>
&lt;/ul>
&lt;p>The generalization call enables you to call the &lt;code>dubbo&lt;/code> service at the gateway.&lt;/p>
&lt;p>The &lt;code>ReferenceConfig&lt;/code> object is the key object that supports generalization calls, and its initialization is done during data synchronization.&lt;/p>
&lt;ul>
&lt;li>org.apache.shenyu.plugin.response.ResponsePlugin#execute()&lt;/li>
&lt;/ul>
&lt;p>The last one to be executed is &lt;code>ResponsePlugin&lt;/code>, which unifies the response result messages of the gateway. The processing type is determined by the &lt;code>MessageWriter&lt;/code>, and the class extends relationship is as follows.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/MessageWriter.png" alt="img">&lt;/p>
&lt;blockquote>
&lt;p>MessageWriter: interface that defines message processing methods.&lt;/p>
&lt;p>NettyClientMessageWriter: Handles the results of &lt;code>Netty&lt;/code> calls.&lt;/p>
&lt;p>RPCMessageWriter: processing the results of &lt;code>RPC&lt;/code> calls.&lt;/p>
&lt;p>WebClientMessageWriter: processing the results of &lt;code>WebClient&lt;/code> calls;&lt;/p>
&lt;/blockquote>
&lt;p>The &lt;code>Dubbo&lt;/code> service is called and the result of processing is the &lt;code>RPCMessageWriter&lt;/code>.&lt;/p>
&lt;ul>
&lt;li>org.apache.shenyu.plugin.response.strategy.RPCMessageWriter#writeWith()&lt;/li>
&lt;/ul>
&lt;p>Process the response results in the &lt;code>writeWith()&lt;/code> method, get the results or handle exceptions.&lt;/p>
&lt;p>At this point in the analysis, the source code analysis of the &lt;code>Dubbo&lt;/code> plugin is complete, and the analysis flowchart is as follows.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/shenyu-dubbo/dubbo-execute-en.png" alt="img">&lt;/p>
&lt;h2 id="4-summary">4. Summary&lt;/h2>
&lt;p>This article analyzes the proxy process of &lt;code>ShenYu&lt;/code> gateway to Dubbo service from a practical case. The main knowledge points involved are as follows.&lt;/p>
&lt;ul>
&lt;li>Implementing plug-ins through the chain-of-responsibility design pattern.&lt;/li>
&lt;li>implementing &lt;code>AbstractShenyuPlugin&lt;/code> using the template method design pattern to handle generic operation types.&lt;/li>
&lt;li>implementation of the cached data class &lt;code>BaseDataCache&lt;/code> using the singleton design pattern.&lt;/li>
&lt;li>the ability to introduce different registries and number synchronization methods through the &lt;code>springboot starter&lt;/code>, which is very scalable.&lt;/li>
&lt;li>support for hot updates of rules through &lt;code>admin&lt;/code> to facilitate traffic control.&lt;/li>
&lt;li>&lt;code>Disruptor&lt;/code> queue is for data and operation decoupling, as well as data buffering.&lt;/li>
&lt;/ul></description></item><item><title>Blog: Makes it More Convenient for You to Proxy Dubbo Services in Apache APISIX</title><link>https://dubbo.apache.org/en/blog/2022/01/18/makes-it-more-convenient-for-you-to-proxy-dubbo-services-in-apache-apisix/</link><pubDate>Tue, 18 Jan 2022 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2022/01/18/makes-it-more-convenient-for-you-to-proxy-dubbo-services-in-apache-apisix/</guid><description>
&lt;h2 id="background">Background&lt;/h2>
&lt;p>&lt;a href="https://dubbo.apache.org/en/">Apache Dubbo&lt;/a> is a MicroService development framework open sourced by Alibaba and donated to Apache, which provides two key capabilities of RPC communication and microservice governance. It has not only been validated by Ali&amp;rsquo;s massive traffic in e-commerce scenario, but also been widely implemented in domestic technology companies.&lt;/p>
&lt;p>In practical application scenarios, Apache Dubbo is generally used as the implementation framework for RPC calls between back-end systems, and when HTTP interfaces need to be provided to the front-end, the Dubbo Service is packaged as an HTTP interface through a &amp;ldquo;glue layer&amp;rdquo; and then delivered to the front-end system.&lt;/p>
&lt;p>&lt;a href="https://apisix.apache.org/">Apache APISIX&lt;/a> is the top open source project of Apache Software Foundation and the most active open source gateway project today. As a dynamic, real-time, high-performance open source API gateway, Apache APISIX provides rich traffic management features such as load balancing, dynamic upstream, grayscale publishing, service meltdown, authentication, observability, and more.&lt;/p>
&lt;p>Benefiting from the advantages of Apache Dubbo application scenarios, Apache APISIX is based on the open source project tengine/mod_dubbo module to equip Apache Dubbo services with HTTP gateway capabilities. Dubbo Service can be easily published as an HTTP service via the dubbo-proxy plugin.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/apisix-plugin/1.png" alt="Architecture Diagram">&lt;/p>
&lt;h2 id="how-to-use">How to use&lt;/h2>
&lt;h3 id="getting-started-installation-and-use">Getting Started: Installation and Use&lt;/h3>
&lt;blockquote>
&lt;p>Here we recommend using the Apache APISIX version 2.11 image for installation. This version of APISIX-Base has the Dubbo module compiled by default, so you can use the &lt;code>dubbo-proxy&lt;/code> plugin directly.&lt;/p>
&lt;/blockquote>
&lt;p>In the next steps, we will use the &lt;a href="https://github.com/apache/dubbo-samples">&lt;code>dubbo-samples&lt;/code>&lt;/a> project for a partial demonstration. This project is a demo application implemented using Apache Dubbo, and in this article we use one of the sub-modules as the Dubbo Provider.&lt;/p>
&lt;p>Before we get into the action, let&amp;rsquo;s take a brief look at the definition, configuration, and implementation of the Dubbo interface.&lt;/p>
&lt;h4 id="interface-implementation">Interface implementation&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">DemoService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * standard samples dubbo infterace demo
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * @param context pass http infos
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * @return Map&amp;lt;String, Object&amp;gt;&amp;lt;/&amp;gt; pass to response http
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> **/&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Object&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">apisixDubbo&lt;/span>(Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Object&lt;span style="color:#719e07">&amp;gt;&lt;/span> httpRequestContext);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>As shown above, the Dubbo interface is defined in a fixed way. The &lt;code>Map&lt;/code> of method parameters represents the information passed by APISIX to the Dubbo Provider about the HTTP request (e.g. header, body, &amp;hellip;). The &lt;code>Map&lt;/code> of the method return value indicates how the Dubbo Provider passes some information to APISIX about the HTTP response to be returned.&lt;/p>
&lt;p>After the interface information, the DemoService can be published via XML configuration.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">&amp;lt;!-- service implementation, as same as regular local bean --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;bean&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;demoService&amp;#34;&lt;/span> class=&lt;span style="color:#2aa198">&amp;#34;org.apache.dubbo.samples.provider.DemoServiceImpl&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">&amp;lt;!-- declare the service interface to be exported --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:service&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;org.apache.dubbo.samples.apisix.DemoService&amp;#34;&lt;/span> ref=&lt;span style="color:#2aa198">&amp;#34;demoService&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>After the above configuration, the Consumer can access the &lt;code>apisixDubbo&lt;/code> method through &lt;code>org.apache.dubbo.samples.apisix.DemoService&lt;/code> The specific interface implementation is as follows.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DemoServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> DemoService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Object&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">apisixDubbo&lt;/span>(Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Object&lt;span style="color:#719e07">&amp;gt;&lt;/span> httpRequestContext) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (Map.Entry&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Object&lt;span style="color:#719e07">&amp;gt;&lt;/span> entry : httpRequestContext.entrySet()) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;Key = &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> entry.getKey() &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#34;, Value = &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> entry.getValue());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Object&lt;span style="color:#719e07">&amp;gt;&lt;/span> ret &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> HashMap&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Object&lt;span style="color:#719e07">&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ret.put(&lt;span style="color:#2aa198">&amp;#34;body&amp;#34;&lt;/span>, &lt;span style="color:#2aa198">&amp;#34;dubbo success\n&amp;#34;&lt;/span>); &lt;span style="color:#586e75">// http response body&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ret.put(&lt;span style="color:#2aa198">&amp;#34;status&amp;#34;&lt;/span>, &lt;span style="color:#2aa198">&amp;#34;200&amp;#34;&lt;/span>); &lt;span style="color:#586e75">// http response status&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ret.put(&lt;span style="color:#2aa198">&amp;#34;test&amp;#34;&lt;/span>, &lt;span style="color:#2aa198">&amp;#34;123&amp;#34;&lt;/span>); &lt;span style="color:#586e75">// http response header&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> ret;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>:::note
In the above code, &lt;code>DemoServiceImpl&lt;/code> prints the received &lt;code>httpRequestContext&lt;/code> and describes the HTTP response to the Dubbo request by returning a Map object with the specified Key.
:::&lt;/p>
&lt;h4 id="operation-steps">Operation steps&lt;/h4>
&lt;ol>
&lt;li>Start &lt;a href="https://github.com/apache/dubbo-samples/tree/master/2-advanced/dubbo-samples-tengine#install-dubbo">&lt;code>dubbo-samples&lt;/code>&lt;/a>.&lt;/li>
&lt;li>Enable the &lt;code>dubbo-proxy&lt;/code> plugin in the &lt;code>config.yaml&lt;/code> file.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"># Add this in config.yaml&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">plugins&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - ... &lt;span style="color:#586e75"># plugin you need&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - dubbo-proxy
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="3">
&lt;li>Create an Upstream that points to the Dubbo Provider.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>curl http://127.0.0.1:9180/apisix/admin/upstreams/1 -H &lt;span style="color:#2aa198">&amp;#39;X-API-KEY: edd1c9f034335f136f87ad84b625c8f1&amp;#39;&lt;/span> -X PUT -d &lt;span style="color:#2aa198">&amp;#39;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">{
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;nodes&amp;#34;: {
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;127.0.0.1:20880&amp;#34;: 1
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> },
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;type&amp;#34;: &amp;#34;roundrobin&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">}&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="4">
&lt;li>Expose an HTTP route for the DemoService.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>curl http://127.0.0.1:9180/apisix/admin/routes/1 -H &lt;span style="color:#2aa198">&amp;#39;X-API-KEY: edd1c9f034335f136f87ad84b625c8f1&amp;#39;&lt;/span> -X PUT -d &lt;span style="color:#2aa198">&amp;#39;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">{
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;host&amp;#34;: &amp;#34;example.org&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;uris&amp;#34;: [
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;/demo&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> ],
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;plugins&amp;#34;: {
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;dubbo-proxy&amp;#34;: {
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;service_name&amp;#34;: &amp;#34;org.apache.dubbo.samples.apisix.DemoService&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;service_version&amp;#34;: &amp;#34;0.0.0&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;method&amp;#34;: &amp;#34;apisixDubbo&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> }
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> },
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;upstream_id&amp;#34;: 1
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">}&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="5">
&lt;li>Use the curl command to request Apache APISIX and view the returned results.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>curl http://127.0.0.1:9080/demo -H &lt;span style="color:#2aa198">&amp;#34;Host: example.org&amp;#34;&lt;/span> -X POST --data &lt;span style="color:#2aa198">&amp;#39;{&amp;#34;name&amp;#34;: &amp;#34;hello&amp;#34;}&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt; HTTP/1.1 &lt;span style="color:#2aa198">200&lt;/span> OK
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt; Date: Sun, &lt;span style="color:#2aa198">26&lt;/span> Dec &lt;span style="color:#2aa198">2021&lt;/span> 11:33:27 GMT
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt; Content-Type: text/plain; &lt;span style="color:#268bd2">charset&lt;/span>&lt;span style="color:#719e07">=&lt;/span>utf-8
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt; Content-Length: &lt;span style="color:#2aa198">14&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt; Connection: keep-alive
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt; test: &lt;span style="color:#2aa198">123&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt; Server: APISIX/2.11.0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo success
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>:::note
The above code returns the &lt;code>test: 123&lt;/code> Header, and the &lt;code>dubbo success&lt;/code> string as the body. This is the same as what we expected in the &lt;code>DemoServiceImpl&lt;/code> code.
:::&lt;/p>
&lt;ol start="6">
&lt;li>You can view the logs of the Dubbo Provider.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>Key = content-length, Value = 17
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Key = host, Value = example.org
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Key = content-type, Value = application/x-www-form-urlencoded
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Key = body, Value = [B@70754265
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Key = accept, Value = */*
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Key = user-agent, Value = curl/7.80.0
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>:::note
The Header and Body of the HTTP request are available through the &lt;code>httpRequestContext&lt;/code>, where the Header is used as a Map element, while the Body has a fixed string &amp;ldquo;body&amp;rdquo; as the Key value and a Byte array as the Value.
:::&lt;/p>
&lt;h3 id="advanced-complex-scenario-example">Advanced: Complex Scenario Example&lt;/h3>
&lt;p>As you can see in the simple use case above, we do publish Dubbo Service as an HTTP service via Apache APISIX, but there are obvious limitations in its use. For example, the parameters and return values of the interface must be &lt;code>Map&amp;lt;String, Object&amp;gt;&lt;/code>.&lt;/p>
&lt;p>So, how do you expose the HTTP service through Apache APISIX if there is an interface in your project that is already defined, but does not meet the above restrictions?&lt;/p>
&lt;h4 id="operation-steps-1">Operation steps&lt;/h4>
&lt;p>For the above scenario, we can use the HTTP Request Body to describe the Service and Method to be invoked and the corresponding parameters, and then use the reflection mechanism of Java to realize the invocation of the target method. Finally, the return value is serialized to JSON and written to the HTTP Response Body.&lt;/p>
&lt;p>This will further enhance the &amp;ldquo;HTTP to Dubbo&amp;rdquo; capability of Apache APISIX and apply it to all existing Dubbo services. For details, see the following.&lt;/p>
&lt;ol>
&lt;li>Add a Dubbo Service for existing projects to handle HTTP to Dubbo conversions in a unified way.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DubboInvocationParameter&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> String type;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> String value;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DubboInvocation&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> String service;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> String method;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> DubboInvocationParameter&lt;span style="color:#719e07">[]&lt;/span> parameters;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">HTTP2DubboService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Object&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">invoke&lt;/span>(Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Object&lt;span style="color:#719e07">&amp;gt;&lt;/span> context) &lt;span style="color:#268bd2">throws&lt;/span> Exception;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Component&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">HTTP2DubboServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> HTTP2DubboService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Autowired&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> ApplicationContext appContext;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Object&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">invoke&lt;/span>(Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Object&lt;span style="color:#719e07">&amp;gt;&lt;/span> context) &lt;span style="color:#268bd2">throws&lt;/span> Exception {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> DubboInvocation invocation &lt;span style="color:#719e07">=&lt;/span> JSONObject.parseObject((&lt;span style="color:#dc322f">byte&lt;/span>&lt;span style="color:#719e07">[]&lt;/span>) context.get(&lt;span style="color:#2aa198">&amp;#34;body&amp;#34;&lt;/span>), DubboInvocation.class);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Object&lt;span style="color:#719e07">[]&lt;/span> args &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> Object&lt;span style="color:#719e07">[&lt;/span>invocation.getParameters().size()&lt;span style="color:#719e07">]&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (&lt;span style="color:#dc322f">int&lt;/span> i &lt;span style="color:#719e07">=&lt;/span> 0; i &lt;span style="color:#719e07">&amp;lt;&lt;/span> args.length; i&lt;span style="color:#719e07">++&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> DubboInvocationParameter parameter &lt;span style="color:#719e07">=&lt;/span> invocation.getParameters().get(i);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> args&lt;span style="color:#719e07">[&lt;/span>i&lt;span style="color:#719e07">]&lt;/span> &lt;span style="color:#719e07">=&lt;/span> JSONObject.parseObject(parameter.getValue(), Class.forName(parameter.getType()));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Object svc &lt;span style="color:#719e07">=&lt;/span> appContext.getBean(Class.forName(invocation.getService()));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Object result &lt;span style="color:#719e07">=&lt;/span> svc.getClass().getMethod(invocation.getMethod()).invoke(args);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Object&lt;span style="color:#719e07">&amp;gt;&lt;/span> httpResponse &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> HashMap&lt;span style="color:#719e07">&amp;lt;&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> httpResponse.put(&lt;span style="color:#2aa198">&amp;#34;status&amp;#34;&lt;/span>, 200);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> httpResponse.put(&lt;span style="color:#2aa198">&amp;#34;body&amp;#34;&lt;/span>, JSONObject.toJSONString(result));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> httpResponse;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="2">
&lt;li>Initiate the relevant call with the following command request.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>curl http://127.0.0.1:9080/demo -H &lt;span style="color:#2aa198">&amp;#34;Host: example.org&amp;#34;&lt;/span> -X POST --data &lt;span style="color:#2aa198">&amp;#39;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">{
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;service&amp;#34;: &amp;#34;org.apache.dubbo.samples.apisix.DemoService&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;method&amp;#34;: &amp;#34;createUser&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;parameters&amp;#34;: [
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> {
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;type&amp;#34;: &amp;#34;org.apache.dubbo.samples.apisix.User&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> &amp;#34;value&amp;#34;: &amp;#34;{&amp;#39;&lt;/span>name&lt;span style="color:#2aa198">&amp;#39;: &amp;#39;&lt;/span>hello&lt;span style="color:#2aa198">&amp;#39;}&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> }
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> ]
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">}&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="summary">Summary&lt;/h2>
&lt;p>In this article, we introduced how to use Apache APISIX to implement a proxy for Dubbo Service. By introducing the &lt;code>dubbo-proxy&lt;/code> plugin, you can build a simpler and more efficient traffic link for the back-end system of Dubbo framework.&lt;/p>
&lt;p>We hope that the above steps and use cases will provide you with ideas for using it in relevant scenarios. For more information about the &lt;code>dubbo-proxy&lt;/code> plugin, please refer to the &lt;a href="https://apisix.apache.org/docs/apisix/plugins/dubbo-proxy/">official documentation&lt;/a>.&lt;/p></description></item><item><title>Blog: 2.7.14 Release Note</title><link>https://dubbo.apache.org/en/blog/2021/09/20/2.7.14-release-note/</link><pubDate>Mon, 20 Sep 2021 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2021/09/20/2.7.14-release-note/</guid><description>
&lt;h2 id="change-lists">Change Lists&lt;/h2>
&lt;ul>
&lt;li>add Dynamic Configuration Override Support For ServiceDiscovery. (#8389)&lt;/li>
&lt;li>fix mock parameters doesn&amp;rsquo;t work when it contain &amp;lsquo;:&amp;rsquo; or &amp;lsquo;=&amp;rsquo;. (#8379)&lt;/li>
&lt;li>fix the issue of taking the zone parameter value in ZoneAwareClusterInvoker. (#8521)&lt;/li>
&lt;li>add the switch for check class is in serialize white list , default is true. (#8537)&lt;/li>
&lt;li>fix NPE on serialization checking when request timed out. (#8587)&lt;/li>
&lt;li>fix NetUtils.ignoreNetworkInterface can&amp;rsquo;t process network card name contains &amp;lsquo;(&amp;rsquo; symbol. (#8629)&lt;/li>
&lt;li>unify the way of getting local address. (#8679)&lt;/li>
&lt;li>fix retries param didn&amp;rsquo;t work well when it is 0. (#8743)&lt;/li>
&lt;li>close client immediately when destroy unused invoker. (#8756)&lt;/li>
&lt;li>fix destroy IllegalStateException and doOverrideIfNecessary NPE. (#8683)&lt;/li>
&lt;li>show message according to log level when DefaultFuture.closeChannel. (#8778)&lt;/li>
&lt;li>use MapUtils instead of AttachmentsAdapter. (#8772)&lt;/li>
&lt;/ul>
&lt;h2 id="dependency-changes">Dependency Changes&lt;/h2>
&lt;ul>
&lt;li>netty4: 4.1.51.Final -&amp;gt; 4.1.66.Final&lt;/li>
&lt;li>netty4_ssl: 2.0.39.Final -&amp;gt; 2.0.40.Final&lt;/li>
&lt;li>http_client: 4.5.3 -&amp;gt; 4.5.13&lt;/li>
&lt;li>jetty: 9.4.11.v20180605 -&amp;gt; 9.4.43.v20210629&lt;/li>
&lt;li>apollo_client: 1.1.1 -&amp;gt; 1.8.0&lt;/li>
&lt;li>tomcat_embed: 8.5.31-&amp;gt; 9.0.48&lt;/li>
&lt;li>commons_io: 2.6 -&amp;gt; 2.7&lt;/li>
&lt;li>curator: 5.0.0 -&amp;gt; 5.1.0&lt;/li>
&lt;li>hessian_lite: 3.2.8 -&amp;gt; 3.2.11&lt;/li>
&lt;/ul></description></item><item><title>Blog: 3.0.2.1 Release Note</title><link>https://dubbo.apache.org/en/blog/2021/08/23/3.0.2.1-release-note/</link><pubDate>Mon, 23 Aug 2021 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2021/08/23/3.0.2.1-release-note/</guid><description>
&lt;p>This is a bugfix version of 3.0.2.
Exactly the same as version 3.0.2, except for the following changes.&lt;/p>
&lt;h2 id="bugfix">Bugfix&lt;/h2>
&lt;ul>
&lt;li>Fix nacos group inviable in consumer side (#8533)&lt;/li>
&lt;li>Fix NPE on serialization checking when request timed out (#8547)&lt;/li>
&lt;li>Compact with dubbo-all without farbic-io (#8546)&lt;/li>
&lt;/ul></description></item><item><title>Blog: 3.0.2 Release Note</title><link>https://dubbo.apache.org/en/blog/2021/08/18/3.0.2-release-note/</link><pubDate>Wed, 18 Aug 2021 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2021/08/18/3.0.2-release-note/</guid><description>
&lt;h2 id="features">Features&lt;/h2>
&lt;ul>
&lt;li>improve generic service with @DubboService annotation.&lt;/li>
&lt;li>metadata report config support xml to config protocol and port.&lt;/li>
&lt;li>compatible for curator5.&lt;/li>
&lt;li>p2p invoke support wildcard url match.&lt;/li>
&lt;li>add Dynamic Configuration Override Support For ServiceDiscovery.&lt;/li>
&lt;li>add provider configuration override disable option.&lt;/li>
&lt;li>support native image.&lt;/li>
&lt;li>support disable shutdown hook.&lt;/li>
&lt;li>add Kubernetes Mesh Rule support.&lt;/li>
&lt;li>support SSL at netty transport.&lt;/li>
&lt;/ul>
&lt;h2 id="bugfixs">BugFixs&lt;/h2>
&lt;ul>
&lt;li>fix re-start override dynamic config.&lt;/li>
&lt;li>fix delete configurators does not take effect.&lt;/li>
&lt;li>fix triple protocol will throw exception when the service is exposed.&lt;/li>
&lt;li>fix ConfigCenterConfig.setAddress will override username problem.&lt;/li>
&lt;li>fix DefaultFuture.closeChannel will shutdown ExecutorService.&lt;/li>
&lt;li>fix TripleClientHandler#writeRequest throwing NPE problem.&lt;/li>
&lt;li>fix NPE when parse migration rule error happen.&lt;/li>
&lt;li>fix Activated Extensions order.&lt;/li>
&lt;li>fix URLAddress#parse method to judge the isPathAddress problem when the address is ipv6.&lt;/li>
&lt;li>fix custom parameter in configuration properties does not work.&lt;/li>
&lt;li>fix Config id Override when both using API and Spring.&lt;/li>
&lt;li>fix service discovery not work on bootstrap &amp;amp; fix address pollution.&lt;/li>
&lt;li>fix nacos registry can&amp;rsquo;t received instance change notify.&lt;/li>
&lt;li>fix could not resolve placeholder &amp;lsquo;${dubbo.application}&amp;rsquo; in xml.&lt;/li>
&lt;li>fix service parameter fetch order.&lt;/li>
&lt;li>fix error of register dubbo bootstrap application listener manually.&lt;/li>
&lt;li>fix mock parameters doesn&amp;rsquo;t work when it contain &amp;lsquo;:&amp;rsquo; or &amp;lsquo;=&amp;rsquo;.&lt;/li>
&lt;li>fix delete mesh rule npe.&lt;/li>
&lt;/ul>
&lt;h2 id="optimization">Optimization&lt;/h2>
&lt;ul>
&lt;li>add exception catch for RemovalTask, ensure semaphore release.&lt;/li>
&lt;li>check duplicated ReferenceConfig/ServiceConfig by unique service name.&lt;/li>
&lt;li>improve the performance for generating random numbers.&lt;/li>
&lt;li>if user define interface service discovery, not publish service name mapping info.&lt;/li>
&lt;li>use StringBuilder#append(Char) to improve performance.&lt;/li>
&lt;li>gRPC Compile class interface order.&lt;/li>
&lt;li>improve property placeholder resolving of reference bean.&lt;/li>
&lt;li>use CompletableFuture#get(long, TimeUnit) to take place of CompletableFuture#get() in MergeableClusterInvoker.&lt;/li>
&lt;li>service delay export config ignore metadata service.&lt;/li>
&lt;li>improve dubbo config beans and bootstrap initialization.&lt;/li>
&lt;li>improve duplicated config checking and add tests for reference annotation.&lt;/li>
&lt;li>replace with ring for registry notification &amp;amp; suppress property checker.&lt;/li>
&lt;li>improve dynamic configuration initialization.&lt;/li>
&lt;li>lock-free ConfigManager and improve config checking.&lt;/li>
&lt;li>modify metadata equals and instance listener.&lt;/li>
&lt;li>improve async export / refer.&lt;/li>
&lt;li>use TreeSet to ensure ServiceNames order when subscribe.&lt;/li>
&lt;li>make first tenth calls notify not delay RegistryNotifier.&lt;/li>
&lt;li>refactor compiler to generate new format stubs.&lt;/li>
&lt;li>change mesh rule group to config default value.&lt;/li>
&lt;li>compatible with nacos grouping via group.&lt;/li>
&lt;li>remove runtime params in ServiceInfo.&lt;/li>
&lt;li>throw RpcException when NacosException occurred.&lt;/li>
&lt;li>configcenter ban accessLogKey and FileRouterFactory key.&lt;/li>
&lt;li>improve config bean initialization compatible with spring 3.x/4.1.x.&lt;/li>
&lt;li>dubbo bootstrap start re-entry, export/refer new services.&lt;/li>
&lt;li>org.apache.dubbo.* add serialization whitelist.&lt;/li>
&lt;li>ensure generated config id is unique, checking existed config.&lt;/li>
&lt;li>compatible with filed change declaration override for Javaassist.&lt;/li>
&lt;li>refactor Codec check, default deny.&lt;/li>
&lt;li>compatible with adaptive extensions when ApplicationModel is null.&lt;/li>
&lt;/ul>
&lt;h2 id="code-improvement">Code Improvement&lt;/h2>
&lt;p>Thanks for these contribution to improve stability of Apache Dubbo.&lt;/p>
&lt;p>&lt;a href="https://github.com/apache/dubbo/pull/8111">#8111&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8147">#8147&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8164">#8164&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8177">#8177&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8180">#8180&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8161">#8161&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8183">#8183&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8205">#8205&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8173">#8173&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8219">#8219&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8228">#8228&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8232">#8232&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8230">#8230&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8236">#8236&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8260">#8260&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8262">#8262&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8252">#8252&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8246">#8246&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8208">#8208&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8278">#8278&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8267">#8267&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8277">#8277&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8291">#8291&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8296">#8296&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8302">#8302&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8175">#8175&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8319">#8319&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8309">#8309&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8336">#8336&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8332">#8332&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8328">#8328&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8355">#8355&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8396">#8396&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8401">#8401&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8395">#8395&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8415">#8415&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8406">#8406&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8411">#8411&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8418">#8418&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8439">#8439&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8404">#8404&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8443">#8443&lt;/a>&lt;/p>
&lt;h2 id="dependency-changes">Dependency Changes&lt;/h2>
&lt;ul>
&lt;li>remove dependency: org.eclipse.collections:eclipse-collections&lt;/li>
&lt;li>remove dependency: com.google.guava:guava&lt;/li>
&lt;li>jetty: 9.4.11.v20180605 -&amp;gt; 9.4.43.v20210629&lt;/li>
&lt;li>apollo client: 1.1.1 -&amp;gt; 1.8.0&lt;/li>
&lt;li>snakeyaml: 1.20 -&amp;gt; 1.29&lt;/li>
&lt;li>tomcat embed: 8.5.31 -&amp;gt; 8.5.69&lt;/li>
&lt;li>nacos client: 2.0.0 -&amp;gt; 2.0.2&lt;/li>
&lt;li>swagger: 1.5.19 -&amp;gt; 1.5.24&lt;/li>
&lt;li>hessian_lite: 3.2.8 -&amp;gt; 3.2.11&lt;/li>
&lt;/ul></description></item><item><title>Blog: 3.0.1 Release Note</title><link>https://dubbo.apache.org/en/blog/2021/07/02/3.0.1-release-note/</link><pubDate>Fri, 02 Jul 2021 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2021/07/02/3.0.1-release-note/</guid><description>
&lt;h2 id="optimization">Optimization&lt;/h2>
&lt;ul>
&lt;li>Refactor NameMapping to Metadata, Support application field in MigrationRule&lt;/li>
&lt;li>Add cache for scan result&lt;/li>
&lt;li>Improve config overrides of method and argument&lt;/li>
&lt;li>Support servlet takeover mode&lt;/li>
&lt;li>Add ServiceListener for ServiceConfig&lt;/li>
&lt;li>Improve method callback&lt;/li>
&lt;/ul>
&lt;h2 id="bugfixs">BugFixs&lt;/h2>
&lt;ul>
&lt;li>Add force check&lt;/li>
&lt;li>Fix multi-registry will destroy unavailable clusters&lt;/li>
&lt;li>Remove needless toString convert &amp;amp; Enable checking by default&lt;/li>
&lt;li>Ignore invalid MetadataReportConfig&lt;/li>
&lt;li>Fix NPE when consumer start&lt;/li>
&lt;li>Fix some compatiable issues&lt;/li>
&lt;li>Optimize Service related issues&lt;/li>
&lt;li>Opt Migration &amp;amp; Fix reSubscribe for ServiceDiscovery&lt;/li>
&lt;li>Fix NPE in MetadataInfo&lt;/li>
&lt;li>Fix customizer not changed&lt;/li>
&lt;/ul>
&lt;h2 id="code-improvement">Code Improvement&lt;/h2>
&lt;p>Thanks for these contribution to improve stability of Apache Dubbo.&lt;/p>
&lt;p>&lt;a href="https://github.com/apache/dubbo/pull/8043">#8043&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8044">#8044&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8048">#8048&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8071">#8071&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8119">#8119&lt;/a>,
&lt;a href="https://github.com/apache/dubbo/pull/8132">#8132&lt;/a>&lt;/p></description></item><item><title>Blog: Past Releases</title><link>https://dubbo.apache.org/en/blog/2020/05/18/past-releases/</link><pubDate>Mon, 18 May 2020 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2020/05/18/past-releases/</guid><description>
&lt;div class="pageinfo pageinfo-primary">
&lt;p>This document is no longer maintained. You are currently viewing a snapshot version. If you want to see the latest version of the documentation, see &lt;a href="https://dubbo.apache.org/en/release/">Latest Version&lt;/a>.&lt;/p>
&lt;/div>
&lt;h2 id="verification">Verification&lt;/h2>
&lt;p>you can follow these &lt;a href="https://www.apache.org/info/verification">procedures&lt;/a> and the &lt;a href="https://downloads.apache.org/dubbo/KEYS">KEYS&lt;/a> file to verify the download files&lt;/p>
&lt;h2 id="apache-dubbo">Apache Dubbo&lt;/h2>
&lt;blockquote>
&lt;p>GitHub: &lt;a href="https://github.com/apache/dubbo">https://github.com/apache/dubbo&lt;/a> &lt;br>
Release Notes: &lt;a href="https://github.com/apache/dubbo/releases">https://github.com/apache/dubbo/releases&lt;/a>&lt;/p>
&lt;/blockquote>
&lt;h3 id="320-beta3-2022-12-22">3.2.0-beta.3 (2022-12-22)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/3.2.0-beta.3/apache-dubbo-3.2.0-beta.3-src.zip">source&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/3.2.0-beta.3/apache-dubbo-3.2.0-beta.3-src.zip.asc">asc&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/3.2.0-beta.3/apache-dubbo-3.2.0-beta.3-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="313-2022-12-22">3.1.3 (2022-12-22)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/3.1.4/apache-dubbo-3.1.4-src.zip">source&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/3.1.4/apache-dubbo-3.1.4-src.zip.asc">asc&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/3.1.4/apache-dubbo-3.1.4-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="2719-2022-12-13">2.7.19 (2022-12-13)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/2.7.19/apache-dubbo-2.7.19-src.zip">source&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/2.7.19/apache-dubbo-2.7.19-src.zip.asc">asc&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/2.7.19/apache-dubbo-2.7.19-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="320-beta2-2022-11-28">3.2.0-beta.2 (2022-11-28)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.2.0-beta.2/apache-dubbo-3.2.0-beta.2-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.2.0-beta.2/apache-dubbo-3.2.0-beta.2-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.2.0-beta.2/apache-dubbo-3.2.0-beta.2-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="313-2022-11-28">3.1.3 (2022-11-28)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.1.3/apache-dubbo-3.1.3-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.1.3/apache-dubbo-3.1.3-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.1.3/apache-dubbo-3.1.3-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="320-beta1-2022-11-08">3.2.0-beta.1 (2022-11-08)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.2.0-beta.1/apache-dubbo-3.2.0-beta.1-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.2.0-beta.1/apache-dubbo-3.2.0-beta.1-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.2.0-beta.1/apache-dubbo-3.2.0-beta.1-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="312-2022-11-08">3.1.2 (2022-11-08)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.1.2/apache-dubbo-3.1.2-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.1.2/apache-dubbo-3.1.2-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.1.2/apache-dubbo-3.1.2-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="311-2022-09-29">3.1.1 (2022-09-29)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.1.1/apache-dubbo-3.1.1-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.1.1/apache-dubbo-3.1.1-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.1.1/apache-dubbo-3.1.1-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="3012-2022-09-29">3.0.12 (2022-09-29)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/3.0.12/apache-dubbo-3.0.12-src.zip">source&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/3.0.12/apache-dubbo-3.0.12-src.zip.asc">asc&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/3.0.12/apache-dubbo-3.0.12-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="2718-2022-09-29">2.7.18 (2022-09-29)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.18/apache-dubbo-2.7.18-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.18/apache-dubbo-2.7.18-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.18/apache-dubbo-2.7.18-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="2717-2022-08-23">2.7.17 (2022-08-23)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.17/apache-dubbo-2.7.17-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.17/apache-dubbo-2.7.17-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.17/apache-dubbo-2.7.17-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="3011-2022-08-23">3.0.11 (2022-08-23)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.0.11/apache-dubbo-3.0.11-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.11/apache-dubbo-3.0.11-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.11/apache-dubbo-3.0.11-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="310-2022-08-22">3.1.0 (2022-08-22)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.1.0/apache-dubbo-3.1.0-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.1.0/apache-dubbo-3.1.0-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.1.0/apache-dubbo-3.1.0-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="3010-2022-07-21">3.0.10 (2022-07-21)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.0.10/apache-dubbo-3.0.10-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.10/apache-dubbo-3.0.10-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.10/apache-dubbo-3.0.10-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="2716-2022-07-06">2.7.16 (2022-07-06)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.16/apache-dubbo-2.7.16-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.16/apache-dubbo-2.7.16-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.16/apache-dubbo-2.7.16-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="309-2022-06-23">3.0.9 (2022-06-23)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.0.9/apache-dubbo-3.0.9-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.9/apache-dubbo-3.0.9-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.9/apache-dubbo-3.0.9-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="308-2022-05-11">3.0.8 (2022-05-11)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.0.8/apache-dubbo-3.0.8-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.8/apache-dubbo-3.0.8-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.8/apache-dubbo-3.0.8-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="307-2022-04-01">3.0.7 (2022-04-01)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.0.7/apache-dubbo-3.0.7-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.7/apache-dubbo-3.0.7-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.7/apache-dubbo-3.0.7-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="306-2022-02-28">3.0.6 (2022-02-28)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.0.6/apache-dubbo-3.0.6-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.6/apache-dubbo-3.0.6-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.6/apache-dubbo-3.0.6-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="305-2021-12-30">3.0.5 (2021-12-30)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.0.5/apache-dubbo-3.0.5-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.5/apache-dubbo-3.0.5-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.5/apache-dubbo-3.0.5-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="2715-2021-12-29">2.7.15 (2021-12-29)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.15/apache-dubbo-2.7.15-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.15/apache-dubbo-2.7.15-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.15/apache-dubbo-2.7.15-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="2612-2021-12-29">2.6.12 (2021-12-29)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/2.6.12/apache-dubbo-2.6.12-src.zip">source&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/2.6.12/apache-dubbo-v-src.zip.asc">asc&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/2.6.12/apache-dubbo-2.6.12-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="304-2021-10-24">3.0.4 (2021-10-24)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.0.4/apache-dubbo-3.0.4-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.4/apache-dubbo-3.0.4-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.4/apache-dubbo-3.0.4-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="303-2021-09-27">3.0.3 (2021-09-27)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.0.3/apache-dubbo-3.0.3-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.3/apache-dubbo-3.0.3-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.3/apache-dubbo-3.0.3-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="2714-2021-09-20">2.7.14 (2021-09-20)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.14/apache-dubbo-2.7.14-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.14/apache-dubbo-2.7.14-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.14/apache-dubbo-2.7.14-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="2611-2021-09-18">2.6.11 (2021-09-18)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.apache.org/dyn/closer.cgi?path=dubbo/2.6.11/apache-dubbo-2.6.11-source-release.zip">source&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.cgi?path=dubbo/2.6.11/apache-dubbo-2.6.11-source-release.zip.asc">asc&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.cgi?path=dubbo/2.6.11/apache-dubbo-2.6.11-source-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="3021-2021-08-23">3.0.2.1 (2021-08-23)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.0.2.1/apache-dubbo-3.0.2.1-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.2.1/apache-dubbo-3.0.2.1-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.2.1/apache-dubbo-3.0.2.1-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="302-2021-08-16">3.0.2 (2021-08-16)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.0.2/apache-dubbo-3.0.2-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.2/apache-dubbo-3.0.2-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.2/apache-dubbo-3.0.2-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="2713-2021-08-05">2.7.13 (2021-08-05)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.13/apache-dubbo-2.7.13-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.13/apache-dubbo-2.7.13-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.13/apache-dubbo-2.7.13-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="301-2021-07-02">3.0.1 (2021-07-02)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.0.1/apache-dubbo-3.0.1-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.1/apache-dubbo-3.0.1-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.1/apache-dubbo-3.0.1-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="300-2021-06-16">3.0.0 (2021-06-16)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/3.0.0/apache-dubbo-3.0.0-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.0/apache-dubbo-3.0.0-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/3.0.0/apache-dubbo-3.0.0-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="2712-2021-06-11">2.7.12 (2021-06-11)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.12/apache-dubbo-2.7.12-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.12/apache-dubbo-2.7.12-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.12/apache-dubbo-2.7.12-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="2711-2021-05-12">2.7.11 (2021-05-12)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.11/apache-dubbo-2.7.11-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.11/apache-dubbo-2.7.11-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.11/apache-dubbo-2.7.11-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="2710-2021-04-08">2.7.10 (2021-04-08)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.10/apache-dubbo-2.7.10-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.10/apache-dubbo-2.7.10-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.10/apache-dubbo-2.7.10-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="279-2020-02-23">2.7.9 (2020-02-23)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.9/apache-dubbo-2.7.9-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.9/apache-dubbo-2.7.9-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.9/apache-dubbo-2.7.9-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="278-2020-07-28">2.7.8 (2020-07-28)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.8/apache-dubbo-2.7.8-source-release.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.8/apache-dubbo-2.7.8-source-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.8/apache-dubbo-2.7.8-source-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="277-2020-05-18">2.7.7 (2020-05-18)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.7/apache-dubbo-2.7.7-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.7/apache-dubbo-2.7.7-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.7/apache-dubbo-2.7.7-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="275-2019-12-29">2.7.5 (2019-12-29)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.5/apache-dubbo-2.7.5-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.5/apache-dubbo-2.7.5-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.5/apache-dubbo-2.7.5-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="2741-2019-10-27">2.7.4.1 (2019-10-27)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.4.1/apache-dubbo-2.7.4.1-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.4.1/apache-dubbo-2.7.4.1-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.4.1/apache-dubbo-2.7.4.1-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="274-2019-10-19">2.7.4 (2019-10-19)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.4/apache-dubbo-2.7.4-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.4/apache-dubbo-2.7.4-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.4/apache-dubbo-2.7.4-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="273-2019-07-19">2.7.3 (2019-07-19)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.3/apache-dubbo-2.7.3-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.3/apache-dubbo-2.7.3-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.3/apache-dubbo-2.7.3-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="272-2019-06-06">2.7.2 (2019-06-06)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/dubbo/2.7.2/apache-dubbo-2.7.2-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.2/apache-dubbo-2.7.2-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/dubbo/2.7.2/apache-dubbo-2.7.2-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="271-2019-03-26">2.7.1 (2019-03-26)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.7.1/apache-dubbo-incubating-2.7.1-src.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.7.1/apache-dubbo-incubating-2.7.1-src.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.7.1/apache-dubbo-incubating-2.7.1-src.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.7.1/apache-dubbo-incubating-2.7.1-bin.zip">binary&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.7.1/apache-dubbo-incubating-2.7.1-bin.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.7.1/apache-dubbo-incubating-2.7.1-bin.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="270-2019-01-29">2.7.0 (2019-01-29)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.7.0/apache-dubbo-incubating-2.7.0-source-release.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.7.0/apache-dubbo-incubating-2.7.0-source-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.7.0/apache-dubbo-incubating-2.7.0-source-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.7.0/apache-dubbo-incubating-2.7.0-bin-release.zip">binary&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.7.0/apache-dubbo-incubating-2.7.0-bin-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.7.0/apache-dubbo-incubating-2.7.0-bin-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="267-2019-07-15">2.6.7 (2019-07-15)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/2.6.7/apache-dubbo-2.6.7-source-release.zip">source&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/2.6.7/apache-dubbo-2.6.7-source-release.zip.asc">asc&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/2.6.7/apache-dubbo-2.6.7-source-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/2.6.7/apache-dubbo-2.6.7-bin-release.zip">binary&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/2.6.7/apache-dubbo-2.6.7-bin-release.zip.asc">asc&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/dubbo/2.6.7/apache-dubbo-2.6.7-bin-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="266-2019-03-07">2.6.6 (2019-03-07)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.apache.org/dyn/closer.lua/incubator/dubbo/2.6.6/apache-dubbo-incubating-2.6.6-source-release.zip">source&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/incubator/dubbo/2.6.6/apache-dubbo-incubating-2.6.6-source-release.zip.asc">asc&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/incubator/dubbo/2.6.6/apache-dubbo-incubating-2.6.6-source-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.apache.org/dyn/closer.lua/incubator/dubbo/2.6.6/apache-dubbo-incubating-2.6.6-bin-release.zip">binary&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/incubator/dubbo/2.6.6/apache-dubbo-incubating-2.6.6-bin-release.zip.asc">asc&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/incubator/dubbo/2.6.6/apache-dubbo-incubating-2.6.6-bin-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="265-2018-11-23">2.6.5 (2018-11-23)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.5/apache-dubbo-incubating-2.6.5-source-release.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.5/apache-dubbo-incubating-2.6.5-source-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.5/apache-dubbo-incubating-2.6.5-source-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.5/apache-dubbo-incubating-2.6.5-bin-release.zip">binary&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.5/apache-dubbo-incubating-2.6.5-bin-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.5/apache-dubbo-incubating-2.6.5-bin-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="264-2018-10-08">2.6.4 (2018-10-08)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.4/apache-dubbo-incubating-2.6.4-source-release.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.4/apache-dubbo-incubating-2.6.4-source-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.4/apache-dubbo-incubating-2.6.4-source-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.4/apache-dubbo-incubating-2.6.4-bin-release.zip">binary&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.4/apache-dubbo-incubating-2.6.4-bin-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.4/apache-dubbo-incubating-2.6.4-bin-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="263-2018-09-11">2.6.3 (2018-09-11)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.3/apache-dubbo-incubating-2.6.3-source-release.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.3/apache-dubbo-incubating-2.6.3-source-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.3/apache-dubbo-incubating-2.6.3-source-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.3/apache-dubbo-incubating-2.6.3-bin-release.zip">binary&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.3/apache-dubbo-incubating-2.6.3-bin-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.3/apache-dubbo-incubating-2.6.3-bin-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="262-2018-06-07">2.6.2 (2018-06-07)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.2/dubbo-incubating-2.6.2-source-release.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.2/dubbo-incubating-2.6.2-source-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.2/dubbo-incubating-2.6.2-source-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.2/dubbo-incubating-2.6.2-bin-release.zip">binary&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.2/dubbo-incubating-2.6.2-bin-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/2.6.2/dubbo-incubating-2.6.2-bin-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h2 id="dubbo-spring-boot-starter">Dubbo Spring Boot Starter&lt;/h2>
&lt;blockquote>
&lt;p>GitHub: &lt;a href="https://github.com/apache/incubator-dubbo-spring-boot-project">https://github.com/apache/incubator-dubbo-spring-boot-project&lt;/a> &lt;br>
发布说明:https://github.com/apache/incubator-dubbo-spring-boot-project/releases&lt;/p>
&lt;/blockquote>
&lt;h3 id="271-2019-04-09">2.7.1 (2019-04-09)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://www.apache.org/dyn/closer.lua/incubator/dubbo/spring-boot-project/2.7.1/apache-dubbo-spring-boot-project-incubating-2.7.1-source-release.zip">source&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/incubator/dubbo/spring-boot-project/2.7.1/apache-dubbo-spring-boot-project-incubating-2.7.1-source-release.zip.asc">asc&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/incubator/dubbo/spring-boot-project/2.7.1/apache-dubbo-spring-boot-project-incubating-2.7.1-source-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.apache.org/dyn/closer.lua/incubator/dubbo/spring-boot-project/2.7.1/apache-dubbo-spring-boot-project-incubating-2.7.1-bin-release.zip">binary&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/incubator/dubbo/spring-boot-project/2.7.1/apache-dubbo-spring-boot-project-incubating-2.7.1-bin-release.zip.asc">asc&lt;/a> |
&lt;a href="https://www.apache.org/dyn/closer.lua/incubator/dubbo/spring-boot-project/2.7.1/apache-dubbo-spring-boot-project-incubating-2.7.1-bin-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="270-2019-02-14">2.7.0 (2019-02-14)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/2.7.0/apache-dubbo-spring-boot-project-incubating-2.7.0-source-release.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/2.7.0/apache-dubbo-spring-boot-project-incubating-2.7.0-source-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/2.7.0/apache-dubbo-spring-boot-project-incubating-2.7.0-source-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/2.7.0/apache-dubbo-spring-boot-project-incubating-2.7.0-bin-release.zip">binary&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/2.7.0/apache-dubbo-spring-boot-project-incubating-2.7.0-bin-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/2.7.0/apache-dubbo-spring-boot-project-incubating-2.7.0-bin-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="021-2019-01-27">0.2.1 (2019-01-27)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/0.2.1/apache-dubbo-spring-boot-project-incubating-0.2.1-source-release.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/0.2.1/apache-dubbo-spring-boot-project-incubating-0.2.1-source-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/0.2.1/apache-dubbo-spring-boot-project-incubating-0.2.1-source-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/0.2.1/apache-dubbo-spring-boot-project-incubating-0.2.1-bin-release.zip">binary&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/0.2.1/apache-dubbo-spring-boot-project-incubating-0.2.1-bin-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/0.2.1/apache-dubbo-spring-boot-project-incubating-0.2.1-bin-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="012-2019-01-27">0.1.2 (2019-01-27)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/0.1.2/apache-dubbo-spring-boot-project-incubating-0.1.2-source-release.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/0.1.2/apache-dubbo-spring-boot-project-incubating-0.1.2-source-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/0.1.2/apache-dubbo-spring-boot-project-incubating-0.1.2-source-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/0.1.2/apache-dubbo-spring-boot-project-incubating-0.1.2-bin-release.zip">binary&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/0.1.2/apache-dubbo-spring-boot-project-incubating-0.1.2-bin-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/spring-boot-project/0.1.2/apache-dubbo-spring-boot-project-incubating-0.1.2-bin-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul>
&lt;h2 id="dubbo-admin">Dubbo Admin&lt;/h2>
&lt;blockquote>
&lt;p>GitHub: &lt;a href="https://github.com/apache/incubator-dubbo-admin">https://github.com/apache/incubator-dubbo-admin&lt;/a> &lt;br>
Release Notes: &lt;a href="https://github.com/apache/incubator-dubbo-admin/releases">https://github.com/apache/incubator-dubbo-admin/releases&lt;/a>&lt;/p>
&lt;/blockquote>
&lt;h3 id="01-2019-02-15">0.1 (2019-02-15)&lt;/h3>
&lt;ul>
&lt;li>&lt;a href="https://archive.apache.org/dist/incubator/dubbo/dubbo-ops/0.1/apache-dubbo-ops-incubating-0.1-source-release.zip">source&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/dubbo-ops/0.1/apache-dubbo-ops-incubating-0.1-source-release.zip.asc">asc&lt;/a> |
&lt;a href="https://archive.apache.org/dist/incubator/dubbo/dubbo-ops/0.1/apache-dubbo-ops-incubating-0.1-source-release.zip.sha512">sha512&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Blog: Dubbo Admin service test</title><link>https://dubbo.apache.org/en/blog/2019/08/26/service-test/</link><pubDate>Mon, 26 Aug 2019 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2019/08/26/service-test/</guid><description>
&lt;p>Based on the metadata of Dubbo2.7, Dubbo Admin implements the service test function, which can call the real service provider on the console through generalized call.&lt;/p>
&lt;h2 id="usage">Usage&lt;/h2>
&lt;ul>
&lt;li>
&lt;p>Deploy the provider: You can download the demo &lt;a href="https://github.com/nzomkxia/dubbo-demo">here&lt;/a>. This project is based on Spring Boot, which is convenient to start in the IDE or command line. For service testing, you only need to start &lt;code>dubbo-basic-provider&lt;/code>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Service-seeking: After completing the server deployment, you can query the corresponding service on the Dubbo Admin&amp;rsquo;s &lt;code>service test&lt;/code> page:
&lt;img src="https://dubbo.apache.org/imgs/blog/admin/testSearch.jpg" alt="testSearch">&lt;br>
the information here is similar to the metadata, including the method name, parameter type and return value. Click the label on the right to enter the &lt;code>service test&lt;/code> page.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Service test:
&lt;img src="https://dubbo.apache.org/imgs/blog/admin/testSuccess.jpg" alt="testSuccess">&lt;br>
&lt;code>service test&lt;/code> page contains two json editor, the parameter&amp;rsquo;s informations are all stored in a json format, where you need to fill in the corresponding parameter values (in this case, the number type is String ), after filling, click &lt;code>execute&lt;/code> to initiate the call to the server, and the result of the call is displayed in the editor on the right. If the call fails, the detailed cause of the failure is displayed. Let&amp;rsquo;s look at the example of the call failure.&lt;br>
&lt;img src="https://dubbo.apache.org/imgs/blog/admin/testFail.jpg" alt="testFail">&lt;/p>
&lt;p>In this case, the Dubbo service provider&amp;rsquo;s process is shut down before the service test is executed, you can see that the returned result is an &lt;code>No provider availble&lt;/code> exception. As with normal calls, business and framework exceptions are returned in the results, for easy business troubleshooting.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Complex type parameters &lt;br>
Consider the following methods and types in &lt;code>UserService&lt;/code>:&lt;/p>
&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">//org.apache.dubbo.demo.api.UserService&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Result &lt;span style="color:#268bd2">getUser&lt;/span>(String name, UserInfoDO userInfoDO);
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">UserInfoDO&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> &lt;span style="color:#dc322f">int&lt;/span> id;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> LocationDO locationDO;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> DepartmentDO departmentDO;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">toString&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;UserInfoDO{&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">&amp;#34;id=&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> id &lt;span style="color:#719e07">+&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">&amp;#34;, locationDO=&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> locationDO.toString() &lt;span style="color:#719e07">+&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">&amp;#34;, departmentDO=&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> departmentDO.toString() &lt;span style="color:#719e07">+&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">&amp;#39;}&amp;#39;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DepartmentDO&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> String departName;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> LocationDO departLocation;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">toString&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;DepartmentDO{&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">&amp;#34;departName=&amp;#39;&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> departName &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#39;\&amp;#39;&amp;#39;&lt;/span> &lt;span style="color:#719e07">+&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">&amp;#34;, departLocation=&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> departLocation.toString() &lt;span style="color:#719e07">+&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">&amp;#39;}&amp;#39;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">LocationDO&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> String address;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> &lt;span style="color:#dc322f">int&lt;/span> postNum;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">toString&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;LocationDO{&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">&amp;#34;address=&amp;#39;&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> address &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#39;\&amp;#39;&amp;#39;&lt;/span> &lt;span style="color:#719e07">+&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">&amp;#34;, postNum=&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> postNum &lt;span style="color:#719e07">+&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">&amp;#39;}&amp;#39;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The parameters are complex complex type. When the service is tested, the value of each field will be filled out layer by layer, As shown below:&lt;br>
&lt;img src="https://dubbo.apache.org/imgs/blog/admin/complex.jpg" alt="complex">
It can also make successful call and the result is returned.&lt;/p>
&lt;h2 id="principledata-source">Principle:Data source&lt;/h2>
&lt;p>In the service test, the most important thing is the complete method signature, and the type information of the parameters, with which the values of each parameter can be filled step by step to assemble the complete service consumer. In Dubbo 2.7, the metadata center has been added. The method signature and parameter type information of Dubbo Admin is from here:&lt;br>
&lt;img src="https://dubbo.apache.org/imgs/blog/admin/metadata.png" alt="medatada">
As shown, the server will register the metadata information of the service to the metadata center when it runs,the format is as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-json" data-lang="json">&lt;span style="display:flex;">&lt;span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;methods&amp;#34;&lt;/span>: [
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;name&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;sayHello&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;parameterTypes&amp;#34;&lt;/span>: [
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">&amp;#34;org.apache.dubbo.demo.model.User&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ],
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;returnType&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;org.apache.dubbo.demo.model.Result&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ],
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;types&amp;#34;&lt;/span>: [
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;char&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;long&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;org.apache.dubbo.demo.model.Result&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;properties&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;msg&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;java.lang.String&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;properties&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;value&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;char[]&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;hash&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;int&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;userName&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;java.lang.String&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;properties&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;value&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;char[]&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;hash&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;int&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;org.apache.dubbo.demo.model.User&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;properties&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;id&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;java.lang.Long&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;properties&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;value&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;long&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;username&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;java.lang.Sring&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;properties&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;value&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;char[]&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;hash&amp;#34;&lt;/span>: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;type&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;int&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Related to service testing is the method and type information contained in &lt;code>methods&lt;/code> and &lt;code>types&lt;/code>. Based on this information, Dubbo Admin renders the parameters into the Json Editor of the service test page, where the user enters the values of each parameter and each member variable.&lt;/p>
&lt;h2 id="principle-generalized-calls">Principle: Generalized calls&lt;/h2>
&lt;p>With the parameter type, the next question is how to call to the server. In the traditional Dubbo RPC call, the client needs to rely on the server&amp;rsquo;s API jar package ( refer to the &lt;a href="https://github.com/nzomkxia/dubbo-demo/tree/master/dubbo-basic-consumer">dubbo-basic-consumer&lt;/a> in the previous demo ), which is unlikely for Dubbo Admin, because the up and down of services are dynamic, Dubbo Admin can not dynamically increase the jar package dependencies, so you need to use the &lt;strong>generalization call&lt;/strong> in Dubbo , which means that in the absence of the server API interface, the client initiates a service call through the &lt;code>GenericService&lt;/code> interface, and the data objects in return values are represented by maps. The generalization call doesn&amp;rsquo;t require special processing on the server side, only need to be initiated by the client side.&lt;/p>
&lt;h2 id="summary-and-outlook">Summary and outlook&lt;/h2>
&lt;p>This article briefly introduces the usage and principle of service testing, and will further enhance this function in the future, such as processing the parameter types of abstract classes, importing parameter values from json files, supporting the saving of parameter values, etc., to facilitate regression testing of the service interface.&lt;/p></description></item><item><title>Blog: Tracing Dubbo service with Apache Skywalking</title><link>https://dubbo.apache.org/en/blog/2019/08/11/tracing-dubbo-service-with-apache-skywalking/</link><pubDate>Sun, 11 Aug 2019 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2019/08/11/tracing-dubbo-service-with-apache-skywalking/</guid><description>
&lt;h2 id="introduction-to-apache-skywalking">Introduction to Apache Skywalking&lt;/h2>
&lt;p>&lt;a href="https://github.com/apache/skywalking">Apache Skywalking&lt;/a> is the APM system that it designed for micro-services architectures and cloud native architecture systems and supports distribute tracking. &lt;a href="https://github.com/apache/skywalking">Apache skywalking (incubator)&lt;/a> collects and analyzes the trace data and generates the relationship between the application and the service metric, Apache skywalking supports multiple languages agent, for example &lt;a href="https://github.com/apache/skywalking">Java&lt;/a>,&lt;a href="https://github.com/OpenSkywalking/skywalking-netcore">.net core&lt;/a>,&lt;a href="https://github.com/OpenSkywalking/skywalking-nodejs">Node.js&lt;/a> and &lt;a href="https://github.com/SkyAPM/go2sky">Go&lt;/a>.&lt;/p>
&lt;p>Currently, Skywalking has supported analysis the operation of distributed systems from 6 visual dimensions. The overview view is a global view of your applications and components, including the number of components and applications, application alarm fluctuations, slow service lists, and application throughput; The topology shows the topological relationship of the whole application; The application view represents the upstream and downstream relationship of the application from single application, TOP N services and servers, JVM, host and process info. The service view focuses on the operation of a single service portal and the upstream and downstream dependencies of this service and it helps the user to optimize and monitor a single service; the trace graph shows all the buried points of the invocation and the execution time of each burial point, and the alarm view is based on the configuration threshold for the application, server, service for real-time alarms&lt;/p>
&lt;h2 id="dubbo-and-apache-skywalking">Dubbo and Apache Skywalking&lt;/h2>
&lt;h3 id="build-the-dubbo-demo--project">Build the Dubbo demo project&lt;/h3>
&lt;p>The Dubbo demo has been uploaded to the &lt;a href="https://github.com/SkywalkingTest/dubbo-trace-example">GitHub repository&lt;/a>.&lt;/p>
&lt;h4 id="api-project">API project&lt;/h4>
&lt;p>Service interface definition:
package org.apache.skywalking.demo.interfaces;&lt;/p>
&lt;p>public interface HelloService {
String sayHello(String name);
}&lt;/p>
&lt;h4 id="service-provider-project">Service provider project&lt;/h4>
&lt;p>package org.apache.skywalking.demo.provider;&lt;/p>
&lt;p>@Service(version = &amp;ldquo;${demo.service.version}&amp;rdquo;,
application = &amp;ldquo;${dubbo.application.id}&amp;rdquo;,
protocol = &amp;ldquo;${dubbo.protocol.id}&amp;rdquo;,
registry = &amp;ldquo;${dubbo.registry.id}&amp;rdquo;, timeout = 60000)
public class HelloServiceImpl implements HelloService {&lt;/p>
&lt;pre>&lt;code>public String sayHello(String name) {
LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(1));
return &amp;quot;Hello, &amp;quot; + name;
}
&lt;/code>&lt;/pre>
&lt;p>}&lt;/p>
&lt;h4 id="service-consumer-project">Service consumer project&lt;/h4>
&lt;p>package org.apache.skywalking.demo.consumer;&lt;/p>
&lt;p>@RestController
public class ConsumerController {&lt;/p>
&lt;pre>&lt;code>private static int COUNT = 0;
@Reference(version = &amp;quot;${demo.service.version}&amp;quot;,
application = &amp;quot;${dubbo.application.id}&amp;quot;,
url = &amp;quot;dubbo://localhost:20880&amp;quot;, timeout = 60000)
private HelloService helloService;
@GetMapping(&amp;quot;/sayHello/{name}&amp;quot;)
public String sayHello(@PathVariable(name = &amp;quot;name&amp;quot;) String name) {
if ((COUNT++) % 3 == 0){
throw new RuntimeException();
}
LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(2));
return helloService.sayHello(name);
}
&lt;/code>&lt;/pre>
&lt;p>}&lt;/p>
&lt;h3 id="deploy-apache-skywalking">Deploy Apache Skywalking&lt;/h3>
&lt;p>&lt;a href="https://github.com/apache/skywalking">Apache skywalking&lt;/a> offers two deployment modes: single-node mode and cluster mode,Here is the single-node mode deployment step, and more about how to deploy skywalking with cluster mode, please reference &lt;a href="https://skywalking.apache.org/docs/main/next/en/setup/backend/backend-setup/">document&lt;/a>.&lt;/p>
&lt;h4 id="third-party-components">Third-party components&lt;/h4>
&lt;ol>
&lt;li>JDK 8+&lt;/li>
&lt;li>Elasticsearch 5.x&lt;/li>
&lt;/ol>
&lt;h4 id="deployment-step">Deployment step&lt;/h4>
&lt;ol>
&lt;li>Download &lt;a href="http://skywalking.apache.org/downloads/">Apache Skywalking Collector&lt;/a>&lt;/li>
&lt;li>Deploy Elasticsearch service
&lt;ul>
&lt;li>Set &lt;code>cluster.name&lt;/code> to &lt;code>CollectorDBCluster&lt;/code>&lt;/li>
&lt;li>Set &lt;code>network.host&lt;/code> to &lt;code>0.0.0.0&lt;/code>&lt;/li>
&lt;li>Start elasticsearch service&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>Unzip and start the Skywalking Collector. Run the &amp;rsquo; bin/startup.sh &amp;rsquo; command to start skywalking Collector&lt;/li>
&lt;/ol>
&lt;h4 id="deploy-the-demo">Deploy the demo&lt;/h4>
&lt;p>Before you deploy the demo service, please run the following command:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>./mvnw clean package
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="deploy-the-provider-service">Deploy the provider service&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>java -jar -javaagent:$AGENT_PATH/skywalking-agent.jar -Dskywalking.agent.application_code=dubbo-provider -Dskywalking.collector.servers=localhost:10800 dubbo-provider/target/dubbo-provider.jar
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="deploy-the-consumer-service">Deploy the consumer service&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>java -jar -javaagent:$AGENT_PATH/skywalking-agent.jar -Dskywalking.agent.application_code=dubbo-consumer -Dskywalking.collector.servers=localhost:10800 dubbo-consumer/target/dubbo-consumer.jar
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="visit-demo-service">visit demo service&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>curl http://localhost:8080/sayHello/test
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="skywalking-scren-snapshot">Skywalking scren snapshot&lt;/h2>
&lt;h3 id="dashboard">Dashboard&lt;/h3>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/skywalking-dashboard.png" alt="/admin-guide/images/skywalking-dashboard.png">&lt;/p>
&lt;h3 id="topology">Topology&lt;/h3>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/skywalking-topology.png" alt="/admin-guide/images/skywalking-topology.png">&lt;/p>
&lt;h3 id="application-view">Application view&lt;/h3>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/skywalking-application.png" alt="/admin-guide/images/skywalking-application.png">&lt;/p>
&lt;p>JVM Information
&lt;img src="https://dubbo.apache.org/imgs/blog/skywalking-application_instance.png" alt="/admin-guide/images/skywalking-application_instance.png">&lt;/p>
&lt;h3 id="service-view">Service view&lt;/h3>
&lt;p>Consumer side
&lt;img src="https://dubbo.apache.org/imgs/blog/skywalking-service-consumer.png" alt="/admin-guide/images/skywalking-service-consumer.png">&lt;/p>
&lt;p>provider side
&lt;img src="https://dubbo.apache.org/imgs/blog/skywalking-service-provider.png" alt="/admin-guide/images/skywalking-service-provider.png">&lt;/p>
&lt;h3 id="trace">Trace&lt;/h3>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/skywalking-trace.png" alt="/admin-guide/images/skywalking-trace.png">&lt;/p>
&lt;p>Span info
&lt;img src="https://dubbo.apache.org/imgs/blog/skywalking-span-Info.png" alt="/admin-guide/images/skywalking-span-Info.png">&lt;/p>
&lt;h3 id="alarm-view">Alarm view&lt;/h3>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/skywalking-alarm.png" alt="/admin-guide/images/skywalking-alarm.png">&lt;/p></description></item><item><title>Blog: Dubbo extensible mechanism source code analysis - part 2</title><link>https://dubbo.apache.org/en/blog/2019/05/02/dubbo-extensible-mechanism-source-code-analysis-part-2/</link><pubDate>Thu, 02 May 2019 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2019/05/02/dubbo-extensible-mechanism-source-code-analysis-part-2/</guid><description>
&lt;p>In the &lt;a href="https://dubbo.apache.org/en/blog/2019/04/25/dubbo-extensible-mechanism-source-code-analysis-part-1/" title="">actual implementation of the Dubbo extensibility mechanism&lt;/a>, we learned some concepts of the Dubbo extension mechanism, explored the implementation of LoadBalance in Dubbo, and implemented a LoadBalance on our own. Do you think Dubbo&amp;rsquo;s extension mechanism is great? Next, we will go deep into the source code of Dubbo and see what it is.&lt;/p>
&lt;h2 id="extensionloader">ExtensionLoader&lt;/h2>
&lt;p>&lt;code>ExtensionLoader&lt;/code> is the core class, which is responsible for the loading and lifecycle management of extension points. Let&amp;rsquo;s start with this class. There are many methods of Extension, and the common methods include:&lt;/p>
&lt;ul>
&lt;li>&lt;code>public static &amp;lt;T&amp;gt; ExtensionLoader&amp;lt;T&amp;gt; getExtensionLoader(Class&amp;lt;T&amp;gt; type)&lt;/code>&lt;/li>
&lt;li>&lt;code>public T getExtension(String name)&lt;/code>&lt;/li>
&lt;li>&lt;code>public T getAdaptiveExtension()&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>The common usages are:&lt;/p>
&lt;ul>
&lt;li>&lt;code>LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(loadbalanceName)&lt;/code>&lt;/li>
&lt;li>&lt;code>RouterFactory routerFactory = ExtensionLoader.getExtensionLoader(RouterFactory.class).getAdaptiveExtension()&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>Notice: In the source code shown below, I&amp;rsquo;ll remove extraneous code (such as logging, exception catching, and so on) to make it easy to read and understand.&lt;/p>
&lt;ol>
&lt;li>getExtensionLoader
This is a static factory method that enters an extensible interface and returns an ExtensionLoader entity class for this interface. With this entity class, you can get not only a specific extension based on name, but also an adaptive extension.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> ExtensionLoader&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">getExtensionLoader&lt;/span>(Class&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> type) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// An extension point must be an interface&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (&lt;span style="color:#719e07">!&lt;/span>type.isInterface()) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">throw&lt;/span> &lt;span style="color:#719e07">new&lt;/span> IllegalArgumentException(&lt;span style="color:#2aa198">&amp;#34;Extension type(&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> type &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#34;) is not interface!&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// @SPI annotations must be provided&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (&lt;span style="color:#719e07">!&lt;/span>withExtensionAnnotation(type)) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">throw&lt;/span> &lt;span style="color:#719e07">new&lt;/span> IllegalArgumentException(&lt;span style="color:#2aa198">&amp;#34;Extension type without @SPI Annotation!&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// Get the corresponding ExtensionLoader from the cache according to the interface&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// Each extension will only be loaded once&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ExtensionLoader&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> loader &lt;span style="color:#719e07">=&lt;/span> (ExtensionLoader&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span>) EXTENSION_LOADERS.get(type);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (loader &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// Initialize extension&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> EXTENSION_LOADERS.putIfAbsent(type, &lt;span style="color:#719e07">new&lt;/span> ExtensionLoader&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span>(type));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> loader &lt;span style="color:#719e07">=&lt;/span> (ExtensionLoader&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span>) EXTENSION_LOADERS.get(type);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> loader;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">private&lt;/span> &lt;span style="color:#268bd2">ExtensionLoader&lt;/span>(Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&lt;/span> type) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">this&lt;/span>.type &lt;span style="color:#719e07">=&lt;/span> type;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> objectFactory &lt;span style="color:#719e07">=&lt;/span> (type &lt;span style="color:#719e07">==&lt;/span> ExtensionFactory.class &lt;span style="color:#719e07">?&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span> : ExtensionLoader.getExtensionLoader(ExtensionFactory.class).getAdaptiveExtension());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="2">
&lt;li>getExtension&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> T &lt;span style="color:#268bd2">getExtension&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Holder&lt;span style="color:#719e07">&amp;lt;&lt;/span>Object&lt;span style="color:#719e07">&amp;gt;&lt;/span> holder &lt;span style="color:#719e07">=&lt;/span> cachedInstances.get(name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (holder &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> cachedInstances.putIfAbsent(name, &lt;span style="color:#719e07">new&lt;/span> Holder&lt;span style="color:#719e07">&amp;lt;&lt;/span>Object&lt;span style="color:#719e07">&amp;gt;&lt;/span>());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> holder &lt;span style="color:#719e07">=&lt;/span> cachedInstances.get(name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Object instance &lt;span style="color:#719e07">=&lt;/span> holder.get();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// Get it from the cache. If it does not exist, create&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (instance &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">synchronized&lt;/span> (holder) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> instance &lt;span style="color:#719e07">=&lt;/span> holder.get();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (instance &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> instance &lt;span style="color:#719e07">=&lt;/span> createExtension(name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> holder.set(instance);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> (T) instance;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Some judgments and caching have been made in the getExtension method, and the main logic is in the createExtension method. Let&amp;rsquo;s move on to the createExtension method.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">private&lt;/span> T &lt;span style="color:#268bd2">createExtension&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// Get the extension class according to the name of extension point. For example, for LoadBalance, get the RandomLoadBalance class according to random&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&lt;/span> clazz &lt;span style="color:#719e07">=&lt;/span> getExtensionClasses().get(name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> T instance &lt;span style="color:#719e07">=&lt;/span> (T) EXTENSION_INSTANCES.get(clazz);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (instance &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// Use reflection to call newInstance to create an example of an extension class&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> EXTENSION_INSTANCES.putIfAbsent(clazz, (T) clazz.newInstance());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> instance &lt;span style="color:#719e07">=&lt;/span> (T) EXTENSION_INSTANCES.get(clazz);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// Make dependency injection for the extended class samples&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> injectExtension(instance);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// If there is a wrapper, add the wrapper&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Set&lt;span style="color:#719e07">&amp;lt;&lt;/span>Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&amp;gt;&lt;/span> wrapperClasses &lt;span style="color:#719e07">=&lt;/span> cachedWrapperClasses;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (wrapperClasses &lt;span style="color:#719e07">!=&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span> &lt;span style="color:#719e07">&amp;amp;&amp;amp;&lt;/span> &lt;span style="color:#719e07">!&lt;/span>wrapperClasses.isEmpty()) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&lt;/span> wrapperClass : wrapperClasses) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> instance &lt;span style="color:#719e07">=&lt;/span> injectExtension((T) wrapperClass.getConstructor(type).newInstance(instance));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> instance;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The createExtension method has done the following:&lt;/p>
&lt;ol>
&lt;li>First, get the corresponding extension class according to name. Read the extension point configuration file from the &lt;code>META-INF&lt;/code> folder under ClassPath.&lt;/li>
&lt;li>Use reflection to create an instance of an extended class.&lt;/li>
&lt;li>make dependency injection for the attributes of the extended class instance. That is, IoC.&lt;/li>
&lt;li>If there is a wrapper, add the wrapper. That is, AOP.&lt;/li>
&lt;/ol>
&lt;p>Let&amp;rsquo;s focus on these four processes.&lt;/p>
&lt;ol>
&lt;li>Get the corresponding extension class according to name. Let’s read the code first:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">private&lt;/span> Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&amp;gt;&lt;/span> getExtensionClasses() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&amp;gt;&lt;/span> classes &lt;span style="color:#719e07">=&lt;/span> cachedClasses.get();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (classes &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">synchronized&lt;/span> (cachedClasses) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> classes &lt;span style="color:#719e07">=&lt;/span> cachedClasses.get();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (classes &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> classes &lt;span style="color:#719e07">=&lt;/span> loadExtensionClasses();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> cachedClasses.set(classes);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> classes;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">// synchronized in getExtensionClasses&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">private&lt;/span> Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&amp;gt;&lt;/span> loadExtensionClasses() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">final&lt;/span> SPI defaultAnnotation &lt;span style="color:#719e07">=&lt;/span> type.getAnnotation(SPI.class);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (defaultAnnotation &lt;span style="color:#719e07">!=&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String value &lt;span style="color:#719e07">=&lt;/span> defaultAnnotation.value();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (value &lt;span style="color:#719e07">!=&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span> &lt;span style="color:#719e07">&amp;amp;&amp;amp;&lt;/span> (value &lt;span style="color:#719e07">=&lt;/span> value.trim()).length() &lt;span style="color:#719e07">&amp;gt;&lt;/span> 0) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String&lt;span style="color:#719e07">[]&lt;/span> names &lt;span style="color:#719e07">=&lt;/span> NAME_SEPARATOR.split(value);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (names.length &lt;span style="color:#719e07">&amp;gt;&lt;/span> 1) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">throw&lt;/span> &lt;span style="color:#719e07">new&lt;/span> IllegalStateException(&lt;span style="color:#2aa198">&amp;#34;more than 1 default extension name on extension &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> type.getName());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (names.length &lt;span style="color:#719e07">==&lt;/span> 1) cachedDefaultName &lt;span style="color:#719e07">=&lt;/span> names&lt;span style="color:#719e07">[&lt;/span>0&lt;span style="color:#719e07">]&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&amp;gt;&lt;/span> extensionClasses &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> HashMap&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> loadFile(extensionClasses, DUBBO_INTERNAL_DIRECTORY);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> loadFile(extensionClasses, DUBBO_DIRECTORY);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> loadFile(extensionClasses, SERVICES_DIRECTORY);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> extensionClasses;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This process is very simple. Get the extension class from the cache first, and if it does not exist, load it from the configuration file. The path of the configuration file has been mentioned before:&lt;/p>
&lt;ul>
&lt;li>&lt;code>META-INF/dubbo/internal&lt;/code>&lt;/li>
&lt;li>&lt;code>META-INF/dubbo&lt;/code>&lt;/li>
&lt;li>&lt;code>META-INF/services&lt;/code>&lt;/li>
&lt;/ul>
&lt;ol start="2">
&lt;li>Use reflection to create an extended instance. This process is very simple. We can do this using &lt;code>clazz.newInstance()&lt;/code>. The attributes of the extended instance created are all null values.&lt;/li>
&lt;li>Extended instance is automatic assembly. In the actual scenario, there have dependencies between classes. Dependencies are also referenced in the extended instance, such as a simple Java class, an extension of another Dubbo, or a Spring Bean. The situation of dependencies is complex, and Dubbo&amp;rsquo;s processing is relatively complicated. We will have a special chapter to explain it later. Now, we just need to know that Dubbo can correctly inject common dependencies in extension points, Dubbo extension dependencies or Spring dependencies, etc..&lt;/li>
&lt;li>Extended instance is auto-wrapping. Auto-wrapping is about implementing Spring like AOP functionality. Dubbo uses it to implement some common functions internally, such as logging, monitoring, and so on. The contents of the extended instance auto-wrapper will also be explained separately later.&lt;/li>
&lt;/ol>
&lt;p>After the above 4 steps, Dubbo creates and initializes an extended instance. The dependencies of this instance are injected and packaged as needed. At this point, this extended instance can be used.&lt;/p>
&lt;h2 id="auto-assembly-of-dubbo-spi-advanced-usage">Auto-assembly of Dubbo SPI advanced usage&lt;/h2>
&lt;p>The relevant code for auto-assembly is in the injectExtension method:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">private&lt;/span> T &lt;span style="color:#268bd2">injectExtension&lt;/span>(T instance) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (Method method : instance.getClass().getMethods()) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (method.getName().startsWith(&lt;span style="color:#2aa198">&amp;#34;set&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;amp;&amp;amp;&lt;/span> method.getParameterTypes().length &lt;span style="color:#719e07">==&lt;/span> 1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;amp;&amp;amp;&lt;/span> Modifier.isPublic(method.getModifiers())) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&lt;/span> pt &lt;span style="color:#719e07">=&lt;/span> method.getParameterTypes()&lt;span style="color:#719e07">[&lt;/span>0&lt;span style="color:#719e07">]&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String property &lt;span style="color:#719e07">=&lt;/span> method.getName().length() &lt;span style="color:#719e07">&amp;gt;&lt;/span> 3 &lt;span style="color:#719e07">?&lt;/span> method.getName().substring(3, 4).toLowerCase() &lt;span style="color:#719e07">+&lt;/span> method.getName().substring(4) : &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Object object &lt;span style="color:#719e07">=&lt;/span> objectFactory.getExtension(pt, property);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (object &lt;span style="color:#719e07">!=&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> method.invoke(instance, object);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> instance;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>To accomplish the automatic assembly of dependencies of the extended instances, you first need to know what the dependencies are and what the types of dependencies are. The solution of Dubbo is to find the Java standard setter method. That is, the method name starting with set has only one parameter. If such a set method exists in an extension class, Dubbo injects it into dependencies, which is similar to the injection of Spring&amp;rsquo;s set method. However, dependency injection in Dubbo is more complicated than that in Spring, because all the methods injected into Spring are Spring beans and managed by the Spring container. In Dubbo&amp;rsquo;s dependency injection, you may need to inject another extension of Dubbo, or a Spring Bean, or a component of Google guice, or a component in any other framework. Dubbo needs to be able to load extensions from any scenario. In the injectExtension method, it is implemented with &lt;code>Object object = objectFactory. getExtension (pt, property)&lt;/code>. ObjectFactory is ExtensionFactory type and initialized when creating ExtensionLoader:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">private&lt;/span> &lt;span style="color:#268bd2">ExtensionLoader&lt;/span>(Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&lt;/span> type) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">this&lt;/span>.type &lt;span style="color:#719e07">=&lt;/span> type;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> objectFactory &lt;span style="color:#719e07">=&lt;/span> (type &lt;span style="color:#719e07">==&lt;/span> ExtensionFactory.class &lt;span style="color:#719e07">?&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span> : ExtensionLoader.getExtensionLoader(ExtensionFactory.class).getAdaptiveExtension());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>ObjectFacore is also an extension, obtained through &lt;code>ExtensionLoader.getExtensionLoader(ExtensionFactory.class).getAdaptiveExtension()&lt;/code>.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-extensionfactory.png" alt="Dubbo-ExtensionFactory" title="">&lt;/p>
&lt;p>ExtensionFactory includes three implementations:&lt;/p>
&lt;ol>
&lt;li>SpiExtensionFactory: use Dubbo&amp;rsquo;s Spi to load Extension.&lt;/li>
&lt;li>SpringExtensionFactory: load Extension from the Spring container.&lt;/li>
&lt;li>AdaptiveExtensionFactory: adaptive AdaptiveExtensionLoader&lt;/li>
&lt;/ol>
&lt;p>Pay attention to the AdaptiveExtensionLoader here, the source code is as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Adaptive&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">AdaptiveExtensionFactory&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> ExtensionFactory {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> &lt;span style="color:#268bd2">final&lt;/span> List&lt;span style="color:#719e07">&amp;lt;&lt;/span>ExtensionFactory&lt;span style="color:#719e07">&amp;gt;&lt;/span> factories;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">AdaptiveExtensionFactory&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ExtensionLoader&lt;span style="color:#719e07">&amp;lt;&lt;/span>ExtensionFactory&lt;span style="color:#719e07">&amp;gt;&lt;/span> loader &lt;span style="color:#719e07">=&lt;/span> ExtensionLoader.getExtensionLoader(ExtensionFactory.class);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> List&lt;span style="color:#719e07">&amp;lt;&lt;/span>ExtensionFactory&lt;span style="color:#719e07">&amp;gt;&lt;/span> list &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ArrayList&lt;span style="color:#719e07">&amp;lt;&lt;/span>ExtensionFactory&lt;span style="color:#719e07">&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (String name : loader.getSupportedExtensions()) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> list.add(loader.getExtension(name));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> factories &lt;span style="color:#719e07">=&lt;/span> Collections.unmodifiableList(list);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> T &lt;span style="color:#268bd2">getExtension&lt;/span>(Class&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> type, String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (ExtensionFactory factory : factories) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> T extension &lt;span style="color:#719e07">=&lt;/span> factory.getExtension(type, name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (extension &lt;span style="color:#719e07">!=&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> extension;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The AdaptiveExtensionLoader class has @Adaptive annotations. As mentioned earlier, Dubbo creates an adaptive instance for each extension. If the extension class has @Adaptive annotations, it will use it as an adaptive class. If not, Dubbo will create one for us. So &lt;code>ExtensionLoader.getExtensionLoader(ExtensionFactory.class).getAdaptiveExtension())&lt;/code> will return an AdaptiveExtensionLoader instance as an adaptive extension instance.
The AdaptiveExtensionLoader will iterate through all the ExtensionFactory implementations and try to load the extensions. If found, return. If not, continue to find it in the next ExtensionFactory. Dubbo has two ExtensionFactory built in, which are searched from Dubbo&amp;rsquo;s own extension mechanism and Spring container. Since ExtensionFactory itself is also an extension point, we can implement our own ExtensionFactory to enable automatic assembly of Dubbo to support our custom components. For example, we used Google&amp;rsquo;s guice as an IoC container in our project. We can implement our own GuiceExtensionFactory to enable Dubbo to load extensions from the guice container.&lt;/p>
&lt;h2 id="aop-of-dubbo-spi-advanced-usage">AOP of Dubbo SPI advanced usage&lt;/h2>
&lt;p>We often use AOP functionality when using Spring. Insert other logic before and after the method of the target class. For example, Spring AOP is usually used to implement logging, monitoring, and authentication, and so on.
Does Dubbo&amp;rsquo;s extension mechanism also support similar features? The answer is yes. In Dubbo, there is a special class called the Wrapper class. It uses the wrapper class to wrap the original extension point instance through the decorator pattern, and then inserts additional logic before and after the original extension point implementation to implement AOP functionality.&lt;/p>
&lt;h3 id="what-is-the-wrapper-class">What is the Wrapper class&lt;/h3>
&lt;p>So what kind of class is the Wrapper class in the Dubbo extension mechanism? The Wrapper class is a class that has a replication constructor and also is a typical decorator pattern. Here&amp;rsquo;s a Wrapper class:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">A&lt;/span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> A a;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">A&lt;/span>(A a){
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">this&lt;/span>.a &lt;span style="color:#719e07">=&lt;/span> a;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Class A has a constructor &lt;code>public A(A a)&lt;/code>, and the argument to the constructor is A itself. Such a class can be a Wrapper class in the Dubbo extension mechanism. Such Wrapper classes in Dubbo include ProtocolFilterWrapper, ProtocolListenerWrapper, and so on. You can check the source code to deepen your understanding.&lt;/p>
&lt;h3 id="how-to-configure-the-wrapper-class">How to configure the Wrapper class&lt;/h3>
&lt;p>The Wrapper class in Dubbo is also an extension point. Like other extension points, it is also configured in the &lt;code>META-INF&lt;/code> folder. For example, the ProtocolFilterWrapper and ProtocolListenerWrapper in the previous example are configured in the path &lt;code>dubbo-rpc/dubbo-rpc-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-text" data-lang="text">&lt;span style="display:flex;">&lt;span>filter=org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>listener=org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>mock=org.apache.dubbo.rpc.support.MockProtocol
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>When Dubbo loads the extension configuration file, there is a piece of code as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">try&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> clazz.getConstructor(type);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Set&lt;span style="color:#719e07">&amp;lt;&lt;/span>Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&amp;gt;&lt;/span> wrappers &lt;span style="color:#719e07">=&lt;/span> cachedWrapperClasses;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (wrappers &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> cachedWrapperClasses &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ConcurrentHashSet&lt;span style="color:#719e07">&amp;lt;&lt;/span>Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> wrappers &lt;span style="color:#719e07">=&lt;/span> cachedWrapperClasses;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> wrappers.add(clazz);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>} &lt;span style="color:#719e07">catch&lt;/span> (NoSuchMethodException e) {}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The meaning of this code is that if the extension class has a copy constructor, it will be saved for later use. The class that has the copy constructor is the Wrapper class. The parameter obtained by &lt;code>clazz.getConstructor(type)&lt;/code> is the constructor of the extension point interface. Note that the parameter type of the constructor is an extension point interface, not an extension class.
Take Protocol as an example. The configuration file &lt;code>dubbo-rpc/dubbo-rpc-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol defines filter=org.apache.dubbo.rpc.protocol. ProtocolFilterWrapper&lt;/code>.
The code of ProtocolFilterWrapper is as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">ProtocolFilterWrapper&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> Protocol {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> &lt;span style="color:#268bd2">final&lt;/span> Protocol protocol;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// One parameter is the copy constructor of Protocol&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">ProtocolFilterWrapper&lt;/span>(Protocol protocol) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (protocol &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">throw&lt;/span> &lt;span style="color:#719e07">new&lt;/span> IllegalArgumentException(&lt;span style="color:#2aa198">&amp;#34;protocol == null&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">this&lt;/span>.protocol &lt;span style="color:#719e07">=&lt;/span> protocol;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>ProtocolFilterWrapper has a constructor &lt;code>public ProtocolFilterWrapper(Protocol protocol)&lt;/code>, and the parameter is the extension point Protocol. So it is a Wrapper class in the Dubbo extension mechanism. The ExtensionLoader will cache it. When creating Extension instances later, the ExtensionLoader use these wrapper classes to wrap the original Extension point in turn.&lt;/p>
&lt;h2 id="extension-point-adaptive">Extension point adaptive&lt;/h2>
&lt;p>As mentioned earlier, Dubbo needs to determine which extension to use based on method parameters at runtime. So there is an extension point adaptive instance. In fact, it is an extension point proxy that delays the selection of extensions from starting Dubbo to calling RPC. Each extension point in Dubbo has an adaptive class. If it is not explicitly provided, Dubbo will automatically create one for us. By default, Javaassist is used.
Let&amp;rsquo;s first look at the code to create an adaptive extension class:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> T &lt;span style="color:#268bd2">getAdaptiveExtension&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Object instance &lt;span style="color:#719e07">=&lt;/span> cachedAdaptiveInstance.get();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (instance &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">synchronized&lt;/span> (cachedAdaptiveInstance) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> instance &lt;span style="color:#719e07">=&lt;/span> cachedAdaptiveInstance.get();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (instance &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> instance &lt;span style="color:#719e07">=&lt;/span> createAdaptiveExtension();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> cachedAdaptiveInstance.set(instance);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> (T) instance;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Continue to read the createAdaptiveExtension method:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">private&lt;/span> T &lt;span style="color:#268bd2">createAdaptiveExtension&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> injectExtension((T) getAdaptiveExtensionClass().newInstance());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Continue to read the getAdaptiveExtensionClass method:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">private&lt;/span> Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&lt;/span> getAdaptiveExtensionClass() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> getExtensionClasses();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (cachedAdaptiveClass &lt;span style="color:#719e07">!=&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> cachedAdaptiveClass;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> cachedAdaptiveClass &lt;span style="color:#719e07">=&lt;/span> createAdaptiveExtensionClass();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Continue to read the createAdaptiveExtensionClass method. After a long journey, we finally come to a concrete realization. Look at this createAdaptiveExtensionClass method, which first generates the Java source code for the adaptive class, and then compile the source code into Java bytecode and load it into the JVM.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">private&lt;/span> Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&lt;/span> createAdaptiveExtensionClass() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String code &lt;span style="color:#719e07">=&lt;/span> createAdaptiveExtensionClassCode();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ClassLoader classLoader &lt;span style="color:#719e07">=&lt;/span> findClassLoader();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> org.apache.dubbo.common.compiler.Compiler compiler &lt;span style="color:#719e07">=&lt;/span> ExtensionLoader.getExtensionLoader(org.apache.dubbo.common.compiler.Compiler.class).getAdaptiveExtension();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> compiler.compile(code, classLoader);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The default implementation of Compiler&amp;rsquo;s code is javassist.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@SPI&lt;/span>(&lt;span style="color:#2aa198">&amp;#34;javassist&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">Compiler&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&lt;/span> compile(String code, ClassLoader classLoader);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The createAdaptiveExtensionClassCode () method uses a StringBuilder to build Java source code for the adaptive class. The method implementation is relatively long, and the code is not posted here. The approach to bytecode generation is also interesting, first generating Java source code, then compiling it and loading it into the jvm. In this way, the generated Java class can be better controlled. And it doesn&amp;rsquo;t have to care about the API of the bytecode generation framework. Because the xxx.java file is universal in Java, it is also the one we are most familiar with. However, the code is not very readable and you need to build xx. Java content bit by bit.
Below are the Java code example for Protocol adaptive class created by createAdaptiveExtensionClassCode method:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> org.apache.dubbo.rpc;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.apache.dubbo.common.extension.ExtensionLoader;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">Protocol$Adaptive&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> org.apache.dubbo.rpc.Protocol {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">destroy&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">throw&lt;/span> &lt;span style="color:#719e07">new&lt;/span> UnsupportedOperationException(&lt;span style="color:#2aa198">&amp;#34;method public abstract void org.apache.dubbo.rpc.Protocol.destroy() of interface org.apache.dubbo.rpc.Protocol is not adaptive method!&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">int&lt;/span> &lt;span style="color:#268bd2">getDefaultPort&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">throw&lt;/span> &lt;span style="color:#719e07">new&lt;/span> UnsupportedOperationException(&lt;span style="color:#2aa198">&amp;#34;method public abstract int org.apache.dubbo.rpc.Protocol.getDefaultPort() of interface org.apache.dubbo.rpc.Protocol is not adaptive method!&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> org.apache.dubbo.rpc.Exporter &lt;span style="color:#268bd2">export&lt;/span>(org.apache.dubbo.rpc.Invoker arg0) &lt;span style="color:#268bd2">throws&lt;/span> org.apache.dubbo.rpc.RpcException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (arg0 &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) &lt;span style="color:#719e07">throw&lt;/span> &lt;span style="color:#719e07">new&lt;/span> IllegalArgumentException(&lt;span style="color:#2aa198">&amp;#34;org.apache.dubbo.rpc.Invoker argument == null&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (arg0.getUrl() &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">throw&lt;/span> &lt;span style="color:#719e07">new&lt;/span> IllegalArgumentException(&lt;span style="color:#2aa198">&amp;#34;org.apache.dubbo.rpc.Invoker argument getUrl() == null&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> org.apache.dubbo.common.URL url &lt;span style="color:#719e07">=&lt;/span> arg0.getUrl();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String extName &lt;span style="color:#719e07">=&lt;/span> (url.getProtocol() &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span> &lt;span style="color:#719e07">?&lt;/span> &lt;span style="color:#2aa198">&amp;#34;dubbo&amp;#34;&lt;/span> : url.getProtocol());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (extName &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">throw&lt;/span> &lt;span style="color:#719e07">new&lt;/span> IllegalStateException(&lt;span style="color:#2aa198">&amp;#34;Fail to get extension(org.apache.dubbo.rpc.Protocol) name from url(&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> url.toString() &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#34;) use keys([protocol])&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> org.apache.dubbo.rpc.Protocol extension &lt;span style="color:#719e07">=&lt;/span> (org.apache.dubbo.rpc.Protocol) ExtensionLoader.getExtensionLoader(org.apache.dubbo.rpc.Protocol.class).getExtension(extName);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> extension.export(arg0);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> org.apache.dubbo.rpc.Invoker &lt;span style="color:#268bd2">refer&lt;/span>(java.lang.Class arg0, org.apache.dubbo.common.URL arg1) &lt;span style="color:#268bd2">throws&lt;/span> org.apache.dubbo.rpc.RpcException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (arg1 &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) &lt;span style="color:#719e07">throw&lt;/span> &lt;span style="color:#719e07">new&lt;/span> IllegalArgumentException(&lt;span style="color:#2aa198">&amp;#34;url == null&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> org.apache.dubbo.common.URL url &lt;span style="color:#719e07">=&lt;/span> arg1;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String extName &lt;span style="color:#719e07">=&lt;/span> (url.getProtocol() &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span> &lt;span style="color:#719e07">?&lt;/span> &lt;span style="color:#2aa198">&amp;#34;dubbo&amp;#34;&lt;/span> : url.getProtocol());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (extName &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">throw&lt;/span> &lt;span style="color:#719e07">new&lt;/span> IllegalStateException(&lt;span style="color:#2aa198">&amp;#34;Fail to get extension(org.apache.dubbo.rpc.Protocol) name from url(&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> url.toString() &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#34;) use keys([protocol])&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> org.apache.dubbo.rpc.Protocol extension &lt;span style="color:#719e07">=&lt;/span> (org.apache.dubbo.rpc.Protocol) ExtensionLoader.getExtensionLoader(org.apache.dubbo.rpc.Protocol.class).getExtension(extName);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> extension.refer(arg0, arg1);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The general logic is the same as at the beginning. The parameters are parsed through the url, and the parsed logic is controlled by the value parameter of @adaptive, and then the extension points implementation are obtained according to the name of the extension point. And then finally make the call. If you want to know the specific construction logic of .Java code, you can see the complete implementation of &lt;code>createAdaptiveExtensionClassCode&lt;/code>.
In the generated Protocol$Adaptive, both the getDefaultPort and destroy methods are found to throw the exception directly. Why? Take a look at the source code of Protocol:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@SPI&lt;/span>(&lt;span style="color:#2aa198">&amp;#34;dubbo&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">Protocol&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#dc322f">int&lt;/span> &lt;span style="color:#268bd2">getDefaultPort&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Adaptive&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> Exporter&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">export&lt;/span>(Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> invoker) &lt;span style="color:#268bd2">throws&lt;/span> RpcException;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Adaptive&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">refer&lt;/span>(Class&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> type, URL url) &lt;span style="color:#268bd2">throws&lt;/span> RpcException;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">destroy&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>As you can see, there are four methods in the Protocol interface, but only the methods of export and refer use the @Adaptive annotation. Dubbo automatically generates adaptive instances, and only the methods modified by @Adaptive has a specific implementation. Therefore, in the Protocol$Adaptive class, only the export and refer methods have specific implementations, and the rest of the methods throw exceptions.&lt;/p></description></item><item><title>Blog: Dubbo extensible mechanism source code analysis - part 1</title><link>https://dubbo.apache.org/en/blog/2019/04/25/dubbo-extensible-mechanism-source-code-analysis-part-1/</link><pubDate>Thu, 25 Apr 2019 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2019/04/25/dubbo-extensible-mechanism-source-code-analysis-part-1/</guid><description>
&lt;h2 id="1-extension-mechanism-of-dubbo">1. Extension Mechanism of Dubbo&lt;/h2>
&lt;p>Dubbo is claimed as a high-performance RPC framework on its official website. Today, I want to talk about another great specialty of Dubbo &amp;mdash; its scalability. As quote: Rome wasn’t built in a day. Any successful system always starts as a prototype. It is impossible to design a perfect system at the beginning. Instead, we should focus on true demand and keep improving the system. On the coding side, it requires us to pay attention on abstraction layers and high-level isolation. In that case, the system could keep a healthy structure and easy to maintain while new features or third-party extensions are added. Under some circumstances, a designer should pursue more of scalability than the system’s current performance.
When talking about software design, people always mention scalability. A framework with good scalability requires the following:
1.The framework should follow opening/closed principle: software entities should be open for extension, but closed for modification; This means a framework should allow the maintainer to add new functions with as few modifications as possible.
2.The framework should allow the user to add new functions by adding code on his project without modifying the framework&amp;rsquo;s original source code base.
With microkernel architecture and extension mechanism, Dubbo satisfies such requirements and achieves good scalability. In the following chapters, we will discuss Dubbo&amp;rsquo;s extension mechanism in detail.&lt;/p>
&lt;h2 id="2extension-solutions">2.Extension Solutions&lt;/h2>
&lt;p>Creating Extensible applications usually considers:&lt;/p>
&lt;ul>
&lt;li>Factory method pattern&lt;/li>
&lt;li>IoC container&lt;/li>
&lt;li>OSGi (Open Services Gateway initiative)&lt;/li>
&lt;/ul>
&lt;p>As a framework, Dubbo does not wish to rely on other IoC containers such as Spring, Guice. OSGi is too complicated to fit Dubbo. In the end, Dubbo SPI is inherited from standard JDK SPI and makes it more powerful.&lt;/p>
&lt;h2 id="3java-spi-mechanism">3.Java SPI Mechanism&lt;/h2>
&lt;p>We will first discuss Java SPI mechanism, which is a basis for understanding Dubbo’s extension mechanism. If you are familiar with Java SPI, you can skip this part.&lt;/p>
&lt;p>Java SPI (Service Provider Interface) is a feature for discovering and loading implementations matching a given interface provided in JDK. We can create a text file with the same name as the interface under resource directory &lt;code>META-INF/services&lt;/code>. The content of the file is the fully qualified class name of the SPI implementation, in which each component is separated by a line breaker. JDK uses &lt;code>java.util.ServiceLoader&lt;/code> to load implementations of a service. Let us use a simple example to show how Java SPI works.&lt;/p>
&lt;ol>
&lt;li>Define an interface IRepository to store data.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">IRepository&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">save&lt;/span>(String data);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="2">
&lt;li>Create 2 implementations for IRepository: MysqlRepository and MongoRepository&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">MysqlRepository&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> IRepository {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">save&lt;/span>(String data) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;Save &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> data &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#34; to Mysql&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">MongoRepository&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> IRepository {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">save&lt;/span>(String data) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;Save &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> data &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#34; to Mongo&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="3">
&lt;li>Create a configuration file under &lt;code>META-INF/services&lt;/code>.&lt;/li>
&lt;/ol>
&lt;p>The file name is &lt;code>META-INF/services/com.demo.IRepository&lt;/code>, the content of file is:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-text" data-lang="text">&lt;span style="display:flex;">&lt;span>com.demo.MongoRepository
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>com.demo.MysqlRepository
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="4">
&lt;li>Load IRepository using ServiceLoader&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>ServiceLoader&lt;span style="color:#719e07">&amp;lt;&lt;/span>IRepository&lt;span style="color:#719e07">&amp;gt;&lt;/span> serviceLoader &lt;span style="color:#719e07">=&lt;/span> ServiceLoader.load(IRepository.class);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Iterator&lt;span style="color:#719e07">&amp;lt;&lt;/span>IRepository&lt;span style="color:#719e07">&amp;gt;&lt;/span> it &lt;span style="color:#719e07">=&lt;/span> serviceLoader.iterator();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">while&lt;/span> (it &lt;span style="color:#719e07">!=&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span> &lt;span style="color:#719e07">&amp;amp;&amp;amp;&lt;/span> it.hasNext()){
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> IRepository demoService &lt;span style="color:#719e07">=&lt;/span> it.next();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;class:&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> demoService.getClass().getName());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> demoService.save(&lt;span style="color:#2aa198">&amp;#34;tom&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In the above example, we created an extension and two of its applications. We created the configuration file in ClassPath and loaded the extensions using ServiceLoader. The final output is:
class:testDubbo.MongoRepository
Save tom to Mongo
class:testDubbo.MysqlRepository
Save tom to Mysql&lt;/p>
&lt;h2 id="4-dubbo-spi-mechanism">4. Dubbo SPI Mechanism&lt;/h2>
&lt;p>Java SPI is simple to use. It also supports basic extension point functions, however, it has some disadvantages:&lt;/p>
&lt;ul>
&lt;li>It will load and instantiate all implementations at once to find the requested implementation.&lt;/li>
&lt;li>The configuration file only includes the extension implementation but does not name them, which makes it hard to reference them in applications.&lt;/li>
&lt;li>If extensions depend on other extensions, Java SPI cannot automatically load the dependency SPI.&lt;/li>
&lt;li>It does not provide functions such as IOC or AOP in Spring.&lt;/li>
&lt;li>It is hard to assemble extensions with other frameworks. For example, if the extension depends on Spring bean, the original Java SPI will not support it.&lt;/li>
&lt;/ul>
&lt;p>Therefore, Java SPI is good for some simple scenarios, but does not fit for Dubbo. Dubbo makes some extensions on the original SPI mechanism. We will discuss more about the Dubbo SPI mechanism in the following sections.&lt;/p>
&lt;h2 id="5-basic-concepts-for-dubbo-extension-point-mechanism">5. Basic Concepts for Dubbo Extension Point Mechanism&lt;/h2>
&lt;p>Before diving into Dubbo&amp;rsquo;s extension mechanism,Let us first declare some basic concepts in Dubbo SPI. Those terms will appear multiple times in the following section.&lt;/p>
&lt;h3 id="51-extension-point">5.1 Extension Point&lt;/h3>
&lt;p>an interface of java.&lt;/p>
&lt;h3 id="52-extension">5.2 Extension&lt;/h3>
&lt;p>an implementation class of the Extension Point&lt;/p>
&lt;h3 id="53-extension-instance">5.3 Extension Instance&lt;/h3>
&lt;p>instance of an extension point implementation class&lt;/p>
&lt;h3 id="54-extension-adaptive-instance">5.4 Extension Adaptive Instance&lt;/h3>
&lt;p>Maybe it is a little difficult to understand this concept when hearing about it the first time. It may help you understand it better by calling it an extension proxy class. The extension adaptive instance is actually an extension proxy, which implements the method of extension point interface. When calling the interface method of the extension point, it will decide which extension to use according to the actual parameters. For example, the extension point of an IRepository has one save method, and two implementations MysqlRepository and MongoRepository. When calling the method of the interface, the adaptive instance of IRepository will determine which IRepository implementation to call according to the parameters in the save method. If the parameter repository=mysql in the method, then we can call the save method of MysqlRepository. If repository=mongo, then we can call the save method of MongoRepository, which is similar to late binding in Object-oriented languages. However, why does Dubbo introduce the concept of extended adaptive instances?&lt;/p>
&lt;ul>
&lt;li>There are two configurations in Dubbo, one is a fixed system-level configuration and it will not be changed after Dubbo launches. Another is the run-time configuration that may be different for each RPC. For instance, the timeout is configured as 10 seconds in the xml file, which will not change after Dubbo launches. However, for a certain PRC call, we can set its timeout to 30 seconds so as to override the system-level configuration. For Dubbo, the parameters called in each RPC is unknown and only at run-time can you make the right decision according to revealed parameters.&lt;/li>
&lt;li>Our class is usually singleton-scaled, such as beans of Spring IoC Container. When instantiating beans, if it depends on some specific extension point, it will know which extension to use, otherwise, the bean will not know how to choose extensions. At this time, a proxy mode is needed, which implements the interface of an extension point. The method can dynamically select the appropriate extension according to the run-time parameters, and this proxy is an adaptive instance. Adaptive extension instance is widely used in Dubbo, in Dubbo, each extension will have an adaptive class, and if we do not provide it, Dubbo will automatically generate one for us by using the bytecode encoder. Therefore, we basically don&amp;rsquo;t recognize the existence of adaptive classes. We will explain how the adaptive class works in later chapters.&lt;/li>
&lt;/ul>
&lt;h3 id="55-spi">5.5 @SPI&lt;/h3>
&lt;p>@SPI annotation works on the interface of the extension point, which indicates that the interface is an extension point, and can be loaded by Dubbo ExtensionLoader. If there is no such ExtentionLoader, the call will throw an exception.&lt;/p>
&lt;h3 id="56-adaptive">5.6 @Adaptive&lt;/h3>
&lt;p>@Adaptive annotation is used on the method that extends the interface, which indicates an adaptive method. When Dubbo generates an adaptive instance for an extension point, if the function has @Adaptive annotation, then Dubbo will generate the corresponding code for the method. The method determines which extension to use according to the parameters. When @Adaptive annotation is used on the class to implement a Decorator class, it is similar to the Decorator pattern, whose major function is to return a specified class. Currently in Dubbo, both AdaptiveCompiler and AdaptiveExtensionFactory have @Adaptive annotation.&lt;/p>
&lt;h3 id="57-extensionloader">5.7 ExtensionLoader&lt;/h3>
&lt;p>Similar to the Java SPI ServiceLoader, it is responsible for loading extensions and life-cycle maintenance.&lt;/p>
&lt;h3 id="58-extension-alias">5.8 Extension Alias&lt;/h3>
&lt;p>Different from Java, each extension in Dubbo has an alias, which is used to reference them in the application, such as&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">random&lt;/span>&lt;span style="color:#719e07">=&lt;/span>com.alibaba.dubbo.rpc.cluster.loadbalance.RandomLoadBalance
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">roundrobin&lt;/span>&lt;span style="color:#719e07">=&lt;/span>com.alibaba.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalance
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>where random, roundrobin are alias of the corresponding extensions, and we can directly use them in the configuration file.&lt;/p>
&lt;h3 id="59-paths">5.9 Paths&lt;/h3>
&lt;p>Similar to the way Java SPI loading the extension configuration from the &lt;code>META-INF/services&lt;/code> directory, Dubbo will also load the extension configuration file from the following path:&lt;/p>
&lt;ul>
&lt;li>&lt;code>META-INF/dubbo/internal&lt;/code>&lt;/li>
&lt;li>&lt;code>META-INF/dubbo&lt;/code>&lt;/li>
&lt;li>&lt;code>META-INF/services&lt;/code>&lt;/li>
&lt;/ul>
&lt;h2 id="6-interpretation-for-dubbos-loadbalance-extension-point">6. Interpretation for Dubbo&amp;rsquo;s LoadBalance Extension Point&lt;/h2>
&lt;p>Now that we know some basic idea about Dubbo, let us check a practical extension point in Dubbo to get some intuition.&lt;/p>
&lt;p>We take the Dubbo’s LoadBalance extension point as an example. A service in Dubbo usually has multiple providers. When a consumer calls the service, he needs to choose one of the providers. This is an example of LoadBalance. Now, let us figure out how LoadBalance becomes an extension point in Dubbo.&lt;/p>
&lt;h3 id="61-loadbalance-interfance">6.1 LoadBalance Interfance&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@SPI&lt;/span>(RandomLoadBalance.NAME)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">LoadBalance&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Adaptive&lt;/span>(&lt;span style="color:#2aa198">&amp;#34;loadbalance&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">select&lt;/span>(List&lt;span style="color:#719e07">&amp;lt;&lt;/span>Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&amp;gt;&lt;/span> invokers, URL url, Invocation invocation) &lt;span style="color:#268bd2">throws&lt;/span> RpcException;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>LoadBalance interface has only one select method. Select method chose one invoker among multiple invokers. In the code above, the elements related to Dubbo SPI are:&lt;/p>
&lt;ul>
&lt;li>@SPI(RandomLoadBalance.NAME) @SPI is used for LoadBalance interface, which indicates that the LoadBalance interface is an extension point. Without the @SPI annotation, if we try to load the extension, it will throw an exception. @SPI annotation has one parameter, and this parameter represents the Alias of the default implementation of the extension point. If there has no explicitly specified extension, the default implementation will be used.
&lt;code>RandomLoadBalance.NAME&lt;/code> is a constant with value “random” and is a random load balancing implementation. The definition of random is in the configuration file &lt;code>META-INF/dubbo/internal/com.alibaba.dubbo.rpc.cluster.LoadBalance&lt;/code>:&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">random&lt;/span>&lt;span style="color:#719e07">=&lt;/span>com.alibaba.dubbo.rpc.cluster.loadbalance.RandomLoadBalance
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">roundrobin&lt;/span>&lt;span style="color:#719e07">=&lt;/span>com.alibaba.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalance
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">leastactive&lt;/span>&lt;span style="color:#719e07">=&lt;/span>com.alibaba.dubbo.rpc.cluster.loadbalance.LeastActiveLoadBalance
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">consistenthash&lt;/span>&lt;span style="color:#719e07">=&lt;/span>com.alibaba.dubbo.rpc.cluster.loadbalance.ConsistentHashLoadBalance
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>There are four extension implementations of LoadBalance defined in the configuration file. The implementation of load balancing will not be covered in this article. The only thing we need to know is that Dubbo provides four kinds of load balancing implementations. We can explicitly specify an implementation by using xml file, properties file or JVM parameter. If there has no explicitly specified implementation, Dubbo will use random as default.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo_loadbalance.png" alt="img">&lt;/p>
&lt;ul>
&lt;li>@Adaptive(&amp;ldquo;loadbalance&amp;rdquo;) Applying @Adaptive annotation on select method indicates that select method is an adaptive method. Dubbo will automatically generate the corresponding code for the method. When select method is called, it will decide which extension to apply based on the method parameters. @Adaptive parameter &lt;code>loadbalance&lt;/code> indicates that the value of loadbalance in method is the extension implementation that will be actually called. However, we cannot find loadbalance parameter in select method, then how can we obtain the value of loadbalance? There is another URL-type parameter in select method, and Dubbo obtains the value of loadbalance from that URL. Here we need to use Dubbo’s URL bus pattern, in one word, URL contains all the parameters in RPC. There is a member variable &lt;code>Map&amp;lt;String, String&amp;gt;parameters&lt;/code> in the URL class, which contains loadbalance as a parameter&lt;/li>
&lt;/ul>
&lt;h3 id="62-obtain-loadbalance-extension">6.2 Obtain LoadBalance extension&lt;/h3>
&lt;p>The code of LoadBalance in Dubbo is as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>LoadBalance lb &lt;span style="color:#719e07">=&lt;/span> ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(loadbalanceName);
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Using ExtensionLoader.getExtensionLoader(LoadBalance.class) method to obtain an implementation of ExtensionLoader, then we call getExtension and pass an extension alias to obtain the corresponding extension implementation.&lt;/p>
&lt;h2 id="7-customize-a-loadbalance-extension">7. Customize a LoadBalance Extension&lt;/h2>
&lt;p>In this session, we will use a simple example to implement a LoadBalance and integrate it into Dubbo. I will show some important steps and codes, and the complete demo can be downloaded from the following address(&lt;a href="https://github.com/vangoleo/dubbo-spi-demo">https://github.com/vangoleo/dubbo-spi-demo&lt;/a>).&lt;/p>
&lt;h3 id="71-implement-loadbalance-interface">7.1 implement LoadBalance Interface&lt;/h3>
&lt;p>First, we build a LoadBalance instance. Since we just need the instance to demonstrate Dubbo extension mechanism, it will be very simple. We choose the first invoker and print a log sentence in the console.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> com.dubbo.spi.demo.consumer;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DemoLoadBalance&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> LoadBalance {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">select&lt;/span>(List&lt;span style="color:#719e07">&amp;lt;&lt;/span>Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&amp;gt;&lt;/span> invokers, URL url, Invocation invocation) &lt;span style="color:#268bd2">throws&lt;/span> RpcException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;DemoLoadBalance: Select the first invoker...&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> invokers.get(0);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="72-add-extension-configuration-file">7.2 Add extension configuration file&lt;/h3>
&lt;p>Add file:&lt;code>META-INF/dubbo/com.alibaba.dubbo.rpc.cluster.LoadBalance&lt;/code>. The content of file is:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">demo&lt;/span>&lt;span style="color:#719e07">=&lt;/span>com.dubbo.spi.demo.consumer.DemoLoadBalance
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="73-configure-customized-loadbalance">7.3 Configure customized LoadBalance&lt;/h3>
&lt;p>Through the above 2 steps, we have already added a LoadBalance implementation named demo, and set up the configuration file. In the next step, we need to explicitly tell Dubbo to implement the demo while doing load balancing. If we use Dubbo through spring, we could set it up in the xml file.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:reference&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;helloService&amp;#34;&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;com.dubbo.spi.demo.api.IHelloService&amp;#34;&lt;/span> loadbalance=&lt;span style="color:#2aa198">&amp;#34;demo&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Configure &amp;lt;loadbalance=&amp;ldquo;demo&amp;rdquo;&amp;gt; in &lt;a href="dubbo:reference">dubbo:reference&lt;/a> at consumer part.&lt;/p>
&lt;h3 id="74-launch-dubbo">7.4 launch Dubbo&lt;/h3>
&lt;p>Launch Dubbo and call IHelloService, the console will output log: &lt;code>DemoLoadBalance: Select the first invoker...&lt;/code>, which means Dubbo does use our customized LoadBalance.&lt;/p>
&lt;h2 id="summary">Summary&lt;/h2>
&lt;p>So far, we learnt the basic concepts of Dubbo SPI beginning with Java SPI, and we used LoadBalance in Dubbo as an example to help us understand better. Finally, we practiced and created a customized LoadBalance and integrated it to Dubbo. We believe that combining concepts and practice, everyone can get a better idea of Dubbo’s scalability. To summarize, Dubbo SPI has the following features:&lt;/p>
&lt;ul>
&lt;li>Build extensions on Dubbo does not require modifications on the original source code base.&lt;/li>
&lt;li>The customized Dubbo extension point implementation is a normal Java class. Dubbo does not introduce any specialized elements, and have almost zero code intrusion.
*Extension registration on Dubbo requires only configuration file under the ClassPath directory. It is simple to use and has no effect on the existing code. This meets opening/closed principle.&lt;/li>
&lt;li>Dubbo&amp;rsquo;s extension mechanism default: @SPI(&amp;ldquo;dubbo&amp;rdquo;) represents the default SPI object.&lt;/li>
&lt;li>Dubbo&amp;rsquo;s extension mechanism supports the advanced features such as IoC and AoP, etc.&lt;/li>
&lt;li>Dubbo&amp;rsquo;s extension mechanism supports third-party IoC containers. It supports Spring beans by default and can be extended to other containers, such as Google/Guice.&lt;/li>
&lt;li>It is easy to switch the implementation of the extension point because it requires only modifications on the specific implementation in the configuration file without changing the code.&lt;/li>
&lt;/ul>
&lt;p>In the next article, we will go deep and check Dubbo&amp;rsquo;s source code to learn more about Dubbo&amp;rsquo;s extensibility mechanism.&lt;/p></description></item><item><title>Blog: Implementation background and practice of Dubbo client asynchronous interface</title><link>https://dubbo.apache.org/en/blog/2019/02/20/implementation-background-and-practice-of-dubbo-client-asynchronous-interface/</link><pubDate>Wed, 20 Feb 2019 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2019/02/20/implementation-background-and-practice-of-dubbo-client-asynchronous-interface/</guid><description>
&lt;h2 id="preface">Preface&lt;/h2>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubboasyn_client/1_en.png" alt="image | left">&lt;/p>
&lt;p>Let&amp;rsquo;s start with a brief introduction about the stages of a complete Dubbo invocation.&lt;/p>
&lt;ol>
&lt;li>
&lt;p>Biz~ represents business thread, that is, the thread where the business logic is located. Biz~ thread pool may be created and maintained by business itself, most of which may be managed by system framework itself (for example, a web system runs under Tomcat container, Biz~ thread is maintained by Tomcat); IO~ stands for network data processing thread, which is created and maintained by IO framework (such as Netty, Grizzly). Dubbo Remoting&amp;rsquo;s default Netty implementation is NioEventloopLoopGroup. In addition, according to the binding relationship between Channel and IO thread, IO~ can also be regarded as an acceptable Channel for event messages. Asynchronous processing stages such as Biz and IO are abstractly described in JDK8 as completionstages.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>As we all know, the way of data communication between threads is shared variables. The data communication between Biz and IO is Queue. Specifically to Dubbo, Biz put a task in EventLoop&amp;rsquo;s LinkedBlockingQueue in the client side implementation (i.e. the steps labeled in Figure 1 above), and the corresponding Thread in the EventLoop will keep iteration the Queue to keep on executing the information the task contains. Specific code can refer to SingleThreadEventExecutor (by the way, the default is to use in the Netty is capacity-free LinkedBlockingQueue, when the Biz processing rate higher than the rate of network, there seems to be a Memory Leak risk).&lt;/p>
&lt;/li>
&lt;li>
&lt;p>As shown in the figure above, a standard RPC call passes through four message (event) transfers of 1,2,3,4, respectively are the client business thread sending requests to the client IO thread, the server business logic thread receiving the server IO thread requests, the server logic thread responding to the server IO thread after processing, and the client IO thread receiving the results feedback to the business logic thread.&lt;/p>
&lt;/li>
&lt;/ol>
&lt;h2 id="client-asynchronization">Client Asynchronization&lt;/h2>
&lt;h3 id="background">Background&lt;/h3>
&lt;p>In the Java language (other languages are not clear), a call of the local interface can be transparently converted into the call of remote RPC through the proxy mechanism. Most business parties prefer this programming method similar to the local interface to do remote service invocation. Therefore, although RPC is naturally asynchronous internally, users using Dubbo mostly use synchronization, while asynchrony becomes a minority use scenario. The advantage of synchronization is that the programming model is more in line with the &amp;ldquo;traditional&amp;rdquo; habits of the business side. The cost is that the current Biz~threads need to be blocked after the request event represented by 1 in the figure, and can not be awakened until the response processing represented by 4. In the process of 1,2,3,4, which is short in microsecond level and long in second level, the Biz~ thread will be blocked, which will consume thread resources and increase the overhead of system resources.&lt;/p>
&lt;p>Therefore, the motivation of client asynchronization is to save thread resource overhead at the cost of understanding how asynchronization is used. In the synchronous mode, the return type of API interface represents a certain business class, while in the asynchronous case, the response and the request are completely independent events, so it is most suitable for the return type of API interface to be CompletionStage mentioned above, which is the inevitable asynchronization supported by Dubbo on asynchronization. Back to the latest Dubbo release, without changing the interface, you need to register a callback interface to handle the response return event when the service is created.&lt;/p>
&lt;p>The example blow is to illustrate it.&lt;/p>
&lt;h3 id="the-sample">The sample&lt;/h3>
&lt;p>Refer to the example code for event notification: &lt;a href="https://github.com/dubbo/dubbo-samples/tree/master/2-advanced/dubbo-samples-notify">https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-notify&lt;/a>&lt;/p>
&lt;p>Event notification allows the Consumer to trigger &amp;lsquo;oninvoke&amp;rsquo;, &amp;lsquo;onreturn&amp;rsquo; and &amp;lsquo;onthrow&amp;rsquo; events, which respectively represent before the call, after the call returns normally, or when an exception occurs.&lt;/p>
&lt;p>You can specify a method for notifying events when configuring the Consumer, such as:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;bean&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;demoCallback&amp;#34;&lt;/span> class=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.notify.impl.NotifyImpl&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:reference&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;demoService&amp;#34;&lt;/span> check=&lt;span style="color:#2aa198">&amp;#34;false&amp;#34;&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.notify.api.DemoService&amp;#34;&lt;/span> version=&lt;span style="color:#2aa198">&amp;#34;1.0.0&amp;#34;&lt;/span> group=&lt;span style="color:#2aa198">&amp;#34;cn&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:method&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;sayHello&amp;#34;&lt;/span> onreturn=&lt;span style="color:#2aa198">&amp;#34;demoCallback.onreturn&amp;#34;&lt;/span> onthrow=&lt;span style="color:#2aa198">&amp;#34;demoCallback.onthrow&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/dubbo:reference&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The code for NotifyImpl is as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">NotifyImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> Notify{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>Integer, String&lt;span style="color:#719e07">&amp;gt;&lt;/span> ret &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> HashMap&lt;span style="color:#719e07">&amp;lt;&lt;/span>Integer, String&lt;span style="color:#719e07">&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">onreturn&lt;/span>(String name, &lt;span style="color:#dc322f">int&lt;/span> id) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ret.put(id, name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;onreturn: &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">onthrow&lt;/span>(Throwable ex, String name, &lt;span style="color:#dc322f">int&lt;/span> id) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;onthrow: &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>It is important to note that the parameters for the three methods in the custom Notify interface are as follows:&lt;/p>
&lt;ul>
&lt;li>&lt;code>oninvoke&lt;/code> The parameters of the method are the same as those of the calling method.&lt;/li>
&lt;li>&lt;code>onreturn&lt;/code> The first parameter of the method is the return value of the calling method, and the rest is the parameters of the calling method.&lt;/li>
&lt;li>&lt;code>onthrow&lt;/code> The first parameter to the method is the call exception, and the rest is the parameter to the calling method.&lt;/li>
&lt;/ul>
&lt;p>In the above configuration, the &lt;code>sayHello&lt;/code> method is called synchronously, so the execution of the event notification method is also synchronously executed. &lt;code>async=true&lt;/code> can be configured to make the method call asynchronous, and the notification event method is also executed asynchronously. In particular, the &lt;code>oninvoke&lt;/code> method executes synchronously, regardless of whether it is invoked asynchronously or not.&lt;/p>
&lt;h3 id="practical-advice">Practical advice&lt;/h3>
&lt;ul>
&lt;li>
&lt;div data-type="alignment" data-value="justify" style="text-align:justify">
&lt;div data-type="p">Logical Non-Strongly dependent results after RPC invocation: Asynchronous callbacks are suitable for client-side asynchronous invocation when the client &lt;strong>is not strongly dependent on the server response&lt;/strong>.&lt;/div>
&lt;/div>
&lt;/li>
&lt;li>
&lt;div data-type="alignment" data-value="justify" style="text-align:justify">
&lt;div data-type="p">RX scenario: after learning about reactive programming model, I believe that as long as the programming thinking can embrace reactive and the state machine design of business model can be adjusted appropriately, asynchronous solutions can be applied in all scenarios, so as to achieve better terminal response experience. For Dubbo, the current asynchronous interface model needs to be improved like the reactive model interface in order to make the user more naturally apply the asynchronous interface. &lt;/div>
&lt;/div>
&lt;/li>
&lt;/ul>
&lt;h3 id="conclusions">Conclusions&lt;/h3>
&lt;ul>
&lt;li>The motivation of client asynchronization is that the request sending and response processing are two different independent events, how the response is handled and in which thread is handled are not required to be coupled with the business logic thread of the request sending event.&lt;/li>
&lt;li>The processing logic of response event callbacks in which thread to process is to be selected according to the situation. It is recommended that if the callback logic is relatively simple, it should be directly in the IO thread; if it contains IO type synchronization operations such as remote access or DB access, it is recommended that it be processed in a separate thread pool.&lt;/li>
&lt;/ul></description></item><item><title>Blog: Implementation background and practice of Dubbo server asynchronous interface</title><link>https://dubbo.apache.org/en/blog/2019/02/20/implementation-background-and-practice-of-dubbo-server-asynchronous-interface/</link><pubDate>Wed, 20 Feb 2019 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2019/02/20/implementation-background-and-practice-of-dubbo-server-asynchronous-interface/</guid><description>
&lt;h2 id="preface">Preface&lt;/h2>
&lt;p>It is suggested to make an understanding of the thread phase involved in the process of Dubbo first, please refer to &lt;a href="https://dubbo.apache.org/en/blog/2019/02/20/implementation-background-and-practice-of-dubbo-client-asynchronous-interface/">Implementation background and practice of Dubbo client asynchronous interface&lt;/a> for details.&lt;/p>
&lt;h2 id="implementation-background">Implementation background&lt;/h2>
&lt;p>It is necessary to introduce the server-side thread strategy in more detail to deepen the user&amp;rsquo;s judgment basis for selecting server-side asynchrony. It is also necessary to introduce coroutines, the &amp;ldquo;secret weapon&amp;rdquo; often used in server-side asynchrony.&lt;/p>
&lt;h3 id="server-side-thread-strategy">Server-side thread strategy&lt;/h3>
&lt;p>Dubbo supports a variety of NIO frameworks to implement remoting protocols. Whether Netty, Mina or Grizzly, the implementations are much the same. They are all based on event-driven methods to establish network channels and read data streams. Taking introduction to &lt;a href="https://javaee.github.io/grizzly/iostrategies.html">Thread Strategy&lt;/a> of Grizzly as an example, the following four categories are usually supported. Dubbo as an RPC framework, the default choice is the first strategy. Because it is impossible to determine whether the business services are CPU-intensive or IO blocking type. the first strategy is the most insurance strategy. Of course, after understanding these strategies, it is the most perfect choice to make targeted choices based on business scenarios.&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Worker-thread Strategy&lt;/strong>&lt;/li>
&lt;/ol>
&lt;p>The most useful IOStrategy, where Selector thread delegates NIO events processing to a worker threads.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubboasyn_server/1.png" alt="workerthread-strategy.png">&lt;/p>
&lt;p>This IOStrategy is very scalable and safe. We can change the size of selector and worker thread pool as required and there is no risk that some problem, which may occur during the specific NIO event processing, will impact other Channels registered on the same Selector.&lt;/p>
&lt;p>The disadvantage is the cost of thread context switching.&lt;/p>
&lt;ol start="2">
&lt;li>&lt;strong>Same-thread Strategy&lt;/strong>&lt;/li>
&lt;/ol>
&lt;p>Potentially the most efficient IOStrategy. Unlike the worker-thread IOStrategy, the same-thread IOStrategy processes NIO events in the current thread, avoiding expensive thread context switches.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubboasyn_server/2.png" alt="samethread-strategy.png">&lt;/p>
&lt;p>This IOStrategy is still pretty scalable, because we can tune the selector thread pool size, but it does have drawbacks. Care needs to be taken that channel NIO event processing won’t block or execute any long lasting operation, because it may block the processing of other NIO events that occur on the same Selector.&lt;/p>
&lt;ol start="3">
&lt;li>&lt;strong>Dynamic Strategy&lt;/strong>&lt;/li>
&lt;/ol>
&lt;p>As mentioned previously worker-thread and same-thread strategies have distinct advantages and disadvantages. However, what if a strategy could try to swap them smartly during runtime depending on the current conditions (load, gathered statistics… etc)?&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubboasyn_server/3.png" alt="dynamic-strategy.png">&lt;/p>
&lt;p>Potentially this IOStrategy could bring a lot of benefit and allow finer control of the resources. However, it’s important to not overload the condition evaluation logic, as its complexity will make this IOStrategy inefficient comparing to previous two strategies.&lt;/p>
&lt;p>By the way, I want you to pay more attention to this strategy, which is probably the best combination of Dubbo server asynchrony.&lt;/p>
&lt;ol start="4">
&lt;li>&lt;strong>Leader-follower Strategy&lt;/strong>&lt;/li>
&lt;/ol>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubboasyn_server/4.png" alt="leaderfollower-strategy.png">&lt;/p>
&lt;p>This IOStrategy is similar to worker-thread IOStrategy, but instead of passing NIO event processing to a worker thread, it changes worker thread to a selector thread by passing it the control over Selector and the actual NIO event processing takes place in the current thread. This strategy actually confuses worker and IO thread stages, which is not recommended.&lt;/p>
&lt;h3 id="coroutine-and-thread">Coroutine and thread&lt;/h3>
&lt;p>In terms of CPU resource management, the minimum scheduling unit of OS and JVM is thread. The coroutine library implemented by business application through extension can have independent running unit. In fact, it is also done based on thread. The principle should be to save the context and switch to another coroutine when IO blocking or lock waiting is encountered.&lt;/p>
&lt;p>&lt;strong>In the default Dubbo thread strategy, there are worker thread pools to execute the business logic, but the ThreadPool Full problem often occurs. In order to release worker threads as soon as possible, another thread will be set up in the implementation of the business service. The cost is thread context switching again, and it&amp;rsquo;s necessary to consider link-level data transfer (such as tracing information) and flow-control export controls, etc. Of course, if Dubbo can switch to the Same-thread strategy, combined with the coroutine library support, server-side asynchrony is a recommended use.&lt;/strong>&lt;/p>
&lt;h2 id="the-sample">The sample&lt;/h2>
&lt;p>Use an example to experience the Dubbo server-side asynchronous interface. For Demo code, visit &lt;a href="https://github.com/dubbo/dubbo-samples/tree/master/2-advanced/dubbo-samples-notify">https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-notify&lt;/a>。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">AsyncServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> AsyncService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;Main sayHello() method start.&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">final&lt;/span> AsyncContext asyncContext &lt;span style="color:#719e07">=&lt;/span> RpcContext.startAsync();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">new&lt;/span> Thread(() &lt;span style="color:#719e07">-&amp;gt;&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> asyncContext.signalContextSwitch();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;Attachment from consumer: &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> RpcContext.getContext().getAttachment(&lt;span style="color:#2aa198">&amp;#34;consumer-key1&amp;#34;&lt;/span>));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34; -- Async start.&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">try&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Thread.sleep(500);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } &lt;span style="color:#719e07">catch&lt;/span> (InterruptedException e) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> e.printStackTrace();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> asyncContext.write(&lt;span style="color:#2aa198">&amp;#34;Hello &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#34;, response from provider.&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34; -- Async end.&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }).start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;Main sayHello() method end.&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;hello, &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="practical-suggestions">Practical suggestions&lt;/h2>
&lt;ul>
&lt;li>Don&amp;rsquo;t rely too much on server-side asynchrony.&lt;/li>
&lt;li>Server-side asynchrony is basically a false proposition in the face of event-driven or Reactive.&lt;span data-type="color" style="color:rgb(36, 41, 46)">&lt;span data-type="background" style="background-color:rgb(255, 255, 255)">Supplement the reason: the server asynchrony is said Dubbo server-side business threads (default is 200) is not enough, but in the Event-Driven mode, 200 threads certainly do not need that much, just as much as the number of CPU cores. As long as the business implementation is non-blocking and pure asynchronous business logic processing, it is a waste of resources to use as many threads as possible.&lt;/span>&lt;/span>&lt;/li>
&lt;li>To use server-side asynchrony, it is recommended that the server-side thread strategy adopt the Same_thread pattern + Coroutine Library.&lt;/li>
&lt;/ul>
&lt;h2 id="conclusions">Conclusions&lt;/h2>
&lt;p>When Dubbo supports business applications, it encounters a variety of requirements scenarios, and server-side asynchrony provides users with a solution to deal with ThreadPool Full. In the case of ThreadPool Full, if the current system bottleneck is CPU, this solution is not recommended. If the system load is not high, increasing the number of worker threads or using server asynchrony can be considered.&lt;/p></description></item><item><title>Blog: How to use Seata to ensure consistency between Dubbo Microservices</title><link>https://dubbo.apache.org/en/blog/2019/01/17/how-to-use-seata-to-ensure-consistency-between-dubbo-microservices/</link><pubDate>Thu, 17 Jan 2019 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2019/01/17/how-to-use-seata-to-ensure-consistency-between-dubbo-microservices/</guid><description>
&lt;h2 id="use-case">Use case&lt;/h2>
&lt;p>A business logic for user purchasing commodities. The whole business logic is powered by 3 microservices:&lt;/p>
&lt;ul>
&lt;li>Storage service: deduct storage count on given commodity.&lt;/li>
&lt;li>Order service: create order according to purchase request.&lt;/li>
&lt;li>Account service: debit the balance of user&amp;rsquo;s account.&lt;/li>
&lt;/ul>
&lt;h3 id="architecture">Architecture&lt;/h3>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/fescar/fescar-1.png" alt="Architecture">&lt;/p>
&lt;h3 id="storageservice">StorageService&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">StorageService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * deduct storage count
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">deduct&lt;/span>(String commodityCode, &lt;span style="color:#dc322f">int&lt;/span> count);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="orderservice">OrderService&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">OrderService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * create order
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Order &lt;span style="color:#268bd2">create&lt;/span>(String userId, String commodityCode, &lt;span style="color:#dc322f">int&lt;/span> orderCount);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="accountservice">AccountService&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">AccountService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * debit balance of user&amp;#39;s account
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">debit&lt;/span>(String userId, &lt;span style="color:#dc322f">int&lt;/span> money);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="main-business-logic">Main business logic&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">BusinessServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> BusinessService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> StorageService storageService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> OrderService orderService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * purchase
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">purchase&lt;/span>(String userId, String commodityCode, &lt;span style="color:#dc322f">int&lt;/span> orderCount) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> storageService.deduct(commodityCode, orderCount);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> orderService.create(userId, commodityCode, orderCount);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">StorageServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> StorageService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> StorageDAO storageDAO;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">deduct&lt;/span>(String commodityCode, &lt;span style="color:#dc322f">int&lt;/span> count) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Storage storage &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> Storage();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> storage.setCount(count);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> storage.setCommodityCode(commodityCode);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> storageDAO.update(storage);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">OrderServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> OrderService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> OrderDAO orderDAO;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> AccountService accountService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> Order &lt;span style="color:#268bd2">create&lt;/span>(String userId, String commodityCode, &lt;span style="color:#dc322f">int&lt;/span> orderCount) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#dc322f">int&lt;/span> orderMoney &lt;span style="color:#719e07">=&lt;/span> calculate(commodityCode, orderCount);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> accountService.debit(userId, orderMoney);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Order order &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> Order();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> order.userId &lt;span style="color:#719e07">=&lt;/span> userId;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> order.commodityCode &lt;span style="color:#719e07">=&lt;/span> commodityCode;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> order.count &lt;span style="color:#719e07">=&lt;/span> orderCount;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> order.money &lt;span style="color:#719e07">=&lt;/span> orderMoney;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> orderDAO.insert(order);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="distributed-transaction-solution-with-seata">Distributed Transaction Solution with Seata&lt;/h2>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/fescar/fescar-2.png" alt="undefined">&lt;/p>
&lt;p>We just need an annotation &lt;code>@GlobalTransactional&lt;/code> on business method:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@GlobalTransactional&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">purchase&lt;/span>(String userId, String commodityCode, &lt;span style="color:#dc322f">int&lt;/span> orderCount) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ......
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="example-powered-by-dubbo--seata">Example powered by Dubbo + Seata&lt;/h2>
&lt;h3 id="step-1-setup-database">Step 1: Setup database&lt;/h3>
&lt;ul>
&lt;li>Requirement: MySQL with InnoDB engine.&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Note:&lt;/strong> In fact, there should be 3 database for the 3 services in the example use case. However, we can just create one database and configure 3 data sources for simple.&lt;/p>
&lt;p>Modify Spring XML with the database URL/username/password you just created.&lt;/p>
&lt;p>dubbo-account-service.xml
dubbo-order-service.xml
dubbo-storage-service.xml&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;property&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;url&amp;#34;&lt;/span> value=&lt;span style="color:#2aa198">&amp;#34;jdbc:mysql://x.x.x.x:3306/xxx&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;property&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;username&amp;#34;&lt;/span> value=&lt;span style="color:#2aa198">&amp;#34;xxx&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;property&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;password&amp;#34;&lt;/span> value=&lt;span style="color:#2aa198">&amp;#34;xxx&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="step-2-create-undo_log-table-for-seata">Step 2: Create undo_log table for Seata&lt;/h3>
&lt;p>&lt;code>UNDO_LOG&lt;/code> table is required by Seata AT mode.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sql" data-lang="sql">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">-- Note that when Seata version is upgraded to 0.3.0+, it is changed from the previous normal index to the unique index.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">&lt;/span>&lt;span style="color:#719e07">CREATE&lt;/span> &lt;span style="color:#719e07">TABLE&lt;/span> &lt;span style="color:#719e07">`&lt;/span>undo_log&lt;span style="color:#719e07">`&lt;/span> (
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>id&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">bigint&lt;/span>(&lt;span style="color:#2aa198">20&lt;/span>) &lt;span style="color:#719e07">NOT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span> AUTO_INCREMENT,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>branch_id&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">bigint&lt;/span>(&lt;span style="color:#2aa198">20&lt;/span>) &lt;span style="color:#719e07">NOT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>xid&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">varchar&lt;/span>(&lt;span style="color:#2aa198">100&lt;/span>) &lt;span style="color:#719e07">NOT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>context&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">varchar&lt;/span>(&lt;span style="color:#2aa198">128&lt;/span>) &lt;span style="color:#719e07">NOT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>rollback_info&lt;span style="color:#719e07">`&lt;/span> longblob &lt;span style="color:#719e07">NOT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>log_status&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">int&lt;/span>(&lt;span style="color:#2aa198">11&lt;/span>) &lt;span style="color:#719e07">NOT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>log_created&lt;span style="color:#719e07">`&lt;/span> datetime &lt;span style="color:#719e07">NOT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>log_modified&lt;span style="color:#719e07">`&lt;/span> datetime &lt;span style="color:#719e07">NOT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>ext&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">varchar&lt;/span>(&lt;span style="color:#2aa198">100&lt;/span>) &lt;span style="color:#719e07">DEFAULT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">PRIMARY&lt;/span> &lt;span style="color:#719e07">KEY&lt;/span> (&lt;span style="color:#719e07">`&lt;/span>id&lt;span style="color:#719e07">`&lt;/span>),
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">UNIQUE&lt;/span> &lt;span style="color:#719e07">KEY&lt;/span> &lt;span style="color:#719e07">`&lt;/span>ux_undo_log&lt;span style="color:#719e07">`&lt;/span> (&lt;span style="color:#719e07">`&lt;/span>xid&lt;span style="color:#719e07">`&lt;/span>,&lt;span style="color:#719e07">`&lt;/span>branch_id&lt;span style="color:#719e07">`&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>) ENGINE&lt;span style="color:#719e07">=&lt;/span>InnoDB AUTO_INCREMENT&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">1&lt;/span> &lt;span style="color:#719e07">DEFAULT&lt;/span> CHARSET&lt;span style="color:#719e07">=&lt;/span>utf8;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="step-3-create-tables-for-example-business">Step 3: Create tables for example business&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sql" data-lang="sql">&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">DROP&lt;/span> &lt;span style="color:#719e07">TABLE&lt;/span> &lt;span style="color:#719e07">IF&lt;/span> &lt;span style="color:#719e07">EXISTS&lt;/span> &lt;span style="color:#719e07">`&lt;/span>storage_tbl&lt;span style="color:#719e07">`&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">CREATE&lt;/span> &lt;span style="color:#719e07">TABLE&lt;/span> &lt;span style="color:#719e07">`&lt;/span>storage_tbl&lt;span style="color:#719e07">`&lt;/span> (
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>id&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">int&lt;/span>(&lt;span style="color:#2aa198">11&lt;/span>) &lt;span style="color:#719e07">NOT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span> AUTO_INCREMENT,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>commodity_code&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">varchar&lt;/span>(&lt;span style="color:#2aa198">255&lt;/span>) &lt;span style="color:#719e07">DEFAULT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>&lt;span style="color:#719e07">count&lt;/span>&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">int&lt;/span>(&lt;span style="color:#2aa198">11&lt;/span>) &lt;span style="color:#719e07">DEFAULT&lt;/span> &lt;span style="color:#2aa198">0&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">PRIMARY&lt;/span> &lt;span style="color:#719e07">KEY&lt;/span> (&lt;span style="color:#719e07">`&lt;/span>id&lt;span style="color:#719e07">`&lt;/span>),
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">UNIQUE&lt;/span> &lt;span style="color:#719e07">KEY&lt;/span> (&lt;span style="color:#719e07">`&lt;/span>commodity_code&lt;span style="color:#719e07">`&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>) ENGINE&lt;span style="color:#719e07">=&lt;/span>InnoDB &lt;span style="color:#719e07">DEFAULT&lt;/span> CHARSET&lt;span style="color:#719e07">=&lt;/span>utf8;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">DROP&lt;/span> &lt;span style="color:#719e07">TABLE&lt;/span> &lt;span style="color:#719e07">IF&lt;/span> &lt;span style="color:#719e07">EXISTS&lt;/span> &lt;span style="color:#719e07">`&lt;/span>order_tbl&lt;span style="color:#719e07">`&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">CREATE&lt;/span> &lt;span style="color:#719e07">TABLE&lt;/span> &lt;span style="color:#719e07">`&lt;/span>order_tbl&lt;span style="color:#719e07">`&lt;/span> (
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>id&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">int&lt;/span>(&lt;span style="color:#2aa198">11&lt;/span>) &lt;span style="color:#719e07">NOT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span> AUTO_INCREMENT,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>user_id&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">varchar&lt;/span>(&lt;span style="color:#2aa198">255&lt;/span>) &lt;span style="color:#719e07">DEFAULT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>commodity_code&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">varchar&lt;/span>(&lt;span style="color:#2aa198">255&lt;/span>) &lt;span style="color:#719e07">DEFAULT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>&lt;span style="color:#719e07">count&lt;/span>&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">int&lt;/span>(&lt;span style="color:#2aa198">11&lt;/span>) &lt;span style="color:#719e07">DEFAULT&lt;/span> &lt;span style="color:#2aa198">0&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>money&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">int&lt;/span>(&lt;span style="color:#2aa198">11&lt;/span>) &lt;span style="color:#719e07">DEFAULT&lt;/span> &lt;span style="color:#2aa198">0&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">PRIMARY&lt;/span> &lt;span style="color:#719e07">KEY&lt;/span> (&lt;span style="color:#719e07">`&lt;/span>id&lt;span style="color:#719e07">`&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>) ENGINE&lt;span style="color:#719e07">=&lt;/span>InnoDB &lt;span style="color:#719e07">DEFAULT&lt;/span> CHARSET&lt;span style="color:#719e07">=&lt;/span>utf8;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">DROP&lt;/span> &lt;span style="color:#719e07">TABLE&lt;/span> &lt;span style="color:#719e07">IF&lt;/span> &lt;span style="color:#719e07">EXISTS&lt;/span> &lt;span style="color:#719e07">`&lt;/span>account_tbl&lt;span style="color:#719e07">`&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">CREATE&lt;/span> &lt;span style="color:#719e07">TABLE&lt;/span> &lt;span style="color:#719e07">`&lt;/span>account_tbl&lt;span style="color:#719e07">`&lt;/span> (
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>id&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">int&lt;/span>(&lt;span style="color:#2aa198">11&lt;/span>) &lt;span style="color:#719e07">NOT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span> AUTO_INCREMENT,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>user_id&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">varchar&lt;/span>(&lt;span style="color:#2aa198">255&lt;/span>) &lt;span style="color:#719e07">DEFAULT&lt;/span> &lt;span style="color:#719e07">NULL&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">`&lt;/span>money&lt;span style="color:#719e07">`&lt;/span> &lt;span style="color:#b58900">int&lt;/span>(&lt;span style="color:#2aa198">11&lt;/span>) &lt;span style="color:#719e07">DEFAULT&lt;/span> &lt;span style="color:#2aa198">0&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">PRIMARY&lt;/span> &lt;span style="color:#719e07">KEY&lt;/span> (&lt;span style="color:#719e07">`&lt;/span>id&lt;span style="color:#719e07">`&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>) ENGINE&lt;span style="color:#719e07">=&lt;/span>InnoDB &lt;span style="color:#719e07">DEFAULT&lt;/span> CHARSET&lt;span style="color:#719e07">=&lt;/span>utf8;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="step-4-start-seata-server">Step 4: Start Seata-Server&lt;/h3>
&lt;ul>
&lt;li>Download server &lt;a href="https://github.com/seata/seata/releases">package&lt;/a>, unzip it.&lt;/li>
&lt;li>Start Seata-Server&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>Usage: sh seata-server.sh&lt;span style="color:#719e07">(&lt;/span>&lt;span style="color:#719e07">for&lt;/span> linux and mac&lt;span style="color:#719e07">)&lt;/span> or cmd seata-server.bat&lt;span style="color:#719e07">(&lt;/span>&lt;span style="color:#719e07">for&lt;/span> windows&lt;span style="color:#719e07">)&lt;/span> &lt;span style="color:#719e07">[&lt;/span>options&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Options:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --host, -h
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> The host to bind.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Default: 0.0.0.0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --port, -p
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> The port to listen.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Default: &lt;span style="color:#2aa198">8091&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --storeMode, -m
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> log store mode : file、db
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Default: file
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --help
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>e.g.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sh seata-server.sh -p &lt;span style="color:#2aa198">8091&lt;/span> -h 127.0.0.1 -m file
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="step-5-run-example">Step 5: Run example&lt;/h3>
&lt;ul>
&lt;li>Start AccountService (&lt;a href="https://github.com/apache/dubbo-samples/blob/master/99-integration/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/starter/DubboAccountServiceStarter.java">DubboAccountServiceStarter&lt;/a>).&lt;/li>
&lt;li>Start StockService (&lt;a href="https://github.com/apache/dubbo-samples/blob/master/99-integration/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/starter/DubboStorageServiceStarter.java">DubboStorageServiceStarter&lt;/a>).&lt;/li>
&lt;li>Start OrderService (&lt;a href="https://github.com/apache/dubbo-samples/blob/master/99-integration/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/starter/DubboOrderServiceStarter.java">DubboOrderServiceStarter&lt;/a>).&lt;/li>
&lt;li>Run BusinessService for test (&lt;a href="https://github.com/apache/dubbo-samples/blob/master/99-integration/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/starter/DubboBusinessTester.java">DubboBusinessTester&lt;/a>).&lt;/li>
&lt;/ul>
&lt;h3 id="related-projects">Related projects&lt;/h3>
&lt;ul>
&lt;li>Seata: &lt;a href="https://github.com/seata/seata">https://github.com/seata/seata&lt;/a>&lt;/li>
&lt;li>Seata Samples : &lt;a href="https://github.com/seata/seata-samples">https://github.com/seata/seata-samples&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Blog: The fifth Dubbo meetup has been held in Hangzhou</title><link>https://dubbo.apache.org/en/blog/2018/12/10/the-fifth-dubbo-meetup-has-been-held-in-hangzhou/</link><pubDate>Mon, 10 Dec 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/12/10/the-fifth-dubbo-meetup-has-been-held-in-hangzhou/</guid><description>
&lt;p>The fifth Dubbo meetup has been held in Hangzhou,&lt;/p>
&lt;p>Please enjoy the slides of the topics:&lt;/p>
&lt;ul>
&lt;li>Ding Li: How to involve in dubbo community &lt;a href="https://github.com/dubbo/awesome-dubbo/blob/master/slides/meetup/201812%40hangzhou/how-to-involve-in-dubbo-community.pdf">slides&lt;/a>&lt;/li>
&lt;li>Shenli Cao: Dubbo 2.7 introduction &lt;a href="https://github.com/dubbo/awesome-dubbo/blob/master/slides/meetup/201812%40hangzhou/dubbo-2.7-introduction.pdf">slides&lt;/a>&lt;/li>
&lt;li>Tao Yang: Dubbo practice in netease koala &lt;a href="https://github.com/dubbo/awesome-dubbo/blob/master/slides/meetup/201812%40hangzhou/dubbo-practice-in-netease-koala.pdf">slides&lt;/a>&lt;/li>
&lt;li>Mercy Ma: Nacos support in Dubbo &lt;a href="https://github.com/dubbo/awesome-dubbo/blob/master/slides/meetup/201812%40hangzhou/nacos-support-in-dubbo.pdf">slides&lt;/a>&lt;/li>
&lt;li>Yihao Zhao: Sentinel: Sentinel support for Dubbo &lt;a href="https://github.com/dubbo/awesome-dubbo/blob/master/slides/meetup/201812%40hangzhou/sentinel-support-for-dubbo.pdf">slides&lt;/a>&lt;/li>
&lt;li>Zhixuan Chen: Troubleshooting Dubbo with Arthas &lt;a href="https://github.com/dubbo/awesome-dubbo/blob/master/slides/meetup/201812%40hangzhou/troubleshooting-dubbo-with-arthas.pdf">slides&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Blog: Dubbo Integrates with Nacos to Become a Registry</title><link>https://dubbo.apache.org/en/blog/2018/11/07/dubbo-integrates-with-nacos-to-become-a-registry/</link><pubDate>Wed, 07 Nov 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/11/07/dubbo-integrates-with-nacos-to-become-a-registry/</guid><description>
&lt;p>Nacos is an important registry in Dubbo ecosystem, and dubbo-registry-nacos is the implementation of Dubbo-integrated Nacos registry.&lt;/p>
&lt;h2 id="preparation-works">Preparation Works&lt;/h2>
&lt;p>Before you integrate dubbo-registry-nacos into your Dubbo project, make sure the Nacos service is started in the background. If you are not familiar with the basic use of Nacos, you can refer to the Quick Start for Nacos: &lt;a href="https://nacos.io/en-us/docs/quick-start.html">https://nacos.io/en-us/docs/quick-start.html&lt;/a>. Nacos versions above 0.6.1 are recommended.&lt;/p>
&lt;h2 id="get-started-quickly">Get Started Quickly&lt;/h2>
&lt;p>The operation steps for Dubbo to integrate Nacos into a registry are simple, the general steps can be divided into &amp;ldquo;add Maven dependency&amp;rdquo; and &amp;ldquo;configure the registry.&amp;rdquo;&lt;/p>
&lt;h2 id="increase-maven-dependency">Increase Maven Dependency&lt;/h2>
&lt;p>First, you need to add the Maven dependency of dubbo-registry-nacos to your project&amp;rsquo;s pom.xml file, and it is strongly recommended that you use Dubbo 2.6.5:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dependencies&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- Dubbo Nacos registry dependency --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.apache&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>dubbo-registry-nacos&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>0.0.2&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- Keep latest Nacos client version --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.apache.nacos&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>nacos-client&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>[0.6.1,)&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- Dubbo dependency --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.apache&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>dubbo&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>2.6.5&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- Alibaba Spring Context extension --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.apache.spring&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>spring-context-support&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>1.0.2&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/dependencies&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>When you add dubbo-registry-nacos to your project, you don&amp;rsquo;t need to programmatically implement the service discovery and registration logic, the actual implementation is provided by the third-party package, and then to configure the Naocs registry.&lt;/p>
&lt;h2 id="configure-the-registry">Configure the Registry&lt;/h2>
&lt;p>Assuming your Dubbo application is assembled by the Spring Framework, there are two configuration options: Dubbo Spring externalization configuration and Spring XML configuration files, I strongly recommend the former.&lt;/p>
&lt;h2 id="dubbo-spring-externalization-configuration">Dubbo Spring Externalization Configuration&lt;/h2>
&lt;p>Dubbo Spring externalization configuration is a new feature introduced by Dubbo 2.5.8, which automatically generates and binds Dubbo configuration Bean through the Spring Environment property, simplifying configuration and lowering the threshold for microservice development.&lt;/p>
&lt;p>Assume your Dubbo application uses Zookeeper as the registry and its server IP address is 10.20.153.10, the registered address is also stored in the dubbo-config.properties file as a Dubbo externalization configuration attribute, as shown below:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-properties" data-lang="properties">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">## application&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.application.name &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">your-dubbo-application&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">## Zookeeper registry address&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.registry.address &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">zookeeper://10.20.153.10:2181&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Assuming your Nacos Server is also running on server 10.20.153.10 and using the default Nacos service port 8848, you can simply adjust the dubbo.registry.address property as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-properties" data-lang="properties">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">## 其他属性保持不变&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">## Nacos registry address&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.registry.address &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">nacos://10.20.153.10:8848&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Subsequently, restart your Dubbo application, and Dubbo&amp;rsquo;s service delivery and consumption information can be displayed in the Nacos console:&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-registry-nacos-1.png" alt="image-20181213103845976">&lt;/p>
&lt;p>As shown in the figure, the service name prefixed with providers: is the meta-information for the service provider, and consumers: represents the meta-information of the service consumer. Click &amp;ldquo;Details&amp;rdquo; to view service status details:&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-registry-nacos-2.png" alt="image-20181213104145998">&lt;/p>
&lt;p>If you are using the Spring XML configuration file to assemble the Dubbo registry, refer to the next section.&lt;/p>
&lt;h2 id="spring-xml-configuration-file">Spring XML Configuration File&lt;/h2>
&lt;p>Also, assume your Dubbo application uses Zookeeper as the registry and its server IP address is 10.20.153.10 and assemble the Spring Bean in an XML file, as shown below:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-8&amp;#34;?&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;beans&lt;/span> xmlns=&lt;span style="color:#2aa198">&amp;#34;http://www.springframework.org/schema/beans&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:xsi=&lt;span style="color:#2aa198">&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:dubbo=&lt;span style="color:#2aa198">&amp;#34;http://dubbo.apache.org/schema/dubbo&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xsi:schemaLocation=&lt;span style="color:#2aa198">&amp;#34;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&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- Provider application information for dependency calculation --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:application&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;dubbo-provider-xml-demo&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- Using the Zookeeper registry Zookeeper --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:registry&lt;/span> address=&lt;span style="color:#2aa198">&amp;#34;zookeeper://10.20.153.10:2181&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/beans&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Similar to the Dubbo Spring externalization configuration, simply adjust the address property configuration:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-8&amp;#34;?&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;beans&lt;/span> xmlns=&lt;span style="color:#2aa198">&amp;#34;http://www.springframework.org/schema/beans&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:xsi=&lt;span style="color:#2aa198">&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:dubbo=&lt;span style="color:#2aa198">&amp;#34;http://dubbo.apache.org/schema/dubbo&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xsi:schemaLocation=&lt;span style="color:#2aa198">&amp;#34;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&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- Provider application information for dependency calculation--&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:application&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;dubbo-provider-xml-demo&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- Using the Nacos registry --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:registry&lt;/span> address=&lt;span style="color:#2aa198">&amp;#34;nacos://10.20.153.10:8848&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/beans&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Once you restart the Dubbo application, you can also see that the registration meta-information for both service providers and consumers is presented in the Nacos console:&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-registry-nacos-3.png" alt="image-20181213113049185">&lt;/p>
&lt;p>Do you absolutely configure or switch Nacos registry super Easy? If you want to get more or unclear, refer to the complete example below.&lt;/p>
&lt;h2 id="complete-example">Complete Example&lt;/h2>
&lt;p>The metadata in the above image is derived from the Dubbo Spring annotation-driven example and the Dubbo Spring XML configuration-driven example, both of which will be described below, you can choose your preferred programming model. Before we get into the formal discussion, let&amp;rsquo;s look at the preparations for both, as they both rely on Java service interfaces and implementations. Also, ensure that the Nacos service is started in the local (127.0.0.1) environment.&lt;/p>
&lt;h3 id="example-interfaces-and-implementations">Example Interfaces and Implementations&lt;/h3>
&lt;p>First, define the sample interface, as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> org.apache.dubbo.demo.service;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * DemoService
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> *
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * @since 2.7.4
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">DemoService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">sayName&lt;/span>(String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Provide implementation classes for the above interfaces:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> org.apache.dubbo.demo.service;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.apache.dubbo.config.annotation.Service;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.apache.dubbo.rpc.RpcContext;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.springframework.beans.factory.annotation.Value;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * Default {@link DemoService}
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> *
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * @since 2.7.4
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Service&lt;/span>(version &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;${demo.service.version}&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DefaultService&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> DemoService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Value&lt;/span>(&lt;span style="color:#2aa198">&amp;#34;${demo.service.name}&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> String serviceName;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">sayName&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> RpcContext rpcContext &lt;span style="color:#719e07">=&lt;/span> RpcContext.getContext();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> String.format(&lt;span style="color:#2aa198">&amp;#34;Service [name :%s , port : %d] %s(\&amp;#34;%s\&amp;#34;) : Hello,%s&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> serviceName,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> rpcContext.getLocalPort(),
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> rpcContext.getMethodName(),
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> name,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Once the interface and implementation are ready, the annotation-driven and XML configuration-driven implementations will be used below.&lt;/p>
&lt;h2 id="spring-annotation-driven-example">Spring Annotation-driven Example&lt;/h2>
&lt;p>Dubbo 2.7.4 reconstructs the Spring annotation-driven programming model.&lt;/p>
&lt;h3 id="service-provider-annotation-driven-implementation">Service Provider Annotation-driven Implementation&lt;/h3>
&lt;ul>
&lt;li>Define property source of Dubbo provider externalization configuration - provider-config.properties&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-properties" data-lang="properties">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">## application&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.application.name &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">dubbo-provider-demo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">## Nacos registry address&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.registry.address &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">nacos://127.0.0.1:8848&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">## Dubbo Protocol&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.protocol.name &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">dubbo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.protocol.port &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">-1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"># Provider @Service version&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>demo.service.version&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">1.0.0&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>demo.service.name &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">demoService&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>Implement service provider bootstrap - DemoServiceProviderBootstrap&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> org.apache.dubbo.demo.provider;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.apache.dubbo.demo.service.DemoService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.springframework.context.annotation.AnnotationConfigApplicationContext;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.springframework.context.annotation.PropertySource;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> java.io.IOException;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * {@link DemoService} provider demo
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@EnableDubbo&lt;/span>(scanBasePackages &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;org.apache.dubbo.demo.service&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@PropertySource&lt;/span>(value &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;classpath:/provider-config.properties&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DemoServiceProviderBootstrap&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) &lt;span style="color:#268bd2">throws&lt;/span> IOException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> AnnotationConfigApplicationContext context &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> AnnotationConfigApplicationContext();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.register(DemoServiceProviderBootstrap.class);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.refresh();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;DemoService provider is starting...&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.in.read();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Wherein, the annotation @EnableDubbo activates the Dubbo annotation-driven and externalization configuration, its scanBasePackages property scans the specified Java package, exposes all service interface implementation classes labeled @Service as Spring Bean, and then exports the Dubbo service.&lt;/p>
&lt;p>@PropertySource is the standard import property configuration resource annotation introduced by Spring Framework 3.1, which provides externalization configuration for Dubbo.&lt;/p>
&lt;h2 id="service-consumer-annotation-driven-implementation">Service consumer annotation-driven implementation&lt;/h2>
&lt;ul>
&lt;li>Define property source of Dubbo consumer externalization configuration - consumer-config.properties&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-properties" data-lang="properties">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">## Dubbo Application info&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.application.name &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">dubbo-consumer-demo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">## Nacos registry address&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.registry.address &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">nacos://127.0.0.1:8848&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"># @Reference version&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>demo.service.version&lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">1.0.0&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Similarly, the dubbo.registry.address property points to the Nacos registry, through which metadata about other Dubbo services is obtained.&lt;/p>
&lt;ul>
&lt;li>Implement service consumer bootstrap class - DemoServiceConsumerBootstrap&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> org.apache.dubbo.demo.consumer;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.apache.dubbo.config.annotation.Reference;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.apache.dubbo.demo.service.DemoService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.springframework.context.annotation.AnnotationConfigApplicationContext;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.springframework.context.annotation.PropertySource;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> javax.annotation.PostConstruct;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> java.io.IOException;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * {@link DemoService} consumer demo
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@EnableDubbo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@PropertySource&lt;/span>(value &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;classpath:/consumer-config.properties&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DemoServiceConsumerBootstrap&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Reference&lt;/span>(version &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;${demo.service.version}&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> DemoService demoService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@PostConstruct&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">init&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (&lt;span style="color:#dc322f">int&lt;/span> i &lt;span style="color:#719e07">=&lt;/span> 0; i &lt;span style="color:#719e07">&amp;lt;&lt;/span> 10; i&lt;span style="color:#719e07">++&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(demoService.sayName(&lt;span style="color:#2aa198">&amp;#34;小马哥(mercyblitz)&amp;#34;&lt;/span>));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) &lt;span style="color:#268bd2">throws&lt;/span> IOException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> AnnotationConfigApplicationContext context &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> AnnotationConfigApplicationContext();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.register(DemoServiceConsumerBootstrap.class);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.refresh();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.close();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Similarly, the @EnableDubbo annotation activates the Dubbo annotation-driven and externalization configuration, although it currently belongs to the service consumer and does not require the Java package name to scan the service implementation labeled @Service.&lt;/p>
&lt;p>@Reference is a dependency injection annotation for Dubbo remote services that requires service provider and consumer contract interface, version, and group information. In the current service consumption example, the service version of DemoService is derived from the property configuration file consumer-config.properties.&lt;/p>
&lt;p>The @PostConstruct code shows that when the DemoServiceConsumerBootstrap Bean is initialized, it executes ten Dubbo remote method invocation.&lt;/p>
&lt;h3 id="run-the-annotation-driven-example">Run the Annotation-driven Example&lt;/h3>
&lt;p>Start DemoServiceProviderBootstrap twice locally and the registry will have two health services:&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-registry-nacos-4.png" alt="image-20181213123909636">&lt;/p>
&lt;p>Run DemoServiceConsumerBootstrap again and the results are as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>Service [name :demoService , port : 20880] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :demoService , port : 20881] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :demoService , port : 20880] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :demoService , port : 20880] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :demoService , port : 20881] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :demoService , port : 20881] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :demoService , port : 20880] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :demoService , port : 20880] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :demoService , port : 20881] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :demoService , port : 20881] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Run correctly and the service consumer uses a load balancing strategy to allocate ten RPC calls equally to two Dubbo service provider instances.&lt;/p>
&lt;h3 id="spring-xml-configuration-driven-example">Spring XML Configuration-driven Example&lt;/h3>
&lt;p>Spring XML configuration-driven is the programming model of traditional Spring assembly components.&lt;/p>
&lt;h4 id="service-provider-xml-configuration-driven">Service Provider XML Configuration-driven&lt;/h4>
&lt;p>Define the service provider XML context configuration file - /META-INF/spring/dubbo-provider-context.xml&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-8&amp;#34;?&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;beans&lt;/span> xmlns=&lt;span style="color:#2aa198">&amp;#34;http://www.springframework.org/schema/beans&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:xsi=&lt;span style="color:#2aa198">&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:dubbo=&lt;span style="color:#2aa198">&amp;#34;http://dubbo.apache.org/schema/dubbo&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xsi:schemaLocation=&lt;span style="color:#2aa198">&amp;#34;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&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!--
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">Provider application information for dependency calculation
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:application&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;dubbo-provider-xml-demo&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- Using the Nacos registry --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:registry&lt;/span> address=&lt;span style="color:#2aa198">&amp;#34;nacos://127.0.0.1:8848&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- Using Dubbo protocol to expose services on random ports --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:protocol&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;dubbo&amp;#34;&lt;/span> port=&lt;span style="color:#2aa198">&amp;#34;-1&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- Declare the service interface to be exposed --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:service&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;org.apache.dubbo.demo.service.DemoService&amp;#34;&lt;/span> ref=&lt;span style="color:#2aa198">&amp;#34;demoService&amp;#34;&lt;/span> version=&lt;span style="color:#2aa198">&amp;#34;2.0.0&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- Implement services like local beans --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;bean&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;demoService&amp;#34;&lt;/span> class=&lt;span style="color:#2aa198">&amp;#34;org.apache.dubbo.demo.service.DefaultService&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/beans&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>Implement service provider bootstrap class - DemoServiceProviderBootstrap&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> org.apache.dubbo.demo.provider;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.apache.dubbo.demo.service.DemoService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.springframework.context.support.ClassPathXmlApplicationContext;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> java.io.IOException;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * {@link DemoService} provider demo XML bootstrap
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DemoServiceProviderXmlBootstrap&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) &lt;span style="color:#268bd2">throws&lt;/span> IOException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ClassPathXmlApplicationContext context &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ClassPathXmlApplicationContext();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.setConfigLocation(&lt;span style="color:#2aa198">&amp;#34;/META-INF/spring/dubbo-provider-context.xml&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.refresh();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;DemoService provider (XML) is starting...&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.in.read();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="service-consumer-xml-configuration-driven">Service Consumer XML Configuration-driven&lt;/h4>
&lt;p>Define the consumer provider XML context configuration file - /META-INF/spring/dubbo- consumer-context.xml&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-8&amp;#34;?&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;beans&lt;/span> xmlns=&lt;span style="color:#2aa198">&amp;#34;http://www.springframework.org/schema/beans&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:xsi=&lt;span style="color:#2aa198">&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:dubbo=&lt;span style="color:#2aa198">&amp;#34;http://dubbo.apache.org/schema/dubbo&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xsi:schemaLocation=&lt;span style="color:#2aa198">&amp;#34;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&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!--
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">Provider application information for dependency calculation
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:application&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;dubbo-consumer-xml-demo&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- Using the Nacos registry--&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:registry&lt;/span> address=&lt;span style="color:#2aa198">&amp;#34;nacos://127.0.0.1:8848&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- Reference service interface --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:reference&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;demoService&amp;#34;&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;org.apache.dubbo.demo.service.DemoService&amp;#34;&lt;/span> version=&lt;span style="color:#2aa198">&amp;#34;2.0.0&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/beans&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>Implement service consumer bootstrap class - DemoServiceConsumerBootstrap&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> org.apache.dubbo.demo.consumer;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.apache.dubbo.demo.service.DemoService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.springframework.context.support.ClassPathXmlApplicationContext;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> java.io.IOException;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * {@link DemoService} consumer demo XML bootstrap
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DemoServiceConsumerXmlBootstrap&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) &lt;span style="color:#268bd2">throws&lt;/span> IOException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ClassPathXmlApplicationContext context &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ClassPathXmlApplicationContext();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.setConfigLocation(&lt;span style="color:#2aa198">&amp;#34;/META-INF/spring/dubbo-consumer-context.xml&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.refresh();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;DemoService consumer (XML) is starting...&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> DemoService demoService &lt;span style="color:#719e07">=&lt;/span> context.getBean(&lt;span style="color:#2aa198">&amp;#34;demoService&amp;#34;&lt;/span>, DemoService.class);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (&lt;span style="color:#dc322f">int&lt;/span> i &lt;span style="color:#719e07">=&lt;/span> 0; i &lt;span style="color:#719e07">&amp;lt;&lt;/span> 10; i&lt;span style="color:#719e07">++&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(demoService.sayName(&lt;span style="color:#2aa198">&amp;#34;小马哥(mercyblitz)&amp;#34;&lt;/span>));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.close();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="run-xml-configuration-driven-example">Run XML Configuration-driven Example&lt;/h4>
&lt;p>As such, start two DemoServiceProviderXmlBootstrap bootstraps and observe the changes in the Nacos registry service provider:&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-registry-nacos-5.png" alt="image-20181213125527201">&lt;/p>
&lt;p>The service version driven by the XML configuration is 2.0.0, so the registration service is correct.&lt;/p>
&lt;p>Run the service consumer bootstrap DemoServiceConsumerXmlBootstrap again and observe the console output:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>Service [name :null , port : 20882] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :null , port : 20882] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :null , port : 20883] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :null , port : 20882] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :null , port : 20882] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :null , port : 20883] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :null , port : 20882] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :null , port : 20883] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :null , port : 20883] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service [name :null , port : 20883] sayName(&amp;#34;小马哥(mercyblitz)&amp;#34;) : Hello,小马哥(mercyblitz)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>As a result, both operation and load balancing are normal due to the property demo.service.name has not been added to the current example, the &amp;ldquo;name&amp;rdquo; information is output as null. For more information, please refer to: &lt;a href="https://github.com/apache/dubbo/tree/master/dubbo-registry/dubbo-registry-nacos">https://github.com/apache/dubbo/tree/master/dubbo-registry/dubbo-registry-nacos&lt;/a>.&lt;/p>
&lt;p>If you&amp;rsquo;re interested in or fond of open source projects like Dubbo and Nacos, try clicking &amp;ldquo;star&amp;rdquo; to support them. The links are as follows:&lt;/p>
&lt;ul>
&lt;li>Apache Dubbo: &lt;a href="https://github.com/apache/dubbo">https://github.com/apache/dubbo&lt;/a>&lt;/li>
&lt;li>Dubbo Nacos Registry: &lt;a href="https://github.com/apache/dubbo/tree/master/dubbo-registry/dubbo-registry-nacos">https://github.com/apache/dubbo/tree/master/dubbo-registry/dubbo-registry-nacos&lt;/a>&lt;/li>
&lt;li>Alibaba Nacos: &lt;a href="https://github.com/alibaba/nacos">https://github.com/alibaba/nacos&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Blog: Introduction to the Dubbo protocol</title><link>https://dubbo.apache.org/en/blog/2018/10/05/introduction-to-the-dubbo-protocol/</link><pubDate>Fri, 05 Oct 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/10/05/introduction-to-the-dubbo-protocol/</guid><description>
&lt;h2 id="the-concept-of-the-protocol">The concept of the protocol&lt;/h2>
&lt;p>The protocol is the foundation of communication between two network entities, and data is transmitted from one entity to another in the form of a byte stream over the network. In the world of byte streams, this one-dimensional byte stream cannot be reshaped into two-dimensional or multi-dimensional data structures and domain objects without a protocol.&lt;/p>
&lt;h3 id="what-is-the-protocol">What is the protocol&lt;/h3>
&lt;p>The protocol is the semantics determined by both parties for the communication. For example, we design a protocol for string transmission, which allows the client to send a string and the server receives the corresponding string.&lt;/p>
&lt;p>This protocol is quite simple, first 4-byte represent the total length of the message, followed by 1-byte represents the length of the charset, and then followed by the message payload, charset name and string body.&lt;/p>
&lt;p>For example, Send a string &lt;code>abc&lt;/code> encoded by &lt;code>iso-8859-1&lt;/code> to the server end. After protocol trans-coding, the content is: &lt;code>18 = 4 + 1 + 10 + 3|10|iso-8859-1|abc&lt;/code>, when the server receives these byte streams, it first reads 4-byte and converts it to int, in this case is 18, which is the length of message. Then continue to read the remaining 14 bytes, the remaining first byte read will be the length of the charset name, which is 10, the after 10-byte content is converted to a string, the content is &lt;code>iso-8859-1&lt;/code>. Use this charset to construct the subsequent byte array into the string &lt;code>new String(bytes, &amp;quot;iso-8859-1&amp;quot;)&lt;/code>.&lt;/p>
&lt;p>In the previous example of a custom string transfer protocol, we have already seen the role of protocols in data transmission. Without a protocol, the data exchange cannot be completed. The following is Wikipedia&amp;rsquo;s definition of the communication protocol.&lt;/p>
&lt;blockquote>
&lt;p>In telecommunication, a communication protocol is a system of rules that allow two or more entities of a communications system to transmit information via any kind of variation of a physical quantity. The protocol defines the rules syntax, semantics and synchronization of communication and possible error recovery methods. Protocols may be implemented by hardware, software, or a combination of both.&lt;/p>
&lt;/blockquote>
&lt;p>Communication protocols need to define syntax, semantics, and communication synchronization operations. The content described here is actually a formal description of the previous custom string transfer protocol.&lt;/p>
&lt;h3 id="the-definition-of-codec">The definition of &lt;code>Codec&lt;/code>&lt;/h3>
&lt;p>&lt;code>org.apache.dubbo.remoting.Codec2&lt;/code> define the &lt;strong>Codec&lt;/strong>&amp;rsquo;s I/O processing, so the main methods are &lt;code>encode&lt;/code> and &lt;code>decode&lt;/code>, as defined below:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@SPI&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">Codec2&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Adaptive&lt;/span>({Constants.CODEC_KEY})
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">encode&lt;/span>(Channel channel, ChannelBuffer buffer, Object message) &lt;span style="color:#268bd2">throws&lt;/span> IOException;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Adaptive&lt;/span>({Constants.CODEC_KEY})
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Object &lt;span style="color:#268bd2">decode&lt;/span>(Channel channel, ChannelBuffer buffer) &lt;span style="color:#268bd2">throws&lt;/span> IOException;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">enum&lt;/span> DecodeResult {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> NEED_MORE_INPUT, SKIP_SOME_INPUT
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>Codec&lt;/code> works on a protocol, &lt;code>encode&lt;/code> method means to encode the communication object to the &lt;code>ByteBufferWrapper&lt;/code>, and &lt;code>decode&lt;/code> method decodes the &lt;code>ChannelBuffer&lt;/code> read from the network into &lt;code>Object&lt;/code>, which is the communication object.&lt;/p>
&lt;h2 id="common-protocol-mode">Common protocol mode&lt;/h2>
&lt;p>Protocols in application layer have three general forms: fixed-length protocol, special delimiter protocol and protocol header + payload mode. The specific contents of these forms are described below.&lt;/p>
&lt;p>When reading data from the network in the form of a byte stream, it is necessary to determine when a meaningful transmission content ends. Moreover, the transmission of data on the network, there are sticky packets and fragment packets problem. The solution to this problem is that the protocol can accurately identify, when the sticky packets or fragment packets occurs, it can handle it correctly.&lt;/p>
&lt;h3 id="fixed-length-protocol">Fixed-length protocol&lt;/h3>
&lt;p>The fixed-length protocol means that the length of the protocol content is fixed. For example, the protocol byte length is 50. When 50 bytes are read from the network, the decoding operation is performed. The fixed-length protocol is more efficient when reading or writing, because the size of the data cache is basically determined, just like an array. The defect is the lack of adaptability. Taking the RPC scene as an example, it is difficult to estimate the length.&lt;/p>
&lt;blockquote>
&lt;p>Refer to Netty&amp;rsquo;s &lt;code>FixedLengthFrameDecoder&lt;/code>&lt;/p>
&lt;/blockquote>
&lt;h3 id="special-delimiter-protocol">Special delimiter protocol&lt;/h3>
&lt;p>Compared to fixed-length protocols, if we can define a special character as the end of each protocol unit, we can communicate in a variable length, so as to balance the data transmission and efficiency, such as the delimiter \n.&lt;/p>
&lt;p>The problem with the special delimiter method is that it think about the process of protocol transmission in a simple way. For a protocol unit, it must be read all before it can be processed. In addition, it must be prevented that the data transmitted by the user cannot be the same as the delimiter, otherwise it will be disordered.&lt;/p>
&lt;blockquote>
&lt;p>Refer to Netty&amp;rsquo;s &lt;code>DelimiterBasedFrameDecoder&lt;/code>&lt;/p>
&lt;/blockquote>
&lt;h3 id="variable-length-protocolprotocol-head--payload">Variable length protocol(protocol head + payload)&lt;/h3>
&lt;p>Generally, it is a custom protocol, which is composed of a fixed length and a variable content. The fixed length part needs to specify the length of the variable content part.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>+————————————————+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>|fixed-length |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+————————————————+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>|variable content|
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+————————————————+
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;blockquote>
&lt;p>Refer to Netty&amp;rsquo;s &lt;code>LengthFieldBasedFrameDecoder&lt;/code>&lt;/p>
&lt;/blockquote>
&lt;p>The Dubbo protocol is actually a variable length protocol, which is covered in more detail in later chapters.&lt;/p>
&lt;h2 id="the-dubbo-protocol">The Dubbo protocol&lt;/h2>
&lt;h3 id="overview-to-the-dubbo-protocol">Overview to the Dubbo protocol&lt;/h3>
&lt;p>The Dubbo framework defines a proprietary RPC protocol in which the specific content of the request and response protocols is presented using a table.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/dev/dubbo_protocol_header.png" alt="/dev-guide/images/dubbo_protocol_header.jpg">&lt;/p>
&lt;h3 id="dubbo-protocol-details">Dubbo protocol details&lt;/h3>
&lt;ul>
&lt;li>
&lt;p>Magic - Magic High &amp;amp; Magic Low (16 bits)&lt;/p>
&lt;p>Identify protocol version, Dubbo protocol: 0xdabb&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Req/Res (1 bit)&lt;/p>
&lt;p>Identify a request or response. request: 1; response: 0.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>2 Way (1 bit)&lt;/p>
&lt;p>Only useful when Req/Res is 1(request), identifying if you expect to return a value from the server. Set to 1 if a return value from the server is required.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Event (1 bit)&lt;/p>
&lt;p>Identifies whether it is an event message, for example, a heartbeat event. Set to 1 if this is an event.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Serialization ID (5 bit)&lt;/p>
&lt;p>Identifies the serialization type: for example, the value of fastjson is 6.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Status (8 bits)&lt;/p>
&lt;p>Only useful when Req/Res is 0 (response), used to identify the status of the response&lt;/p>
&lt;ul>
&lt;li>20 - OK&lt;/li>
&lt;li>30 - CLIENT_TIMEOUT&lt;/li>
&lt;li>31 - SERVER_TIMEOUT&lt;/li>
&lt;li>40 - BAD_REQUEST&lt;/li>
&lt;li>50 - BAD_RESPONSE&lt;/li>
&lt;li>60 - SERVICE_NOT_FOUND&lt;/li>
&lt;li>70 - SERVICE_ERROR&lt;/li>
&lt;li>80 - SERVER_ERROR&lt;/li>
&lt;li>90 - CLIENT_ERROR&lt;/li>
&lt;li>100 - SERVER_THREADPOOL_EXHAUSTED_ERROR&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>Request ID (64 bits)&lt;/p>
&lt;p>Identifies the only request, the type is long.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Data Length (32 bits)&lt;/p>
&lt;p>The length of the serialized content (variable part), counted in bytes, the type is int.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Variable Part&lt;/p>
&lt;p>After being serialized by a specific serialization type (identified by the serialization ID), each part is a byte [] or byte.&lt;/p>
&lt;ul>
&lt;li>If it is a request packet (Req/Res = 1), each part is:
&lt;ul>
&lt;li>Dubbo version&lt;/li>
&lt;li>Service name&lt;/li>
&lt;li>Service version&lt;/li>
&lt;li>Method name&lt;/li>
&lt;li>Method parameter types&lt;/li>
&lt;li>Method arguments&lt;/li>
&lt;li>Attachments&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>If it is a response packet (Req/Res = 0), each part is:
&lt;ul>
&lt;li>Return value&amp;rsquo;s type (byte), identifying the type of value returned from the server:
&lt;ul>
&lt;li>Return null: RESPONSE_NULL_VALUE 2&lt;/li>
&lt;li>Normal response value: RESPONSE_VALUE 1&lt;/li>
&lt;li>Exception: RESPONSE_WITH_EXCEPTION 0&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>Return value: response bytes returned from the server&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Note:&lt;/strong> For the variable part, when uses json serialization in current version of Dubbo framework, an additional line break is added as a separator between each part of the content. Please add a new line break after each part of the variable part, such as:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>Dubbo version bytes (line break)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Service name bytes (line break)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="advantages-and-disadvantages-about-the-dubbo-protocol">Advantages and disadvantages about the Dubbo protocol&lt;/h2>
&lt;h3 id="advantages">Advantages&lt;/h3>
&lt;ul>
&lt;li>The protocol is designed to be very compact. The data type can be represented by 1 bit will not be represented by a byte, such as a boolean type identifier.&lt;/li>
&lt;li>The request header is the same as response header, and the specific content is assembled to the variable part through the serializer, and it is simple to implement.&lt;/li>
&lt;/ul>
&lt;h3 id="to-be-improved">To be improved&lt;/h3>
&lt;ul>
&lt;li>
&lt;p>Similar to the http request, the header can determine the resource to be accessed, and Dubbo needs to involve the specific serializer to resolve the service name, method, method signature, and these resource locators are string type or string array. It&amp;rsquo;s easy to convert to bytes, so it can be assembled into the header. Similar to http2 header compression, resources called for rpc can also be negotiated with an int to identify, which improves performance. This is easier to implement if the resource locator is assembled on &lt;code>header&lt;/code>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Use req/res to determine if it is a request, then you can refine the protocol, remove some unwanted identifiers and add some specific identifiers. For example, &lt;code>status&lt;/code>, &lt;code>twoWay&lt;/code> can be strictly customized to remove redundant identifiers. There is also a timeout identifier that is transmitted as the &lt;code>attachment&lt;/code> of the Dubbo. In theory, it should be placed in the header of the request protocol, because the timeout is essential in the network request. Referring to &lt;code>attachment&lt;/code>, you can see from the implementation that there are some fields in &lt;code>attachment&lt;/code> that are duplicated with existing fields in &lt;code>content&lt;/code>, such as &lt;code>path&lt;/code> and &lt;code>version&lt;/code>, which increase the protocol size.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Dubbo will convert the service name &lt;code>com.alibaba.middleware.hsf.guide.api.param.ModifyOrderPriceParam&lt;/code> to &lt;code>Lcom/alibaba/middleware/hsf/guide/api/param/ModifyOrderPriceParam;&lt;/code>, which is theoretically unnecessary, simply append a &lt;code>;&lt;/code> will be fine.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>The Dubbo protocol does not reserve extension fields, and cannot add new identifiers. The scalability is not very good. For example, the only way to add the &lt;code>response context&lt;/code> function is to change the protocol version, but this requires both the client and server versions to be upgraded. Very unfriendly in distributed scenarios.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>This article mainly introduces the concept of the protocol and the commonly used protocol mode. Then it analyzes the Dubbo protocol in detail and also mentions some shortcomings. However, compared with its simplicity and ease of implementation, the above shortcomings are not enough to drive us to redesign a new version of the protocol, so we welcome suggestions and features for protocol optimization.&lt;/p></description></item><item><title>Blog: Integrate Dubbo with Kubernetes</title><link>https://dubbo.apache.org/en/blog/2018/09/30/integrate-dubbo-with-kubernetes/</link><pubDate>Sun, 30 Sep 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/09/30/integrate-dubbo-with-kubernetes/</guid><description>
&lt;h1 id="general-goal">General goal&lt;/h1>
&lt;p>Dubbo&amp;rsquo;s provider don&amp;rsquo;t care about service registration.Open its Dubbo service port,the declaration and publishment of the service will be executed by Kubernetes.
Dubbo&amp;rsquo;s consumer directly discovers the corresponding service endpoints of Kubernetes during service discovery procedure, thereby reusing Dubbo&amp;rsquo;s existing microservice channel capabilities.The benefit is that there is no need to rely on any third-party soft-loaded registry and it can be seamlessly integrated into the multi-tenant security system of Kubernetes. Reference demo : &lt;a href="https://github.com/dubbo/dubbo-Kubernetes">https://github.com/dubbo/dubbo-ubernetes&lt;/a>&lt;/p>
&lt;h1 id="introduction">Introduction&lt;/h1>
&lt;p>Kubernates is a hierarchical system with rich secondary development function based on the expansibility.&lt;/p>
&lt;ul>
&lt;li>First of all, Kubernates&amp;rsquo;s core function is to manage the container cluster. Kubernates manages the storage and calculation of containerized cluster, based on the container runtime (CRI), network interface (CNI) and storage service interface (CSI/FV).&lt;/li>
&lt;li>Secondly,Kubernates has application-oriented deployment and routing capabilities,including statefulness/statelessness,batch processing and service-oriented applications,especially the application management based on microservices architecture which includes service discovery,service definition and unified configuration on the basis of configmap.&lt;/li>
&lt;li>Finally, on top of the abstract model of the basic resource (mainly the resources of abstract infrastructure, IaaS) and the application layer is the governance layer, which includes elastic expansion, namespaces/tenants and so on. Naturally, it is a matter of course to set up service about unified log center and omnidirectional monitoring on the Kubernetes based upon the foundational capabilities of atomic inner core.&lt;/li>
&lt;/ul>
&lt;p>We will explain the above description with a diagram of Kubernetes Architecture. In 2018, Kubernetes took a qualitative step toward the standard PaaS basement.Someone hold opinions that the reason is the ability for secondary development on the basis of the expansion and someone think the key is declarative programming and strong community operations relying on Google and Redhat. However,I think the essential reason is Layered architecture and the abstract domain modeling in the problem domain as the figure below.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/k8s/1.png" alt="img">&lt;/p>
&lt;p>From a micro-service architecture perspective, Kubernetes is a micro-service framework (more appropriate than a micro-service platform or toolkit set at this time) in a sense, supporting the basic capabilities of microservices for service discovery/registration. Use the following table to make a brief description.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align:left">The design of microservice&lt;/th>
&lt;th style="text-align:left">The function of Kubernetes&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align:left">Point 1:API gateway&lt;/td>
&lt;td style="text-align:left">Ingress&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Point 2:Statelessness, distinguish between stateful and stateless applications&lt;/td>
&lt;td style="text-align:left">Stateless corresponds to Deployment,and stateful corresponds to StatefulSet&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Point 3:Horizontal expansion of the database&lt;/td>
&lt;td style="text-align:left">Headless service points to PaaS service or StatefulSet deployment&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Point 4:Cache&lt;/td>
&lt;td style="text-align:left">Headless service points to PaaS service or StatefulSet deployment&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Point 5:Service splitting and service discovery&lt;/td>
&lt;td style="text-align:left">Service&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Point 6:Service orchestration and flexibility&lt;/td>
&lt;td style="text-align:left">Replicas of deployment&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Point 7:Unified configuration center&lt;/td>
&lt;td style="text-align:left">ConfigMap&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Point 8:Unified log center&lt;/td>
&lt;td style="text-align:left">DaemonSet deploys log agent&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Point 9:Circut break, current limiting and downgrade&lt;/td>
&lt;td style="text-align:left">Service Mesh&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Point 10:Comprehensive monitoring&lt;/td>
&lt;td style="text-align:left">Cadsivor, DaemonSet deploys and monitors Agent&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>By the way, the microservices field involves many issues, which can be explained as follows. When building microservices, we will delve into Distributed System, a discipline has a 40-year research background and is rooted in the adaptive system theory. It&amp;rsquo;s a bit complicated, but the concepts it covers are more or less heard for us, and it solves problems that we&amp;rsquo;re familiar with:&lt;/p>
&lt;ul>
&lt;li>Deployment&lt;/li>
&lt;li>Delivery&lt;/li>
&lt;li>APIs&lt;/li>
&lt;li>Versioning&lt;/li>
&lt;li>Contracts&lt;/li>
&lt;li>Scaling / Autoscaling&lt;/li>
&lt;li>Service Discovery&lt;/li>
&lt;li>Load Balancing&lt;/li>
&lt;li>Routing / Adaptive Routing&lt;/li>
&lt;li>Health Checking&lt;/li>
&lt;li>Configuration&lt;/li>
&lt;li>Circuit Breaking&lt;/li>
&lt;li>Bulk-heads&lt;/li>
&lt;li>TTL / Deadlining&lt;/li>
&lt;li>Latency Tracing&lt;/li>
&lt;li>Service Causal Tracing&lt;/li>
&lt;li>Distributed logging&lt;/li>
&lt;li>Metrics Exposure, Collection&lt;/li>
&lt;/ul>
&lt;p>For Kubernetes, only a few of problems are solved. Problems such as Dynamic Routing, Stability Control (Circuit Breaking, Bulk-heads, etc.) , Distributed Service Tracking, etc. are all the blank. These problems are exactly what Service Mesh needs to solve, and these also plays an important role in CNCF&amp;rsquo;s Tail Map. Of course, as Dubbo is a basically complete microservices infrastructure (Dubbo is based on the Sidecar which is a common solution for solving cross-language claims in Service Mesh, and the details of Dubbo are so complicated that they need to be explained in the new topic ) , that is to say, it is very meaningful to integrate Dubbo into the k8s system. The original definition of Service Mesh is cited below:&lt;/p>
&lt;blockquote>
&lt;p>&lt;span data-type="color" style="color:rgb(119, 119, 119)">&lt;span data-type="background" style="background-color:rgb(255, 255, 255)">A service mesh is a dedicated infrastructure layer for handling service-to-service communication. It's responsible for the reliable delivery of requests through the complex topology of services that comprise a modern, cloud native application.&lt;/span>&lt;/span>&lt;/p>
&lt;/blockquote>
&lt;p>We will know the existing solution, Dubbo integrates the Clould Native Equipment - Kubernetes&amp;rsquo;s basic abilities to solve the microservices&amp;rsquo;s core problems, can be regarded as a Service Mesh solution in a narrow sense, but it can only be used in the Java field. You can understand the above words as a joke, haha.&lt;/p>
&lt;h1 id="tspan-data-typecolor-stylecolorrgb51-51-51span-data-typebackground-stylebackground-colorrgb255-255-255houghtspanspanplan">T&lt;span data-type="color" style="color:rgb(51, 51, 51)">&lt;span data-type="background" style="background-color:rgb(255, 255, 255)">hought&lt;/span>&lt;/span>/Plan&lt;/h1>
&lt;p>Kubernetes is a natural address registration center for microservices, similar to zookeeper, VIPserver and Configserver used internally by Alibaba. Specifically, the Pod in Kubernetes is a running instance of the application. The scheduled deployment/start/stop of the Pod will call the API-Server service to maintain its state to ETCD. The service in Kubernetes is coresponded to the concept of the microservices defined as follows.&lt;/p>
&lt;blockquote>
&lt;p>A Kubernetes Service is an abstraction layer which defines a logical set of Pods and enables external traffic exposure, load balancing and service discovery for those Pods.&lt;/p>
&lt;/blockquote>
&lt;p>In conclusion, the Kubernetes service has the following characteristics:&lt;/p>
&lt;ul>
&lt;li>Each Service has a unique name and corresponding IP. IP is automatically assigned by Kubernetes and the name is defined by the developer.&lt;/li>
&lt;li>Service IP has several manifestations: ClusterIP, NodePort, LoadBalance and Ingress. ClusterIP is mainly used for intra-cluster communication; NodePort, Ingress and LoadBalance, which are used to expose services to access portals outside the cluster.&lt;/li>
&lt;/ul>
&lt;p>At first sight, the service of Kubernetes has its own IP, while under the original fixed mindset: Dubbo/HSF service is aggregated by the IP of the entire service cluster, that means, Kubernetes and Dubbo/HSF look like something different in natural, but when carefully thinking, the difference becomes insignificant. Because the only IP under Kubernetes is just a Virtural IP&amp;ndash;VIP, behind the vip are multiple endpoints, which is the factual processing node.&lt;/p>
&lt;p>Here we only discuss the situation that the Dubbo service in the cluster is accessed in the same Kubernetes cluster, As for the provider outside Kubernetes to access the provider in Kubernetes, since it involves the problem of network address space, and it usually requires GateWay/loadbalance for mapping conversion, which there not detail discussion for this case. Besides, there are two options available for Kubernetes:&lt;/p>
&lt;ol>
&lt;li>
&lt;p>DNS: The default Kubernetes service is based on the DNS plugin (The latest version of the recommendation is coreDNS), one proposal on Dubbo is about this.  since HSF/Dubbo has always highlighted its soft-load address discovery capability, it ignores Static&amp;rsquo;s strategy insteadily, my understanding is that as a service discovery mechanism, the static resolution mechanism is one of the simplest and most needed to support mechanism, you can also refer to Envoy&amp;rsquo;s point of views. While at the same time, ant&amp;rsquo;s SOFA has always supported this static strategy, it can provides an explanation for an engineering fragment of the SOFA project. There are two advantages to doing this. 1) When the soft load center crash is unavailable and the address list cannot be obtained, there is a mechanism to Failover to this policy to handle certain requests. 2) Under LDC/unitization, the ant&amp;rsquo;s load center cluster is deployed in the equipment room/area. First, the LDC of the soft load center is guaranteed to be stable and controllable. When the unit needs the request center, the address of the VIP can come in handy.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/2018/09/30/integrate-dubbo-with-kubernetes/TB1Kj1ktpkoBKNjSZFEXXbrEVXa-985-213.png" alt="img">&lt;/p>
&lt;/li>
&lt;li>
&lt;p>API:DNS relies on the DNS plugin, which will generate additional operation, so consider directly obtaining the endpoint through the client of Kubernetes. In fact, by accessing the API server interface of Kubernetes, you can directly obtain the list of endpoints behind a certain servie, and can also monitor the changes in its address list. Thereby implementing the soft load discovery strategy recommended by Dubbo/HSF. Refer to the code for details:&lt;/p>
&lt;/li>
&lt;/ol>
&lt;p>The above two thoughts need to consider the following two points:&lt;/p>
&lt;ol>
&lt;li>Kubernetes and Dubbo are consistent with the mapping name of service. Dubbo&amp;rsquo;s service is determined by serviename, group, version to determine its uniqueness, and servicename generally has a longer package name for its service interface. Need to map the servie name of Kubernetes and the service name of dubbo. Either add a property like SOFA to define it. This is a big change, but it is most reasonable. Or it is a fixed rule to reference the deployed environment variables, which can be used for quick verification.&lt;/li>
&lt;li>Port problem:The default Pod and Pod network interoperability is solved, need to be validated.&lt;/li>
&lt;/ol>
&lt;h2 id="demo-verification">Demo Verification&lt;/h2>
&lt;p>The following is a demo deployment through Kubernetes service in Alibaba Cloud&amp;rsquo;s Container Registry and EDAS. Visit Alibaba Cloud -》Container Registry.&lt;/p>
&lt;ol>
&lt;li>
&lt;p>Create repo and bind the github codebase. As shown below.
&lt;img src="https://dubbo.apache.org/imgs/blog/2018/09/30/integrate-dubbo-with-kubernetes/TB1m.tEtrorBKNjSZFjXXc_SpXa-1892-870.png" alt="img">&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Click Manage enter the repository details page. Click Build in images service panel, construct the demo into image and publish it to the specified repository. As shown below.
&lt;img src="https://dubbo.apache.org/imgs/blog/2018/09/30/integrate-dubbo-with-kubernetes/TB1oYqvtcIrBKNjSZK9XXagoVXa-1872-888.png" alt="img">&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Switch to Enterprise Distributed Application Services (EDAS) products panel, visit Resource Management -&amp;gt; Clusters. Create Kubernetes cluster and bind ECS. As shown below.
&lt;img src="https://dubbo.apache.org/imgs/blog/2018/09/30/integrate-dubbo-with-kubernetes/TB1b1p2trZnBKNjSZFKXXcGOVXa-1858-833.png" alt="img">&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Application Management -&amp;gt; Create application, type Kubernetes application and specify the image in the container registry . As shown below.
&lt;img src="https://dubbo.apache.org/imgs/blog/2018/09/30/integrate-dubbo-with-kubernetes/TB1_YywtDCWBKNjSZFtXXaC3FXa-1737-588.png" alt="img">&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/2018/09/30/integrate-dubbo-with-kubernetes/TB18uzTtdcnBKNjSZR0XXcFqFXa-1820-861.png" alt="img">&lt;/p>
&lt;/li>
&lt;li>
&lt;p>After creation , then deploy applications. As shown below.
&lt;img src="https://dubbo.apache.org/imgs/blog/2018/09/30/integrate-dubbo-with-kubernetes/TB1fEpEtrorBKNjSZFjXXc_SpXa-1846-783.png" alt="img">&lt;/p>
&lt;/li>
&lt;/ol>
&lt;ul>
&lt;li>
&lt;p>The supplementary application name cannot have uppercase letters, all lowercase, otherwise there is a problem of deployment failure.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>When creating an app, after selecting the image, the next button cannot be clicked and you need to click Choose to continue.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>EDAS has two independent Kubernetes services, one based on Alibaba Cloud&amp;rsquo;s container service, and one set by Lark. I experience the latter.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>The development joint of Docker and IDE integration, you need to consider the relevant plug-ins for integrating IDEA.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>There is always an error in deployment, maybe there is a problem with the Kubernetes service. Need further investigation.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-json" data-lang="json">&lt;span style="display:flex;">&lt;span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;kind&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;Pod&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;namespace&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;lzumwsrddf831iwarhehd14zh2-default&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;name&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;dubbo-k8s-demo-610694273-jq238&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;uid&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;12892e67-8bc8-11e8-b96a-00163e02c37b&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;apiVersion&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;v1&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;#34;resourceVersion&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;850282769&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}, &lt;span style="color:#2aa198">&amp;#34;reason&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;FailedSync&amp;#34;&lt;/span>, &lt;span style="color:#2aa198">&amp;#34;message&amp;#34;&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;Error syncing pod&amp;#34;&lt;/span>, &amp;#34;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item><item><title>Blog: How to prepare an Apache Release</title><link>https://dubbo.apache.org/en/blog/2018/09/02/how-to-prepare-an-apache-release/</link><pubDate>Sun, 02 Sep 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/09/02/how-to-prepare-an-apache-release/</guid><description>
&lt;h2 id="understanding-the-apache-release-cycle">Understanding the Apache Release Cycle&lt;/h2>
&lt;p>In general, Source Release is the key and the required content of Apache. But Binary Release is optional, Dubbo can choose whether to release binary packages to the Apache repository or to the Maven central repository.&lt;/p>
&lt;p>Please refer to the following links for more information on ASF&amp;rsquo;s release guide:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="http://www.apache.org/dev/release-publishing">Apache Release Guide&lt;/a>&lt;/li>
&lt;li>&lt;a href="http://www.apache.org/dev/release.html">Apache Release Policy&lt;/a>&lt;/li>
&lt;li>&lt;a href="http://www.apache.org/dev/publishing-maven-artifacts.html">Maven Release Info&lt;/a>&lt;/li>
&lt;/ul>
&lt;h2 id="preparation-of-local-building-environment">Preparation of Local Building Environment&lt;/h2>
&lt;p>Mainly including the related preparation of signature utilities and Maven repository certification&lt;/p>
&lt;ol>
&lt;li>
&lt;p>Install GPG,refer to &lt;a href="https://www.gnupg.org/download/index.html">https://www.gnupg.org/download/index.html&lt;/a>&lt;/p>
&lt;ul>
&lt;li>For example, in Mac OS&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>$ brew install gpg
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ gpg --version &lt;span style="color:#586e75">#check version,should be 2.x&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>Generate the key with GPG&lt;/p>
&lt;ul>
&lt;li>Generate the key according to the prompt&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ gpg2 --full-gen-key
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>gpg &lt;span style="color:#719e07">(&lt;/span>GnuPG&lt;span style="color:#719e07">)&lt;/span> 2.0.12; Copyright &lt;span style="color:#719e07">(&lt;/span>C&lt;span style="color:#719e07">)&lt;/span> &lt;span style="color:#2aa198">2009&lt;/span> Free Software Foundation, Inc.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>This is free software: you are free to change and redistribute it.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>There is NO WARRANTY, to the extent permitted by law.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Please &lt;span style="color:#719e07">select&lt;/span> what kind of key you want:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">(&lt;/span>1&lt;span style="color:#719e07">)&lt;/span> RSA and RSA &lt;span style="color:#719e07">(&lt;/span>default&lt;span style="color:#719e07">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">(&lt;/span>2&lt;span style="color:#719e07">)&lt;/span> DSA and Elgamal
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">(&lt;/span>3&lt;span style="color:#719e07">)&lt;/span> DSA &lt;span style="color:#719e07">(&lt;/span>sign only&lt;span style="color:#719e07">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">(&lt;/span>4&lt;span style="color:#719e07">)&lt;/span> RSA &lt;span style="color:#719e07">(&lt;/span>sign only&lt;span style="color:#719e07">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Your selection? &lt;span style="color:#2aa198">1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>RSA keys may be between &lt;span style="color:#2aa198">1024&lt;/span> and &lt;span style="color:#2aa198">4096&lt;/span> bits long.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>What keysize &lt;span style="color:#719e07">do&lt;/span> you want? &lt;span style="color:#719e07">(&lt;/span>2048&lt;span style="color:#719e07">)&lt;/span> &lt;span style="color:#2aa198">4096&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Requested keysize is &lt;span style="color:#2aa198">4096&lt;/span> bits
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Please specify how long the key should be valid.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">0&lt;/span> &lt;span style="color:#719e07">=&lt;/span> key does not expire
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;n&amp;gt; &lt;span style="color:#719e07">=&lt;/span> key expires in n days
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;n&amp;gt;w &lt;span style="color:#719e07">=&lt;/span> key expires in n weeks
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;n&amp;gt;m &lt;span style="color:#719e07">=&lt;/span> key expires in n months
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;n&amp;gt;y &lt;span style="color:#719e07">=&lt;/span> key expires in n years
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Key is valid &lt;span style="color:#719e07">for&lt;/span>? &lt;span style="color:#719e07">(&lt;/span>0&lt;span style="color:#719e07">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Key does not expire at all
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Is this correct? &lt;span style="color:#719e07">(&lt;/span>y/N&lt;span style="color:#719e07">)&lt;/span> y
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>GnuPG needs to construct a user ID to identify your key.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Real name: Robert Burrell Donkin
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Email address: rdonkin@apache.org
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Comment: CODE SIGNING KEY
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>You selected this USER-ID:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">&amp;#34;Robert Burrell Donkin (CODE SIGNING KEY) &amp;lt;rdonkin@apache.org&amp;gt;&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Change &lt;span style="color:#719e07">(&lt;/span>N&lt;span style="color:#719e07">)&lt;/span>ame, &lt;span style="color:#719e07">(&lt;/span>C&lt;span style="color:#719e07">)&lt;/span>omment, &lt;span style="color:#719e07">(&lt;/span>E&lt;span style="color:#719e07">)&lt;/span>mail or &lt;span style="color:#719e07">(&lt;/span>O&lt;span style="color:#719e07">)&lt;/span>kay/&lt;span style="color:#719e07">(&lt;/span>Q&lt;span style="color:#719e07">)&lt;/span>uit? O
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>You need a Passphrase to protect your secret key. &lt;span style="color:#586e75"># enter the password, which will be used frequently when packaging.&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>View key id&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>$ gpg --list-keys
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>pub rsa4096/28681CB1 2018-04-26 &lt;span style="color:#586e75"># 28681CB1 is the key id&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>uid &lt;span style="color:#719e07">[&lt;/span>ultimate&lt;span style="color:#719e07">]&lt;/span> liujun &lt;span style="color:#719e07">(&lt;/span>apache-dubbo&lt;span style="color:#719e07">)&lt;/span> &amp;lt;liujun@apache.org&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sub rsa4096/D3D6984B 2018-04-26
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">########### Note: Different diaplay for different version.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ gpg --list-keys
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>pub rsa4096 2018-11-12 &lt;span style="color:#719e07">[&lt;/span>SC&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> 63AAE9838F4A303E40BAF5FEA3A1CA7A5D4A3981 &lt;span style="color:#586e75"># Last 8 character(5D4A3981) as key id,it will be used when send public key to keyserver&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>uid &lt;span style="color:#719e07">[&lt;/span> 绝对 &lt;span style="color:#719e07">]&lt;/span> Victory Cao &lt;span style="color:#719e07">(&lt;/span>CODE SIGNING KEY&lt;span style="color:#719e07">)&lt;/span> &amp;lt;victory@apache.org&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sub rsa4096 2018-11-12 &lt;span style="color:#719e07">[&lt;/span>E&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"># send public key to keyserver via key id &lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ gpg --keyserver pgpkeys.mit.edu --send-key 28681CB1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"># Here pgpkeys.mit.edu is a random selection of keyserver. Any key server from the list https://sks-keyservers.net/status/ is acceptable because they are automatically synchronized.&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>If there are multiple public keys,you can set the default key&lt;/li>
&lt;/ul>
&lt;p>~/.gnupg/gpg.conf&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span># If you have more than 1 secret key in your keyring, you may want to
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span># uncomment the following option and set your preferred keyid.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>default-key 28681CB1
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>If there are multiple public keys, you can also delete unuseful key:&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">### Delete the private key first, then delete the public key.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ gpg --yes --delete-secret-keys shenglicao2@gmail.com &lt;span style="color:#586e75">### indicate email address &lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ gpg --delete-keys 1808C6444C781C0AEA0AAD4C4D6A8007D20DB8A4
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>Set up Apache central repository.&lt;/p>
&lt;ul>
&lt;li>The parent pom of Dubbo project is apache pom&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;parent&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.apache&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>apache&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>19&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/parent&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>
&lt;p>Add the following contents to .m2/settings.xml&lt;/p>
&lt;p>Enter the passwords after
encrypting by &lt;a href="http://maven.apache.org/guides/mini/guide-encryption.html">maven-encryption-plugin&lt;/a>&lt;/p>
&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;settings&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;servers&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- To publish a snapshot of some part of Maven --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;server&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;id&amp;gt;&lt;/span>apache.snapshots.https&lt;span style="color:#268bd2">&amp;lt;/id&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;username&amp;gt;&lt;/span> &lt;span style="color:#586e75">&amp;lt;!-- YOUR APACHE LDAP USERNAME --&amp;gt;&lt;/span> &lt;span style="color:#268bd2">&amp;lt;/username&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;password&amp;gt;&lt;/span> &lt;span style="color:#586e75">&amp;lt;!-- YOUR APACHE LDAP PASSWORD (encrypted) --&amp;gt;&lt;/span> &lt;span style="color:#268bd2">&amp;lt;/password&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/server&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- To stage a release of some part of Maven --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;server&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;id&amp;gt;&lt;/span>apache.releases.https&lt;span style="color:#268bd2">&amp;lt;/id&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;username&amp;gt;&lt;/span> &lt;span style="color:#586e75">&amp;lt;!-- YOUR APACHE LDAP USERNAME --&amp;gt;&lt;/span> &lt;span style="color:#268bd2">&amp;lt;/username&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;password&amp;gt;&lt;/span> &lt;span style="color:#586e75">&amp;lt;!-- YOUR APACHE LDAP PASSWORD (encrypted) --&amp;gt;&lt;/span> &lt;span style="color:#268bd2">&amp;lt;/password&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/server&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- gpg passphrase used when generate key --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;server&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;id&amp;gt;&lt;/span>gpg.passphrase&lt;span style="color:#268bd2">&amp;lt;/id&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;passphrase&amp;gt;&lt;/span>&lt;span style="color:#586e75">&amp;lt;!-- yourKeyPassword --&amp;gt;&lt;/span>&lt;span style="color:#268bd2">&amp;lt;/passphrase&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/server&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/servers&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/settings&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;/ol>
&lt;h2 id="pack--upload">Pack &amp;amp; Upload&lt;/h2>
&lt;ol>
&lt;li>
&lt;p>Pull the new branch from the master branch as the release branch. If you want to release the ${release_version} version now, pull the new branch ${release_version}-release from 2.6.x. Then the
modifications and taggings related to ${release_version} Release Candidates are applied to ${release_version}-release branch, and is merged into the master branch after the final release.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>First of all, verify that the maven component packing, source packing, signature, etc are working properly on the ${release_version}-release branch.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ mvn clean install -Papache-release
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ mvn deploy
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;/ol>
&lt;p>This push the snapshot package to the maven central repository.&lt;/p>
&lt;ol start="3">
&lt;li>
&lt;p>Release with maven-release-plugin&lt;/p>
&lt;ul>
&lt;li>verify with dryRun&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ mvn release:prepare -Prelease -Darguments&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;-Dmaven.test.skip=true&amp;#34;&lt;/span> -DautoVersionSubmodules&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#b58900">true&lt;/span> -Dusername&lt;span style="color:#719e07">=&lt;/span>YOUR GITHUB ID -DdryRun&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#b58900">true&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>After verification, run release:prepare&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ mvn release:clean
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ mvn release:prepare -Prelease -Darguments&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;-Dmaven.test.skip=true&amp;#34;&lt;/span> -DautoVersionSubmodules&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#b58900">true&lt;/span> -Dusername&lt;span style="color:#719e07">=&lt;/span>YOUR GITHUB ID -DpushChanges&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#b58900">false&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;blockquote>
&lt;p>If you are promted to input password for pushing to GitHub (basically including adding new commits and tags), do not input your login password of GitHub. Use &lt;code>Personal access tokens&lt;/code> instead. You can go to &lt;a href="https://github.com/settings/profile">https://github.com/settings/profile&lt;/a>, click &lt;code>Developer settings&lt;/code> -&amp;gt; &lt;code>Personal access tokens&lt;/code>, and generate a new token if not. Please refer to this &lt;a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token">guide&lt;/a> for more infomation.
you need to choose the release artifactId, next artifactId and the release tag, the default tag is dubbo-parent-xxxx, you need to change it to dubbo-xxxx&lt;/p>
&lt;/blockquote>
&lt;p>After executing the above commands, you will find that:&lt;/p>
&lt;ol>
&lt;li>source-release.zip and bin-release.zip are generated under dubbo-distribution directory, please unzip it and check the file structure&lt;/li>
&lt;li>&lt;code>-DpushChanges=false&lt;/code> tells maven not to push the commits and tags to the remote repostiroy. If not specified, the version tag will be pushed to github repository, you will see a commit called &lt;code>[maven-release-plugin] prepare release dubbo-x.x.x&lt;/code> added.&lt;/li>
&lt;li>The branch version is upgraded to ${release_version+1}-SNAPSHOT automatically. If &lt;code>-DpushChanges=true&lt;/code> is specified, the modifications will be pushed to the remote repository, you will see a commit called &lt;code>[maven-release-plugin] prepare for next development iteration&lt;/code> added.&lt;/li>
&lt;/ol>
&lt;p>If &lt;code>-DpushChanges=false&lt;/code> is specified, you will have to manually push the commit to remote repository before go to next step.&lt;/p>
&lt;ul>
&lt;li>Run release:perform&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ mvn release:perform -Prelease -Darguments&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;-Dmaven.test.skip=true&amp;#34;&lt;/span> -DautoVersionSubmodules&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#b58900">true&lt;/span> -Dusername&lt;span style="color:#719e07">=&lt;/span>YOUR GITHUB ID
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Maven will download the source code from the tag you just pushed, compile it, and deploy to remote maven repsoitry in staging state.&lt;/p>
&lt;/li>
&lt;/ol>
&lt;h3 id="note">Note&lt;/h3>
&lt;blockquote>
&lt;p>When you deploy the package into repository, it will be interrupted for network. So you must restart to desploy.&lt;br>
The problem is that missing package occurred many times at deploying. So you should check the quantity of package, especially parent package.&lt;/p>
&lt;/blockquote>
&lt;h2 id="prepare-apache-release">Prepare Apache Release&lt;/h2>
&lt;ol>
&lt;li>
&lt;p>Prepare the svn local environment (Apache hosting the release content of project by svn)&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Checkout dubbo to local directory&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ svn checkout https://dist.apache.org/repos/dist/dev/dubbo
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Assume that the local directory is &lt;code>~/apache/incubator/dubbo&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>The current release version is ${release_version}, new directory&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ &lt;span style="color:#b58900">cd&lt;/span> ~/apache/incubator/dubbo &lt;span style="color:#586e75"># dubbo svn root directory&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ mkdir &lt;span style="color:#2aa198">${&lt;/span>&lt;span style="color:#268bd2">release_version&lt;/span>&lt;span style="color:#2aa198">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>Add public key to &lt;a href="https://dist.apache.org/repos/dist/dev/dubbo/KEYS">KEYS&lt;/a> file if you are the first time to be a release manager. KEYS is mainly used to allow people who participate in the voting to be imported locally to verify the correctness of the sign.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ gpg -a --export your_key_id &amp;gt;&amp;gt; KEYS
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>For more information on how to get your key id, please refer to this &lt;a href="https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key">guide&lt;/a>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Copy the source.zip package from the Dubbo root directory to the svn local repository dubbo/${release_version}&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Generate sha512 sign&lt;/p>
&lt;p>For source-release.zip&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ shasum -a &lt;span style="color:#2aa198">512&lt;/span> apache-dubbo-&lt;span style="color:#2aa198">${&lt;/span>&lt;span style="color:#268bd2">release_version&lt;/span>&lt;span style="color:#2aa198">}&lt;/span>-source-release.zip &amp;gt;&amp;gt; apache-dubbo-&lt;span style="color:#2aa198">${&lt;/span>&lt;span style="color:#268bd2">release_version&lt;/span>&lt;span style="color:#2aa198">}&lt;/span>-source-release.zip.sha512
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>For bin-release.zip&lt;/p>
&lt;p>Please add &lt;code>-b&lt;/code> paramter when generating sha512 for bin-release.zip, which indicates it is a binary file.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ shasum -b -a &lt;span style="color:#2aa198">512&lt;/span> apache-dubbo-&lt;span style="color:#2aa198">${&lt;/span>&lt;span style="color:#268bd2">release_version&lt;/span>&lt;span style="color:#2aa198">}&lt;/span>-bin-release.zip &amp;gt;&amp;gt; apache-dubbo-&lt;span style="color:#2aa198">${&lt;/span>&lt;span style="color:#268bd2">release_version&lt;/span>&lt;span style="color:#2aa198">}&lt;/span>-bin-release.zip.sha512
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>You should generate something like this:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>b8f13d1df6d6c9a1facc72fafc00b2d22bea1e600517c507467d8fca2f776a7a3877101742da53114bfa629ca5b941eb4d9ef989de43f0833e2a794e7ccf5c8a *apache-dubbo-spring-boot-project-2.7.0-bin-release.zip
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Note there is a &lt;code>*&lt;/code> sign before the file name.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>If the binary release is accompanied with the source release. Run the following command in the dubbo-distribution module:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ mvn install
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Go to target directory, copy bin-release.zip and bin-release.zip.asc to svn local repository dubbo/${release_version}, and refer to step 6 to generate sha512 sign.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Commit to Apache svn&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ svn status
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ svn commit -m &lt;span style="color:#2aa198">&amp;#39;prepare for ${release_version} RC1&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;/ol>
&lt;h2 id="verify-release-candidates">Verify Release Candidates&lt;/h2>
&lt;p>&lt;strong>A full check list can be found &lt;a href="https://cwiki.apache.org/confluence/display/INCUBATOR/Incubator+Release+Checklist">here&lt;/a>&lt;/strong>&lt;/p>
&lt;p>The verification link includes but is not limited to the following contents and forms:&lt;/p>
&lt;h3 id="check-signatures-and-hashes-are-good">Check signatures and hashes are good&lt;/h3>
&lt;h4 id="check-the-sha512-sum">check the sha512 sum&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>$ shasum -c apache-dubbo-&lt;span style="color:#2aa198">${&lt;/span>&lt;span style="color:#268bd2">release_version&lt;/span>&lt;span style="color:#2aa198">}&lt;/span>-source-release.zip.sha512
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ shasum -c apache-dubbo-&lt;span style="color:#2aa198">${&lt;/span>&lt;span style="color:#268bd2">release_version&lt;/span>&lt;span style="color:#2aa198">}&lt;/span>-bin-release.zip.sha512
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="check-the-gpg-signarure">check the gpg signarure&lt;/h4>
&lt;p>If it&amp;rsquo;s your first time verify a release candidte, you should import public keys first.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span> $ curl https://dist.apache.org/repos/dist/dev/dubbo/KEYS &amp;gt;&amp;gt; KEYS &lt;span style="color:#586e75"># download public keys to local directory&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> $ gpg --import KEYS &lt;span style="color:#586e75"># import keys&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> $ gpg —edit-key liujun
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;gt; trust &lt;span style="color:#586e75"># type trust command&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Now, you can verify signature with command&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>gpg --verify apache-dubbo-2.6.3-source-release.zip.asc apache-dubbo-2.6.3-source-release.zip
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>gpg --verify apache-dubbo-2.6.3-bin-release.zip.asc apache-dubbo-2.6.3-bin-release.zip
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="check-source-release-file-content">Check source release file content&lt;/h3>
&lt;p>Unzip apache-dubbo-${release_version}-source-release.zip to the default directory and check the following:&lt;/p>
&lt;ul>
&lt;li>Directory with &amp;lsquo;incubating&amp;rsquo; in name
&lt;code>apache-dubbo-${release_version}-source-release&lt;/code>&lt;/li>
&lt;li>DISCLAIMER exists&lt;/li>
&lt;li>LICENSE and NOTICE exists and contents are good&lt;/li>
&lt;li>All files and no binary files exist&lt;/li>
&lt;li>All files has standard ASF License header&lt;/li>
&lt;li>Can compile from source&lt;/li>
&lt;li>All unit tests can pass
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>mvn clean &lt;span style="color:#b58900">test&lt;/span> &lt;span style="color:#586e75"># This will run all unit tests&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"># you can also open rat and style plugin to check if every file meets requirements.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>mvn clean &lt;span style="color:#b58900">test&lt;/span> -Drat.skip&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#b58900">false&lt;/span> -Dcheckstyle.skip&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#b58900">false&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>Release candidates match with corresponding tags, you can find tag link and hash in vote email.
&lt;ul>
&lt;li>check the version number in pom.xml are the same&lt;/li>
&lt;li>check there are no extra files or directories in the source package, for example, no empty directories or useless log files.&lt;br>
&lt;code>diff -r rc_dir tag_dir&lt;/code>&lt;/li>
&lt;li>check the top n tag commits, dive into the related files and check if the source package has the same changes&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h3 id="check-binary-distribution-file-content">Check binary distribution file content&lt;/h3>
&lt;p>Unzip apache-dubbo-${release_version}-bin-release.zip and check:&lt;/p>
&lt;ul>
&lt;li>Check signatures are good&lt;/li>
&lt;li>&amp;lsquo;incubating&amp;rsquo; in name&lt;/li>
&lt;li>LICENSE and NOTICE exists and contents are good&lt;/li>
&lt;/ul>
&lt;p>Note that if the binary distribution contains third party files, you may need to update LICENSE file by adding the 3rd party license files. If these dependency is Apache License 2.0, and it contains NOTICE file, you may also need to update NOTICE file as well.&lt;/p>
&lt;h2 id="release-vote">Release vote&lt;/h2>
&lt;p>The voting is divided into two phases:&lt;/p>
&lt;ol>
&lt;li>Dubbo community votes and sends the voting email to &lt;a href="mailto:dev@dubbo.apache.org">dev@dubbo.apache.org&lt;/a>. After reviewing by community developers and winning 3 binding tickets that agree to release, you can go to the next stage of voting.&lt;/li>
&lt;li>Apache community votes and sends the voting email to &lt;a href="mailto:general@incubator.apache.org">general@incubator.apache.org&lt;/a>. After reviewing by Apache IPMC(Incubator PMC) members and winning 3 binding votes that agree to release, you will be allowed to release officially.&lt;/li>
&lt;/ol>
&lt;p>The mail template for Apache Dubbo vote:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-tex" data-lang="tex">&lt;span style="display:flex;">&lt;span>Hello Dubbo Community,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>This is a call for vote to release Apache Dubbo (Incubating) version 2.6.2.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>The release candidates:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>https://dist.apache.org/repos/dist/dev/dubbo/2.6.2/
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Git tag for the release:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>https://github.com/apache/dubbo/tree/dubbo-2.6.2
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Hash for the release tag:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>afab04c53edab38d52275d2a198ea1aff7a4f41e
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Release Notes:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>https://github.com/apache/dubbo/releases/tag/untagged-4775c0a22c60fca55118
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>The artifacts have been signed with Key : 28681CB1, which can be found in the keys file:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>https://dist.apache.org/repos/dist/dev/dubbo/KEYS
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>The vote will be open for at least 72 hours or until necessary number of votes are reached.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Please vote accordingly:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>[ ] +1 approve
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>[ ] +0 no opinion
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>[ ] -1 disapprove with the reason
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Thanks,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>The Apache Dubbo (Incubating) Team
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The mail template for Apache Incubator vote:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-text" data-lang="text">&lt;span style="display:flex;">&lt;span>Hello all,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>This is a call for vote to release Apache Dubbo (Incubating) version 2.6.4.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>The Apache Dubbo community has voted on and approved a proposal to release
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Apache Dubbo (Incubating) version 2.6.4.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>We now kindly request the Incubator PMC members review and vote on this
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>incubator release.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Apache Dubbo™ is a high-performance, java based, open source
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>RPC framework. Dubbo offers three key functionalities, which include
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>interface based remote call, fault tolerance &amp;amp; load balancing, and
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>automatic service registration &amp;amp; discovery.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Dubbo community vote and result thread:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>https://lists.apache.org/thread.html/8d5c39eece6288beed2e22ca976350728c571d2a9cef1c9a9e56a409@%3Cdev.dubbo.apache.org%3E
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>A minor issue also can be found in the above thread.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>The release candidates (RC1):
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>https://dist.apache.org/repos/dist/dev/dubbo/2.6.4
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Git tag for the release (RC1):
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>https://github.com/apache/dubbo/tree/dubbo-2.6.4
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Hash for the release tag:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>88037747a3b69d3225c73f6fbcda36ebd8435887
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Release Notes:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>*https://github.com/apache/dubbo/blob/dubbo-2.6.4/CHANGES.md
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;https://github.com/apache/dubbo/blob/dubbo-2.6.4/CHANGES.md&amp;gt;*
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>The artifacts have been signed with Key : 7955FB6D1DD21CF7, which can be
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>found in the keys file:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>https://dist.apache.org/repos/dist/dev/dubbo/KEYS
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Look at here for how to verify this release candidate:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>https://github.com/apache/dubbo-website/blob/asf-site/blog/en-us/prepare-an-apache-release.md#prepare-apache-release
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>The vote will be open for at least 72 hours or until necessary number of
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>votes are reached.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Please vote accordingly:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>[ ] +1 approve
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>[ ] +0 no opinion
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>[ ] -1 disapprove with the reason
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Thanks,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>The Apache Dubbo (Incubating) Team
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The mail template to announce the vote result:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-text" data-lang="text">&lt;span style="display:flex;">&lt;span>We’ve received 3 +1 binding votes and one +1 non-binding vote:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+1 binding, Ian Luo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+1 binding, Huxing Zhang
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+1 binding, Jun Liu
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+1 non-binding, Jerrick
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>I will create a new vote thread in Apache community now.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Best regards,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>The Apache Dubbo (Incubating) Team
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="official-release">Official Release&lt;/h2>
&lt;p>When the release vote has passed,&lt;/p>
&lt;ol>
&lt;li>Add the release files to &lt;a href="https://dist.apache.org/repos/dist/release/dubbo">official release directory&lt;/a>&lt;/li>
&lt;li>Remove the release files in &lt;a href="https://dist.apache.org/repos/dist/dev/dubbo">dev directory&lt;/a>&lt;/li>
&lt;li>Remove the the release file for the previous release under &lt;a href="https://dist.apache.org/repos/dist/release/dubbo/">official release directory&lt;/a>, which will be archived and can be found &lt;a href="https://archive.apache.org/dist/incubator/dubbo/">here&lt;/a>&lt;/li>
&lt;li>Publish &lt;a href="https://github.com/apache/dubbo/releases">release notes&lt;/a> on Github.&lt;/li>
&lt;li>Update the recommend dependency on &lt;a href="https://github.com/apache/dubbo#maven-dependency">Github&lt;/a> to the latest version, also update the version in other place if necessary.&lt;/li>
&lt;li>Add the download link to official website &lt;a href="https://dubbo.apache.org/en/blog/2020/05/18/past-releases/">https://dubbo.apache.org/en/blog/2020/05/18/past-releases/&lt;/a>, using the ASF mirror system. The latest release download link should be something like &lt;code>https://www.apache.org/dyn/closer.cgi?path=incubator/dubbo/$VERSION/apache-dubbo-$VERSION-source-release.zip&lt;/code>. The download link for the previous release version should be changed like &lt;code>https://archive.apache.org/dist/incubator/dubbo/$VERSION/apache-dubbo-$VERSION-bin-release.zip)&lt;/code>. Please refer to the &lt;a href="https://dubbo.apache.org/en/blog/2020/05/18/past-releases/">download page&lt;/a> for more details.&lt;/li>
&lt;li>Make sure all the commits in the release branch are merged into master branch, and then remove the remote release branch. For example: &lt;code>git push origin --delete 2.7.0-release&lt;/code>&lt;/li>
&lt;li>Send mail to &lt;a href="mailto:dev@dubbo.apache.org">dev@dubbo.apache.org&lt;/a> and &lt;a href="mailto:general@incubator.apache.org">general@incubator.apache.org&lt;/a>, notify the community that the release is completed.
The mail template to announce release:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-text" data-lang="text">&lt;span style="display:flex;">&lt;span>Hello Community,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>The Apache Dubbo team is pleased to announce that the
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>2.6.6 has just been released.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Apache Dubbo™ is a high-performance, java based, open source
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>RPC framework. Dubbo offers three key functionalities, which include
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>interface based remote call, fault tolerance &amp;amp; load balancing, and
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>automatic service registration &amp;amp; discovery.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Both the source release[1] and the maven binary release[2] are available
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>now, you can also find the detailed release notes in here[3].
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>If you have any usage questions, or have problems when upgrading or find
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>any problems about enhancements included in this release, please don’t
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>hesitate to let us know by sending feedback to this mailing list or filing
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>an issue on GitHub[4].
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>=====
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>*Disclaimer*
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Apache Dubbo is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>[1] https://dubbo.apache.org/en/blog/2020/05/18/past-releases/
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>[2] http://central.maven.org/maven2/com/alibaba/dubbo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>[3] https://github.com/apache/dubbo/releases
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>[4] https://github.com/apache/dubbo/issues
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="complete-maven-convenient-binary-release">Complete Maven Convenient Binary release&lt;/h2>
&lt;p>&lt;strong>&lt;a href="https://repository.apache.org/">repository.apache.org&lt;/a> The permissions of the nexus repository have been applied, see &lt;a href="https://issues.apache.org/jira/browse/INFRA-16451">jira&lt;/a>。&lt;/strong>&lt;/p>
&lt;p>To release the maven artifacts, go to &lt;a href="https://repository.apache.org">repository.apache.org&lt;/a>, and choose the staging repository, click the release button. Wait for a moment and verify it at &lt;a href="https://repository.apache.org/content/repositories/releases/org/apache/dubbo/">here&lt;/a>, make sure your artifacts are there and correct. It will take some time to sync to maven central repository. You can verify it at &lt;a href="https://repo.maven.apache.org/maven2/org/apache/dubbo">here&lt;/a>&lt;/p>
&lt;h2 id="faq">FAQ&lt;/h2>
&lt;h4 id="gpg-signing-failed-inappropriate-ioctl-for-device">gpg: signing failed: Inappropriate ioctl for device&lt;/h4>
&lt;p>If you&amp;rsquo;ve encoutered this error, try the following commands:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">export&lt;/span> GPG_TTY&lt;span style="color:#719e07">=$&lt;/span>(tty)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item><item><title>Blog: How to implement a fully asynchronous calls chain based on Dubbo</title><link>https://dubbo.apache.org/en/blog/2018/09/02/how-to-implement-a-fully-asynchronous-calls-chain-based-on-dubbo/</link><pubDate>Sun, 02 Sep 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/09/02/how-to-implement-a-fully-asynchronous-calls-chain-based-on-dubbo/</guid><description>
&lt;p>Implementing the full asynchronous programming based on Dubbo, which is a new feature introduced in version 2.7.0 after the enhancement of the existing asynchronous mode.This article first reviews the supported functions and existing problems of asynchronization in 2.6.x and earlier versions, and introduces the targeted enhancements based on CompletableFuture in version 2.7.0. Then, the use of enhanced asynchronous programming is elaborated through several examples. Finally, it summarizes the new problems brought by the introduction of asynchronous mode and corresponding solutions from Dubbo. By reading this article, it is easy to implement a fully asynchronous remote service call chain based on Dubbo 2.7.0+.&lt;/p>
&lt;h2 id="asynchronous-mode-before-version-26x">Asynchronous mode before version 2.6.x&lt;/h2>
&lt;p>Dubbo Provides some asynchronous programming capabilities in 2.6.x and earlier versions, including &lt;a href="https://dubbo.apache.org/en/docs/v2.7/user/examples/async-call/">Asynchronous Call&lt;/a>, &lt;a href="https://dubbo.apache.org/en/docs/v2.7/user/examples/callback-parameter/">Parameter Callback&lt;/a> and &lt;a href="https://dubbo.apache.org/en/docs/v2.7/user/examples/events-notify/">Event Notification&lt;/a> on Consumer side. There are some brief introductions to the usage and Demo in the above document links.&lt;/p>
&lt;p>But the current asynchronous method has the following problems:&lt;/p>
&lt;ul>
&lt;li>Methods to access Future object are not direct enough.&lt;/li>
&lt;li>Future interface cannot implement automatic callback. Customized ResponseFuture class could implement callback, however it only supports limited asynchronous scenes. For example, it does not support mutual coordination or combination between Future objects.&lt;/li>
&lt;li>Asynchronization on Provider side is not supported.&lt;/li>
&lt;/ul>
&lt;p>Take the asynchronous method of Consumer side as an example:&lt;/p>
&lt;ol>
&lt;li>Define a original synchronous interface and add the declaration to support asynchronous calls.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">FooService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">findFoo&lt;/span>(String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:reference&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;fooService&amp;#34;&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.foo.FooService&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:method&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;findFoo&amp;#34;&lt;/span> async=&lt;span style="color:#2aa198">&amp;#34;true&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/dubbo:reference&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="2">
&lt;li>Obtain Future object through RpcContext.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">// this call will return null immediately&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>fooService.findFoo(fooId);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">// Obtain the Future instance. When the result is returned, Future instance will be notified and the result will be set to Future instance.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Future&lt;span style="color:#719e07">&amp;lt;&lt;/span>Foo&lt;span style="color:#719e07">&amp;gt;&lt;/span> fooFuture &lt;span style="color:#719e07">=&lt;/span> RpcContext.getContext().getFuture();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>fooFuture.get();
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>or&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">// this call will return null immediately&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>fooService.findFoo(fooId);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">// get Dubbo&amp;#39;s built-in ResponseFuture, and set the callback&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ResponseFuture future &lt;span style="color:#719e07">=&lt;/span> ((FutureAdapter)RpcContext.getContext().getFuture()).getFuture();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>future.setCallback(&lt;span style="color:#719e07">new&lt;/span> ResponseCallback() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">done&lt;/span>(Object response) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.print(response);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">caught&lt;/span>(Throwable exception) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> exception.printStackTrace();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>});
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>From this simple example, we can see there are some inconveniences in use:&lt;/p>
&lt;ol>
&lt;li>The synchronization interface of findFoo cannot directly return a Future object representing the asynchronous result, which is further obtained through RpcContext.&lt;/li>
&lt;li>Future object can only be obtained from get method that will block until getting the result.&lt;/li>
&lt;li>Callback can be set by getting the built-in ResponseFuture interface. However, the API to obtain ResponseFuture is not convenient enough to support other asynchronous scenes except callback. For example, it does not support the scene where multiple Future objects work together.&lt;/li>
&lt;/ol>
&lt;h2 id="enhancement-based-on-completablefuture-in-version-270">Enhancement based on CompletableFuture in version 2.7.0&lt;/h2>
&lt;p>People who understand the evolution history of Future in Java should know that the Future used in Dubbo 2.6.x and earlier versions is introduced in Java 5, so there are some problems in function design.The CompletableFuture introduced in Java 8 further enriches the Future interface and solves these problems well.&lt;/p>
&lt;p>Support for Java 8 has been upgraded in Dubbo 2.7.0, and Dubbo has enhanced the current asynchronous functionality based on CompletableFuture.&lt;/p>
&lt;ol>
&lt;li>
&lt;p>Now it supports direct definition of service interfaces that return CompletableFuture. Through these interfaces, we can implement asynchronous programming on both Consumer side and Provider side more naturally.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">AsyncService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> CompletableFuture&lt;span style="color:#719e07">&amp;lt;&lt;/span>String&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">sayHello&lt;/span>(String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>If you don&amp;rsquo;t want to define the return value of the interface as a Future object, or if there is a defined synchronization interface, you can additionally define an asynchronous interface and provide a method to return a Future object.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">AsyncService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> CompletableFuture&lt;span style="color:#719e07">&amp;lt;&lt;/span>String&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">sayHello&lt;/span>(String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@AsyncFor&lt;/span>(AsyncService.class)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">GrettingServiceAsync&lt;/span> &lt;span style="color:#268bd2">extends&lt;/span> GreetingsService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> CompletableFuture&lt;span style="color:#719e07">&amp;lt;&lt;/span>String&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">sayHiAsync&lt;/span>(String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In this way, Provider can only implement the sayHi method. The Consumer can get a Future instance by directly calling sayHiAsync, and Dubbo framework will convert it to a call to the sayHi method on the Provider side automatically.&lt;/p>
&lt;p>Providing an asynchronous method definition for each synchronization method can be inconvenient. Further, using &lt;a href="https://github.com/dubbo/dubbo-async-processor">Annotation Processor implementation&lt;/a> in the Dubbo ecosystem can automatically generate asynchronous method definitions for us.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Similarly, if your original interface definition doesn&amp;rsquo;t return a Future object, the Provider side also provides a programming interface similar to the Async Servlet in Servlet 3.0 to support asynchronization : &lt;code>RpcContext.startAsync()&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">AsyncService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">AsyncServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> AsyncService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">final&lt;/span> AsyncContext asyncContext &lt;span style="color:#719e07">=&lt;/span> RpcContext.startAsync();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">new&lt;/span> Thread(() &lt;span style="color:#719e07">-&amp;gt;&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> asyncContext.write(&lt;span style="color:#2aa198">&amp;#34;Hello &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#34;, response from provider.&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }).start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>At the beginning of the method body, it starts asynchronization by running &lt;code>RpcContext.startAsync()&lt;/code> , and it starts a new thread to execute the business logic asynchronously. After the time-consuming operation is completed, the result is written back by &lt;code>asyncContext.write&lt;/code>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>RpcContext returns CompletableFuture directly.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>CompletableFuture&lt;span style="color:#719e07">&amp;lt;&lt;/span>String&lt;span style="color:#719e07">&amp;gt;&lt;/span> f &lt;span style="color:#719e07">=&lt;/span> RpcContext.getContext().getCompletableFuture();
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;/ol>
&lt;p>All of the above enhancements are based on the compatibility with existing asynchronous programming, so asynchronous programs written based on 2.6.x versions can be successfully compiled without any modification.&lt;/p>
&lt;p>Next, let&amp;rsquo;s illustrate how to implement a fully asynchronous Dubbo service call chain through a few examples.&lt;/p>
&lt;h2 id="example-1completablefuture-interface">example 1:CompletableFuture interface&lt;/h2>
&lt;p>CompletableFuture interface can be used both for a synchronous call and for an asynchronous call on Consumer or Provider side. This example implements asynchronous calls between Consumer and Provider sides. Code link &lt;a href="https://github.com/apache/dubbo-samples/tree/master/2-advanced/dubbo-samples-async/dubbo-samples-async-original-future">dubbo-samples-async-original-future&lt;/a>.&lt;/p>
&lt;ol>
&lt;li>
&lt;p>Interface definition&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">AsyncService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> CompletableFuture&lt;span style="color:#719e07">&amp;lt;&lt;/span>String&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">sayHello&lt;/span>(String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Note that the return type of this interface is &lt;code>CompletableFuture&amp;lt;String&amp;gt;&lt;/code>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Provider Side&lt;/p>
&lt;ul>
&lt;li>
&lt;p>Implementation&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">AsyncServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> AsyncService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> CompletableFuture&lt;span style="color:#719e07">&amp;lt;&lt;/span>String&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">sayHello&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> CompletableFuture.supplyAsync(() &lt;span style="color:#719e07">-&amp;gt;&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">try&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Thread.sleep(5000);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } &lt;span style="color:#719e07">catch&lt;/span> (InterruptedException e) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> e.printStackTrace();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;async response from provider.&amp;#34;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> });
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>We can see that the business code is switched to be executed in the new thread by supplyAsync, so the Provider side is asynchronous.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Config&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;bean&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;asyncService&amp;#34;&lt;/span> class=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.async.impl.AsyncServiceImpl&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:service&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.async.api.AsyncService&amp;#34;&lt;/span> ref=&lt;span style="color:#2aa198">&amp;#34;asyncService&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The Config is the same as the original interface.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>Consumer Side&lt;/p>
&lt;ul>
&lt;li>Config&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:reference&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;asyncService&amp;#34;&lt;/span> timeout=&lt;span style="color:#2aa198">&amp;#34;10000&amp;#34;&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.async.api.AsyncService&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The Config is the same as the original interface.&lt;/p>
&lt;ul>
&lt;li>Call remote service&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) &lt;span style="color:#268bd2">throws&lt;/span> Exception {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ClassPathXmlApplicationContext context &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ClassPathXmlApplicationContext(&lt;span style="color:#719e07">new&lt;/span> String&lt;span style="color:#719e07">[]&lt;/span>{&lt;span style="color:#2aa198">&amp;#34;META-INF/spring/async-consumer.xml&amp;#34;&lt;/span>});
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">final&lt;/span> AsyncService asyncService &lt;span style="color:#719e07">=&lt;/span> (AsyncService) context.getBean(&lt;span style="color:#2aa198">&amp;#34;asyncService&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> CompletableFuture&lt;span style="color:#719e07">&amp;lt;&lt;/span>String&lt;span style="color:#719e07">&amp;gt;&lt;/span> future &lt;span style="color:#719e07">=&lt;/span> asyncService.sayHello(&lt;span style="color:#2aa198">&amp;#34;async call request&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> future.whenComplete((v, t) &lt;span style="color:#719e07">-&amp;gt;&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (t &lt;span style="color:#719e07">!=&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> t.printStackTrace();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } &lt;span style="color:#719e07">else&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;Response: &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> v);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> });
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;Executed before response return.&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.in.read();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>CompletableFuture&amp;lt;String&amp;gt; future = asyncService.sayHello(&amp;quot;async call request&amp;quot;);&lt;/code>It is convenient to return the Future instance, which implements the asynchronous service call on the Consumer side.&lt;/p>
&lt;/li>
&lt;/ol>
&lt;h2 id="example-2synchronous-interface-uses-annotation-processor">Example 2:Synchronous interface uses Annotation Processor&lt;/h2>
&lt;p>This example demonstrates how to implement the Consumer-side asynchronous service call using the Annotation Processor based on the original synchronous interface. Code link &lt;a href="https://github.com/apache/dubbo-samples/tree/master/2-advanced/dubbo-samples-async/dubbo-samples-async-generated-future">dubbo-samples-async-generated-future&lt;/a>.&lt;/p>
&lt;ol>
&lt;li>
&lt;p>Interface definition&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@DubboAsync&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">GreetingsService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">sayHi&lt;/span>(String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This is a generic definition of the Dubbo service interface. Note that add the @DubboAsync annotation when using Annotation Processor.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>com.alibaba&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>dubbo-async-processer&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>1.0.0-SNAPSHOT&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;plugin&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.apache.maven.plugins&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>maven-compiler-plugin&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>3.7.0&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;configuration&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;source&amp;gt;&lt;/span>1.8&lt;span style="color:#268bd2">&amp;lt;/source&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;target&amp;gt;&lt;/span>1.8&lt;span style="color:#268bd2">&amp;lt;/target&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;annotationProcessorPaths&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;path&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>com.alibaba&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>dubbo-async-processer&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>1.0.0-SNAPSHOT&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/path&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/annotationProcessorPaths&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/configuration&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/plugin&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The above config is the Maven dependency that imports dubbo-async-processer processor. Developers who define interfaces (providing APIs) usually add the above dependencies to the project, so that when doing API packaging, the following interface definitions will be automatically generated in APIs:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">* Generated by dubbo-async-processer
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">*/&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> com.alibaba.dubbo.samples.api;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> java.util.concurrent.CompletableFuture;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@javax.annotation.Generated&lt;/span>(&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.async.processor.AsyncAnnotationProcessor&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@org.apache.dubbo.common.config.AsyncFor&lt;/span>(com.alibaba.dubbo.samples.api.GreetingsService.class)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">GreetingsServiceAsync&lt;/span> &lt;span style="color:#268bd2">extends&lt;/span> GreetingsService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>CompletableFuture&lt;span style="color:#719e07">&amp;lt;&lt;/span>java.lang.String&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">sayHiAsync&lt;/span>(java.lang.String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>Provider side&lt;/p>
&lt;ul>
&lt;li>Config&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;bean&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;greetingsService&amp;#34;&lt;/span> class=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.async.impl.GreetingsServiceImpl&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:service&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.api.GreetingsService&amp;#34;&lt;/span> ref=&lt;span style="color:#2aa198">&amp;#34;greetingsService&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>Service implementation&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">GreetingsServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> GreetingsService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">sayHi&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;hi, &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>Consumer side&lt;/p>
&lt;ul>
&lt;li>Config&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:reference&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;greetingsService&amp;#34;&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.api.GreetingsServiceAsync&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Note that the service interface uses &lt;strong>GreetingsServiceAsync&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Service call&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) &lt;span style="color:#268bd2">throws&lt;/span> Exception {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ClassPathXmlApplicationContext context &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ClassPathXmlApplicationContext(&lt;span style="color:#719e07">new&lt;/span> String&lt;span style="color:#719e07">[]&lt;/span>{&lt;span style="color:#2aa198">&amp;#34;META-INF/spring/async-consumer.xml&amp;#34;&lt;/span>});
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> GreetingsServiceAsync greetingsService &lt;span style="color:#719e07">=&lt;/span> (GreetingsServiceAsync) context.getBean(&lt;span style="color:#2aa198">&amp;#34;greetingsService&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> CompletableFuture&lt;span style="color:#719e07">&amp;lt;&lt;/span>String&lt;span style="color:#719e07">&amp;gt;&lt;/span> future &lt;span style="color:#719e07">=&lt;/span> greetingsService.sayHiAsync(&lt;span style="color:#2aa198">&amp;#34;async call reqeust&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;async call ret :&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> future.get());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.in.read();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In this way, we can use &lt;code>CompletableFuture&amp;lt;String&amp;gt; future = greetingsService.sayHiAsync(&amp;quot;async call reqeust&amp;quot;);&lt;/code> directly,and return CompletableFuture.&lt;/p>
&lt;/li>
&lt;/ol>
&lt;h2 id="example-3use-asynccontext">Example 3:Use AsyncContext&lt;/h2>
&lt;p>This example demonstrates how to implement the Provider-side asynchronous execution through AsyncContext based on the original synchronous interface. Code link &lt;a href="https://github.com/apache/dubbo-samples/tree/master/2-advanced/dubbo-samples-async/dubbo-samples-async-provider">dubbo-samples-async-provider&lt;/a>.&lt;/p>
&lt;ol>
&lt;li>
&lt;p>Interface definition&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">AsyncService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>Provider side&lt;/p>
&lt;ul>
&lt;li>Config&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;bean&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;asyncService&amp;#34;&lt;/span> class=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.async.impl.AsyncServiceImpl&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:service&lt;/span> async=&lt;span style="color:#2aa198">&amp;#34;true&amp;#34;&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.async.api.AsyncService&amp;#34;&lt;/span> ref=&lt;span style="color:#2aa198">&amp;#34;asyncService&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Note that adding &lt;code>async=&amp;quot;true&amp;quot;&lt;/code> indicates that this is a service that starts the Provider-side execution asynchronously.&lt;/p>
&lt;ul>
&lt;li>Asynchronous execution implementation&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">AsyncServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> AsyncService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">final&lt;/span> AsyncContext asyncContext &lt;span style="color:#719e07">=&lt;/span> RpcContext.startAsync();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">new&lt;/span> Thread(() &lt;span style="color:#719e07">-&amp;gt;&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> asyncContext.signalContextSwitch();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">try&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Thread.sleep(500);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } &lt;span style="color:#719e07">catch&lt;/span> (InterruptedException e) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> e.printStackTrace();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> asyncContext.write(&lt;span style="color:#2aa198">&amp;#34;Hello &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#34;, response from provider.&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }).start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>Consumer side&lt;/p>
&lt;ul>
&lt;li>Config&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:reference&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;asyncService&amp;#34;&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.async.api.AsyncService&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>Service call&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) &lt;span style="color:#268bd2">throws&lt;/span> Exception {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ClassPathXmlApplicationContext context &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ClassPathXmlApplicationContext(&lt;span style="color:#719e07">new&lt;/span> String&lt;span style="color:#719e07">[]&lt;/span>{&lt;span style="color:#2aa198">&amp;#34;META-INF/spring/async-consumer.xml&amp;#34;&lt;/span>});
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> AsyncService asyncService &lt;span style="color:#719e07">=&lt;/span> (AsyncService) context.getBean(&lt;span style="color:#2aa198">&amp;#34;asyncService&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(asyncService.sayHello(&lt;span style="color:#2aa198">&amp;#34;async call request&amp;#34;&lt;/span>));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.in.read();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;/ol>
&lt;h2 id="new-problems-resulted-from-asynchronization">New problems resulted from asynchronization&lt;/h2>
&lt;h3 id="filter-chain">Filter Chain&lt;/h3>
&lt;p>The following is a complete Filter chain for a normal Dubbo call.&lt;/p>
&lt;p>After using the asynchronous call, since the asynchronous result is executed separately in the asynchronous thread, the Result passed through the second half of the Filter chain is null, and the real result cannot be processed by the Filter chain when it is returned.&lt;/p>
&lt;p>In order to solve this problem, PostProcessFilter and AbstractPostProcessFilter were introduced in Dubbo 2.7.0. The PostProcessFilter interface extends from the Filter interface, and AbstractPostProcessFilter is an abstract implementation of PostProcessFilter.&lt;/p>
&lt;p>The following is an example of extending the Filter and supporting the asynchronous Filter chain.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Activate&lt;/span>(group &lt;span style="color:#719e07">=&lt;/span> {Constants.PROVIDER, Constants.CONSUMER})
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">AsyncPostprocessFilter&lt;/span> &lt;span style="color:#268bd2">extends&lt;/span> AbstractPostProcessFilter {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> Result &lt;span style="color:#268bd2">invoke&lt;/span>(Invoker&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&lt;/span> invoker, Invocation invocation) &lt;span style="color:#268bd2">throws&lt;/span> RpcException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> postProcessResult(invoker.invoke(invocation), invoker, invocation);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">protected&lt;/span> Result &lt;span style="color:#268bd2">doPostProcess&lt;/span>(Result result, Invoker&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&lt;/span> invoker, Invocation invocation) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;Filter get the return value: &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> result.getValue());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> result;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="context-passing">Context passing&lt;/h3>
&lt;p>Currently, the context we are considering mainly refers to the data stored in the RpcContext. In most scenarios, the user needs to complete the passing of the Context before switching the service thread.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">AsyncServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> AsyncService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// Save the context of the current thread&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> RpcContext context &lt;span style="color:#719e07">=&lt;/span> RpcContext.getContext();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> CompletableFuture&lt;span style="color:#719e07">&amp;lt;&lt;/span>String&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">sayHello&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> CompletableFuture.supplyAsync(() &lt;span style="color:#719e07">-&amp;gt;&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// Set context into new thread&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> RpcContext.setContext(context);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">try&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Thread.sleep(5000);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } &lt;span style="color:#719e07">catch&lt;/span> (InterruptedException e) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> e.printStackTrace();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;async response from provider.&amp;#34;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> });
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>However, AsyncContext also provides the signalContextSwitch() method for a convenient Context switch.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">AsyncServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> AsyncService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">final&lt;/span> AsyncContext asyncContext &lt;span style="color:#719e07">=&lt;/span> RpcContext.startAsync();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">new&lt;/span> Thread(() &lt;span style="color:#719e07">-&amp;gt;&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> asyncContext.signalContextSwitch();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">try&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Thread.sleep(500);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } &lt;span style="color:#719e07">catch&lt;/span> (InterruptedException e) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> e.printStackTrace();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> asyncContext.write(&lt;span style="color:#2aa198">&amp;#34;Hello &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#34;, response from provider.&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }).start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item><item><title>Blog: The fourth Dubbo meetup has been held in Chengdu</title><link>https://dubbo.apache.org/en/blog/2018/08/26/the-fourth-dubbo-meetup-has-been-held-in-chengdu/</link><pubDate>Sun, 26 Aug 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/08/26/the-fourth-dubbo-meetup-has-been-held-in-chengdu/</guid><description>
&lt;h1 id="the-fourth-dubbo-meetup-has-been-held-in-chengdu">The fourth Dubbo meetup has been held in Chengdu&lt;/h1>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/meetup-chengdu/all-hands.webp" alt="img">&lt;/p>
&lt;h2 id="the-depth-of-the-user-communication">The depth of the user communication&lt;/h2>
&lt;p>On August 26, 10:00 am - 12:00am, invited the arrival of the car to help, cloud gold, former BBD, flying fish star four companies open source enthusiasts and heavy users participate in face-to-face communication;According to the participants&amp;rsquo; feedback, answer to Dubbo many doubt, especially how to participate in the contribution to the community, as well as code contribution value point.Hope later can be more deeply involved in Dubbo communities and activities.&lt;/p>
&lt;h2 id="meetup-activity-information">Meetup activity information&lt;/h2>
&lt;p>The event is still full, total enrollment of 976, 350 + site users, live PV 13207.&lt;/p>
&lt;h2 id="the-registration-information">The registration information&lt;/h2>
&lt;p>Aliware Open Source, headquarters - Apache Dubbo developers salon on August 26 (Sunday) in chengdu high-tech zone tianfu hemicyenine rong international plaza, 200 five street on the 8th floor held the second floor conference room, technical thinking is GG feast, dry goods and welfare will not one less.&lt;/br>
Sign up link:http://www.huodongxing.com/event/7453091088400&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-chengdu-meetup-img.jpg" alt="img">&lt;/p></description></item><item><title>Blog: Dubbo Basic Usage - Dubbo Consumer Configuration</title><link>https://dubbo.apache.org/en/blog/2018/08/14/dubbo-basic-usage-dubbo-consumer-configuration/</link><pubDate>Tue, 14 Aug 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/08/14/dubbo-basic-usage-dubbo-consumer-configuration/</guid><description>
&lt;h2 id="dubbo-consumer-configuration">Dubbo Consumer Configuration&lt;/h2>
&lt;h3 id="consumer-configuration-detailed">Consumer Configuration Detailed&lt;/h3>
&lt;p>There are 3 ways to configure the Dubbo Consumer: XML configuration, API call mode configuration, and annotation mode configuration.&lt;/p>
&lt;h4 id="xml-configuration">XML Configuration&lt;/h4>
&lt;h6 id="example-of-the-simplest-configuration">Example of the simplest configuration:&lt;/h6>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-8&amp;#34;?&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;beans xmlns=&amp;#34;http://www.springframework.org/schema/beans&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Xmlns:xsi=&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Xmlns:dubbo=&amp;#34;http://dubbo.apache.org/schema/dubbo&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Xsi:schemaLocation=&amp;#34;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&amp;#34;&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:application name=&amp;#34;hello-world-app&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:registry address=&amp;#34;multicast://224.5.6.7:1234&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:protocol name=&amp;#34;dubbo&amp;#34; port=&amp;#34;20880&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:reference id=&amp;#34;demoServiceRemote&amp;#34; interface=&amp;#34;com.alibaba.dubbo.demo.DemoService&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/beans&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;blockquote>
&lt;p>For the supported configuration tags and corresponding configuration items, refer to the usage in the provider.&lt;/p>
&lt;/blockquote>
&lt;blockquote>
&lt;p>Next, focus on the configuration of &amp;lt;dubbo:reference/&amp;gt;.&lt;/p>
&lt;/blockquote>
&lt;ul>
&lt;li>&amp;lt;dubbo:reference/&amp;gt; List of main attributes supported:&lt;/li>
&lt;/ul>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Property Name&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>id&lt;/td>
&lt;td>service reference id, as java bean id, requires unique&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Interface&lt;/td>
&lt;td>interface name for finding services&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>version&lt;/td>
&lt;td>version number, consistent with the service provider&amp;rsquo;s version&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>timeout&lt;/td>
&lt;td>service method call timeout (ms)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>retries&lt;/td>
&lt;td>The number of retry attempts by the remote service, excluding the first call, no need to retry, please set to 0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Connections&lt;/td>
&lt;td>For each provider&amp;rsquo;s maximum number of connections, rmi, http, hessian, etc. The short connection protocol indicates the number of restricted connections, and the dubbo equal-length connection association indicates the number of long connections established&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Loadbalance&lt;/td>
&lt;td>Load balancing policy, optional values: random, roundrobin, leastactive, respectively: random, polling, least active call&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>async&lt;/td>
&lt;td>Whether to execute asynchronously, unreliable asynchronous, just ignore return value, do not block execution thread&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>generic&lt;/td>
&lt;td>generalized call, can bypass&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>check&lt;/td>
&lt;td>Check if the provider exists at startup, true error, false ignore&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Actives&lt;/td>
&lt;td>Maximum concurrent calls per method per service consumer&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>For other configuration properties, please refer to xsd: &lt;a href="http://dubbo.apache.org/schema/dubbo/dubbo.xsd">http://dubbo.apache.org/schema/dubbo/dubbo.xsd&lt;/a>&lt;/p>
&lt;ul>
&lt;li>&amp;lt;dubbo:method/&amp;gt; As a child of &amp;lt;dubbo:reference/&amp;gt;, it can be configured for methods. The more commonly used attributes are:&lt;/li>
&lt;/ul>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Property Name&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>executes&lt;/td>
&lt;td>request ceiling for service execution&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>retries&lt;/td>
&lt;td>Timeout retries&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>timeout&lt;/td>
&lt;td>call timeout&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Loadbalance&lt;/td>
&lt;td>Load balancing policy, optional values: random, roundrobin, leastactive, respectively: random, polling, least active call&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>async&lt;/td>
&lt;td>Whether to execute asynchronously, unreliable asynchronous, just ignore return value, do not block execution thread&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Actives&lt;/td>
&lt;td>Maximum concurrent call limit per service consumer&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>For other properties, you can refer to xsd above.&lt;/p>
&lt;h6 id="configured-coverage-relationship">Configured coverage relationship&lt;/h6>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/user/dubbo-config-override.jpg" alt="undefined">&lt;/p>
&lt;p>Coverage diagram for configuration&lt;/p>
&lt;p>It contains the configuration of the consumer side and the provider, pay attention to the distinction.&lt;/p>
&lt;h4 id="annotation">annotation&lt;/h4>
&lt;h6 id="reference-annotation-remote-service">Reference Annotation Remote Service&lt;/h6>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Public class AnnotationConsumeService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> @com.alibaba.dubbo.config.annotation.Reference
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Public AnnotateService annotateService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> // ...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The configuration in this way is the same as the previous configuration in xml.&lt;/p>
&lt;blockquote>
&lt;p>To specify the way dubbo scans the path, refer to the implementation of the provider in the previous section.&lt;/p>
&lt;/blockquote>
&lt;h4 id="api-direct-trigger">api direct trigger&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>Import com.alibaba.dubbo.rpc.config.ApplicationConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Import com.alibaba.dubbo.rpc.config.RegistryConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Import com.alibaba.dubbo.rpc.config.ConsumerConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Import com.alibaba.dubbo.rpc.config.ReferenceConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Import com.xxx.XxxService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// current application configuration
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ApplicationConfig application = new ApplicationConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>application.setName(&amp;#34;yyy&amp;#34;);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// Connect to the registry configuration
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>RegistryConfig registry = new RegistryConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>registry.setAddress(&amp;#34;10.20.130.230:9090&amp;#34;);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>registry.setUsername(&amp;#34;aaa&amp;#34;);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>registry.setPassword(&amp;#34;bbb&amp;#34;);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// Note: ReferenceConfig is a heavy object that internally encapsulates the connection to the registry and the connection to the service provider.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// reference remote service
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ReferenceConfig&amp;lt;XxxService&amp;gt; reference = new ReferenceConfig&amp;lt;XxxService&amp;gt;(); // This instance is heavy, encapsulates the connection to the registry and the connection to the provider, please cache it yourself, otherwise it may cause memory and connection leaks.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>reference.setApplication(application);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>reference.setRegistry(registry); // Multiple registries can use setRegistries()
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>reference.setInterface(XxxService.class);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>reference.setVersion(&amp;#34;1.0.0&amp;#34;);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// Use xxxService like local beans
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>XxxService xxxService = reference.get();
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h6 id="methodspecial-settings">methodSpecial settings&lt;/h6>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// Method level configuration
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>List&amp;lt;MethodConfig&amp;gt; methods = new ArrayList&amp;lt;MethodConfig&amp;gt;();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>MethodConfig method = new MethodConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>method.setName(&amp;#34;createXxx&amp;#34;);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>method.setTimeout(10000);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>method.setRetries(0);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Methods.add(method);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// reference remote service
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ReferenceConfig&amp;lt;XxxService&amp;gt; reference = new ReferenceConfig&amp;lt;XxxService&amp;gt;(); // This instance is heavy, encapsulates the connection to the registry and the connection to the provider, please cache it yourself, otherwise it may cause memory and connection leaks.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>reference.setMethods(methods); // Set method level configuration
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="consumer-calling-remote-service">Consumer Calling Remote Service&lt;/h3>
&lt;p>The above chapters are more from a configuration point of view, and then through a complete example, explain the complete use of dubbo consumer.&lt;/p>
&lt;p>There is only one service UserReadService in this example, there is a method getUserById. Need to call a remote service through Dubbo. The specific steps are as follows:&lt;/p>
&lt;ol>
&lt;li>Create a project
If there is already a project, you can ignore it. Create a spring boot project that can be created at &lt;a href="https://start.spring.io/">https://start.spring.io/&lt;/a>.
The provider of the service has been defined in the provider section.&lt;/li>
&lt;li>Call the service&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>@RestController
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Public class UserTestController{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> @Autowired
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Private UserReadService userReadService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> @RequestMapping(&amp;#34;/user/getById&amp;#34;)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Public String getUserById(Long id){
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> // just test
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Return userReadService.getUserById(id).toString();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>3.Dubbo configuration&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-8&amp;#34;?&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;beans xmlns=&amp;#34;http://www.springframework.org/schema/beans&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Xmlns:xsi=&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Xmlns:dubbo=&amp;#34;http://dubbo.apache.org/schema/dubbo&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Xsi:schemaLocation=&amp;#34;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&amp;#34;&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:application name=&amp;#34;hello-world-app&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:registry address=&amp;#34;multicast://224.5.6.7:1234&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:protocol name=&amp;#34;dubbo&amp;#34; port=&amp;#34;20880&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:reference id=&amp;#34;userReadService&amp;#34; interface=&amp;#34;com.package.UserReadService&amp;#34;check=&amp;#34;false&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/beans&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Other ways of configuring Dubbo can refer to the relevant configuration in the previous section, or use the integrated dubbo spring boot starter mode.&lt;/p></description></item><item><title>Blog: Dubbo: Several ways about synchronous/asynchronous invoke</title><link>https://dubbo.apache.org/en/blog/2018/08/14/dubbo-several-ways-about-synchronous/asynchronous-invoke/</link><pubDate>Tue, 14 Aug 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/08/14/dubbo-several-ways-about-synchronous/asynchronous-invoke/</guid><description>
&lt;p>As we all know,Dubbo adopts a single large join protocol by default and takes the NIO asynchronous communication mechanism of Netty as the low-level implementation. Based on this mechanism, Dubbo implements several invocation modes as follows:&lt;/p>
&lt;ul>
&lt;li>synchronous invoke&lt;/li>
&lt;li>asynchronous invoke&lt;/li>
&lt;li>parameters callback&lt;/li>
&lt;li>event notification&lt;/li>
&lt;/ul>
&lt;h3 id="synchronous-invoke">Synchronous invoke&lt;/h3>
&lt;p>Synchronous invoke is a kind of blocking invocation mode, that is the Consumer keeps blocking and waiting, until the Provider returns.&lt;/p>
&lt;p>Generally, a typical synchronous invocation process is as follows:&lt;/p>
&lt;ol>
&lt;li>Consumer service thread invokes the remote API and sends requests to the Provider. Meanwhile, the current service thread stays in blocking state;&lt;/li>
&lt;li>Provider process relative request after receiving it from Consumer. Then returns the results to Consumer;&lt;/li>
&lt;li>After Consumer receiving results, the current thread continues to execute.&lt;/li>
&lt;/ol>
&lt;p>Here are two problems:&lt;/p>
&lt;ol>
&lt;li>How does Consumer service thread turn into &lt;code>blocking&lt;/code> state?&lt;/li>
&lt;li>How does the service thread be awaked to execute after Consumer receiving results?&lt;/li>
&lt;/ol>
&lt;p>In fact, the low-level I/O operations of Dubbo are all asynchronous. The Consumer gets a Future object after invoking the Provider. For synchronous invoke, the service thread takes advantage of &lt;code>Future#get(timeout)&lt;/code> to block and wait for Provider returning results, with the &amp;rsquo;timeout&amp;rsquo; indicating the timeout defined by Consumer. When the result returns, the Future will be set and the blocked service thread will be awaked. The service thread will return an exception if there is no result after timeout.&lt;/p>
&lt;h3 id="asynchronous-invoke">Asynchronous invoke&lt;/h3>
&lt;p>For scenarios that Provider has a long response time, it&amp;rsquo;s necessary to implement asynchronous invoke based on Dubbo&amp;rsquo;s underlying asynchronous NIO. It could utilize the resource of Consumer effectively, and costs less than using multi-thread for Consumer.&lt;/p>
&lt;p>Asynchronous invoke does not need specific configuration for Provider. In the example,the API of Provider is defined as follow:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">AsyncService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">goodbye&lt;/span>(String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h5 id="consumer-configuration">Consumer configuration&lt;/h5>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:reference&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;asyncService&amp;#34;&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.async.api.AsyncService&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:method&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;goodbye&amp;#34;&lt;/span> async=&lt;span style="color:#2aa198">&amp;#34;true&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/dubbo:reference&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Notice that if we need an asynchronous revoke method, we must use &lt;code>&amp;lt;dubbo:method/&amp;gt;&lt;/code> label to describe it.&lt;/p>
&lt;h5 id="consumer-triggers-invocation">Consumer triggers invocation&lt;/h5>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>AsyncService service &lt;span style="color:#719e07">=&lt;/span> ...;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>String result &lt;span style="color:#719e07">=&lt;/span> service.goodbye(&lt;span style="color:#2aa198">&amp;#34;samples&amp;#34;&lt;/span>);&lt;span style="color:#586e75">// returns NULL and DO NOT use!&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Future&lt;span style="color:#719e07">&amp;lt;&lt;/span>String&lt;span style="color:#719e07">&amp;gt;&lt;/span> future &lt;span style="color:#719e07">=&lt;/span> RpcContext.getContext().getFuture();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>... &lt;span style="color:#586e75">// other service thread logic&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>result &lt;span style="color:#719e07">=&lt;/span> future.get(); &lt;span style="color:#586e75">// could use get(timeout, unit) to configure timeout, when it needs to get the asynchronous result&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>After Dubbo Consumer triggers invocation, it uses &lt;code>RpcContext.getContext().getFuture()&lt;/code> to get the relative &lt;code>Future&lt;/code> object, and then it could start executing other tasks. Anytime when we need results, &lt;code>future.get(timeout)&lt;/code> is supposed to be called.&lt;/p>
&lt;p>Under several special conditions, it could be set whether to wait for sending the request, to accelerate the return of invocation:&lt;/p>
&lt;ul>
&lt;li>&lt;code>sent=&amp;quot;true&amp;quot;&lt;/code> Waiting for sending the request, and return an exception if it fails;&lt;/li>
&lt;li>&lt;code>sent=&amp;quot;false&amp;quot;&lt;/code> Do not wait for the request, and returns immediately after putting the request to the I/O queue.&lt;/li>
&lt;/ul>
&lt;p>We set it to &lt;code>false&lt;/code> by default. And detailed configuration is as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:method&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;goodbye&amp;#34;&lt;/span> async=&lt;span style="color:#2aa198">&amp;#34;true&amp;#34;&lt;/span> sent=&lt;span style="color:#2aa198">&amp;#34;true&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>If you only want to be asynchronous, then omit the result thoroughly, &lt;code>return=&amp;quot;false&amp;quot;&lt;/code> could be set to reduce the creation and management cost of Future:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:method&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;goodbye&amp;#34;&lt;/span> async=&lt;span style="color:#2aa198">&amp;#34;true&amp;#34;&lt;/span> return=&lt;span style="color:#2aa198">&amp;#34;false&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>At this time,&lt;code>RpcContext.getContext().getFuture()&lt;/code> will return &lt;code>null&lt;/code>。&lt;/p>
&lt;p>The complete sequence diagram of asynchronous invoke is as follow:&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-async.svg" alt="Asynchronous invoke">&lt;/p>
&lt;p>The sample locates at:https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-async&lt;/p>
&lt;h3 id="parameters-callback">Parameters callback&lt;/h3>
&lt;p>The parameter Callback is somewhat similar to the local Callback mechanism, but Callback is not an inner class or interface of Dubbo. Instead, it is defined by the Provider. Dubbo will generate a reverse proxy based on the long connection, so as to implement the logic of calling the Consumer from the Provider.&lt;/p>
&lt;h5 id="service-and-callback-definition-of-provider">Service and Callback definition of Provider&lt;/h5>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">CallbackService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">addListener&lt;/span>(String key, CallbackListener listener);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">CallbackListener&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">changed&lt;/span>(String msg);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h5 id="service-implementation-of-provider">Service implementation of Provider&lt;/h5>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">CallbackServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> CallbackService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> &lt;span style="color:#268bd2">final&lt;/span> Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, CallbackListener&lt;span style="color:#719e07">&amp;gt;&lt;/span> listeners &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ConcurrentHashMap&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, CallbackListener&lt;span style="color:#719e07">&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">CallbackServiceImpl&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Thread t &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> Thread(&lt;span style="color:#719e07">new&lt;/span> Runnable() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">run&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">while&lt;/span> (&lt;span style="color:#cb4b16">true&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">try&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (Map.Entry&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, CallbackListener&lt;span style="color:#719e07">&amp;gt;&lt;/span> entry : listeners.entrySet()) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">try&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> entry.getValue().changed(getChanged(entry.getKey()));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } &lt;span style="color:#719e07">catch&lt;/span> (Throwable t) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> listeners.remove(entry.getKey());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Thread.sleep(5000); &lt;span style="color:#586e75">// timely trigger change event&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } &lt;span style="color:#719e07">catch&lt;/span> (Throwable t) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> t.printStackTrace();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> });
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> t.setDaemon(&lt;span style="color:#cb4b16">true&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> t.start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">addListener&lt;/span>(String key, CallbackListener listener) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> listeners.put(key, listener);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> listener.changed(getChanged(key)); &lt;span style="color:#586e75">// send notification for change&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> String &lt;span style="color:#268bd2">getChanged&lt;/span>(String key) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;Changed: &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#719e07">new&lt;/span> SimpleDateFormat(&lt;span style="color:#2aa198">&amp;#34;yyyy-MM-dd HH:mm:ss&amp;#34;&lt;/span>).format(&lt;span style="color:#719e07">new&lt;/span> Date());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h5 id="service-exposure-of-provider">Service exposure of Provider&lt;/h5>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;bean&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;callbackService&amp;#34;&lt;/span> class=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.callback.impl.CallbackServiceImpl&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:service&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.callback.api.CallbackService&amp;#34;&lt;/span> ref=&lt;span style="color:#2aa198">&amp;#34;callbackService&amp;#34;&lt;/span> connections=&lt;span style="color:#2aa198">&amp;#34;1&amp;#34;&lt;/span> callbacks=&lt;span style="color:#2aa198">&amp;#34;1000&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:method&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;addListener&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:argument&lt;/span> index=&lt;span style="color:#2aa198">&amp;#34;1&amp;#34;&lt;/span> callback=&lt;span style="color:#2aa198">&amp;#34;true&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!--&amp;lt;dubbo:argument type=&amp;#34;com.demo.CallbackListener&amp;#34; callback=&amp;#34;true&amp;#34; /&amp;gt;--&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dubbo:method&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/dubbo:service&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Here,Provider needs to declare which parameter is the Callback parameter in the method.&lt;/p>
&lt;h5 id="callback-interface-implementation-of-consumer">Callback interface implementation of Consumer&lt;/h5>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>CallbackService callbackService &lt;span style="color:#719e07">=&lt;/span> ...;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>callbackService.addListener(&lt;span style="color:#2aa198">&amp;#34;foo.bar&amp;#34;&lt;/span>, &lt;span style="color:#719e07">new&lt;/span> CallbackListener() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">changed&lt;/span>(String msg) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;callback1:&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> msg);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>});
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The implementation class of the Callback interface is on the Consumer, which automatically exports a Callback service when the method is called. Thus during Provider processing the call, if the parameter is determined as Callback, it will generate a proxy. Therefore, when the service implementation class calling the Callback method, it will be passed to the Consumer to execute the code.&lt;/p>
&lt;p>The sample code above is located at:https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-callback&lt;/p>
&lt;p>This invocation mode is somewhat like message publishing and subscribing, but there is a little difference. For example, when the Consumer completes the export of Callback service, if it restarts later, then the Provider will fail to adjust. Meanwhile it is also a problem for the Provider to clean up the proxy.&lt;/p>
&lt;h3 id="event-notification">Event notification&lt;/h3>
&lt;p>Event notification allows the Consumer triggering three events,particularly &lt;code>oninvoke&lt;/code>, &lt;code>onreturn&lt;/code>, &lt;code>onthrow&lt;/code> before calling, after calling or occurring exceptions.&lt;/p>
&lt;p>You can specify which events need to be notified during configuring Consumer, such as:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;bean&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;demoCallback&amp;#34;&lt;/span> class=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.notify.impl.NotifyImpl&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:reference&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;demoService&amp;#34;&lt;/span> check=&lt;span style="color:#2aa198">&amp;#34;false&amp;#34;&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.notify.api.DemoService&amp;#34;&lt;/span> version=&lt;span style="color:#2aa198">&amp;#34;1.0.0&amp;#34;&lt;/span> group=&lt;span style="color:#2aa198">&amp;#34;cn&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:method&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;sayHello&amp;#34;&lt;/span> onreturn=&lt;span style="color:#2aa198">&amp;#34;demoCallback.onreturn&amp;#34;&lt;/span> onthrow=&lt;span style="color:#2aa198">&amp;#34;demoCallback.onthrow&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/dubbo:reference&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Among them,the code of NotifyImpl is as follow:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">NotifyImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> Notify{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>Integer, String&lt;span style="color:#719e07">&amp;gt;&lt;/span> ret &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> HashMap&lt;span style="color:#719e07">&amp;lt;&lt;/span>Integer, String&lt;span style="color:#719e07">&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">onreturn&lt;/span>(String name, &lt;span style="color:#dc322f">int&lt;/span> id) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ret.put(id, name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;onreturn: &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">onthrow&lt;/span>(Throwable ex, String name, &lt;span style="color:#dc322f">int&lt;/span> id) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;onthrow: &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Here we address that the parameter rules of three methods in the custom Notify interface are as follows:&lt;/p>
&lt;ul>
&lt;li>&lt;code>oninvoke&lt;/code> method&amp;rsquo;s parameters are the same as the calling method parameters;&lt;/li>
&lt;li>&lt;code>onreturn&lt;/code> method&amp;rsquo;s first parameter is the returned value of calling method,and the others are the same as the calling method;&lt;/li>
&lt;li>&lt;code>onthrow&lt;/code> method&amp;rsquo;s first parameter is an invoked exception,and the others are the same as the calling method.&lt;/li>
&lt;/ul>
&lt;p>In the above configuration, &lt;code>sayHello&lt;/code> method is an asynchronous invocation, so the execution of event notification method is also synchronous. You can configure the &lt;code>async = true&lt;/code> to make method invocation asynchronous, at this moment, event notification method is executed asynchronously. Especially emphasize that &lt;code>oninvoke&lt;/code> method is executed synchronously, whether is an asynchronous call or not.&lt;/p>
&lt;p>Please refer to the sample code for event notification:https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-notify&lt;/p></description></item><item><title>Blog: Dubbo Basic Usage -- Dubbo Provider Configuration</title><link>https://dubbo.apache.org/en/blog/2018/08/14/dubbo-basic-usage--dubbo-provider-configuration/</link><pubDate>Tue, 14 Aug 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/08/14/dubbo-basic-usage--dubbo-provider-configuration/</guid><description>
&lt;p>This chapter mainly talking about how to configure dubbo. According to the configuration mode, it can be divided into the following mode: XML Configuration, Properties Configuration, Annotation Configuration, API Invocation Mode Configuration. And according to the function, we can divide them into Dubbo Provider and Dubbo Consumer. In the following sections, we would explain Dubbo Provider and Dubbo Consumer respectively.&lt;/p>
&lt;h2 id="dubbo-provider-configuration">Dubbo Provider Configuration&lt;/h2>
&lt;h3 id="provider-configuration-in-detail">Provider Configuration in Detail&lt;/h3>
&lt;p>The configuration mode of Dubbo Provider has 4 different ways: XML Configuration, Properties Configuration, API Invocation Mode Configuration and Annotation Configuration.&lt;/p>
&lt;h4 id="xml-configuration">XML Configuration&lt;/h4>
&lt;h6 id="the-simplest-configuration-example">The simplest configuration example:&lt;/h6>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-8&amp;#34;?&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;beans xmlns=&amp;#34;http://www.springframework.org/schema/beans&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:xsi=&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:dubbo=&amp;#34;http://dubbo.apache.org/schema/dubbo&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xsi:schemaLocation=&amp;#34;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&amp;#34;&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:application name=&amp;#34;hello-world-app&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:registry address=&amp;#34;multicast://224.5.6.7:1234&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:protocol name=&amp;#34;dubbo&amp;#34; port=&amp;#34;20880&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:service interface=&amp;#34;com.alibaba.dubbo.demo.DemoService&amp;#34; ref=&amp;#34;demoServiceLocal&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:reference id=&amp;#34;demoServiceRemote&amp;#34; interface=&amp;#34;com.alibaba.dubbo.demo.DemoService&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/beans&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In the example above,note the way to write dubbo schema:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>&amp;lt;beans xmlns:xsi=&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:dubbo=&amp;#34;http://code.alibabatech.com/schema/dubbo&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns=&amp;#34;http://www.springframework.org/schema/beans&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xsi:schemaLocation=&amp;#34;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd&amp;#34;&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h6 id="supported-configuration-tags">Supported Configuration Tags&lt;/h6>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Tags&lt;/th>
&lt;th>Application&lt;/th>
&lt;th style="text-align:left">Describe&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&amp;lt;dubbo:service/&amp;gt;&lt;/td>
&lt;td>Service Configuration&lt;/td>
&lt;td style="text-align:left">Expose a service, define the meta information of the service. One service can use multiple protocols to expose and can be registered to multiple registry centers&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;lt;dubbo:reference/&amp;gt;&lt;/td>
&lt;td>Reference Configuration&lt;/td>
&lt;td style="text-align:left">Create a remote service agent, one reference can point to multiple registry centers&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;lt;dubbo:protocol/&amp;gt;&lt;/td>
&lt;td>Protocol Configuration&lt;/td>
&lt;td style="text-align:left">Configure protocol information for providing services, protocol is specified by the provider and accepted passively by the consumer&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;lt;dubbo:application/&amp;gt;&lt;/td>
&lt;td>Application Configuration&lt;/td>
&lt;td style="text-align:left">Configure current application information, regardless of whether the application is provider or consumer&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;lt;dubbo:module/&amp;gt;&lt;/td>
&lt;td>Module Configuration&lt;/td>
&lt;td style="text-align:left">Configure current module information. Optional&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;lt;dubbo:registry/&amp;gt;&lt;/td>
&lt;td>Registry Center Configuration&lt;/td>
&lt;td style="text-align:left">Configure information related to connect registry centers&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;lt;dubbo:monitor/&amp;gt;&lt;/td>
&lt;td>Monitoring Center Configuration&lt;/td>
&lt;td style="text-align:left">Configure information related to connect monitor centers. Optional&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;lt;dubbo:provider/&amp;gt;&lt;/td>
&lt;td>Provider Configuration&lt;/td>
&lt;td style="text-align:left">When some properties ProtocolConfig or ServiceConfig are not configured, use this default value. Optional&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;lt;dubbo:consumer/&amp;gt;&lt;/td>
&lt;td>Consumer Configuration&lt;/td>
&lt;td style="text-align:left">When some properties of ReferenceConfig are not configured, use this default value. Optional&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;lt;dubbo:method/&amp;gt;&lt;/td>
&lt;td>Method Configuration&lt;/td>
&lt;td style="text-align:left">Configure specific method level information of ServiceConfig and ReferenceConfig&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;lt;dubbo:argument/&amp;gt;&lt;/td>
&lt;td>Parameter Configuration&lt;/td>
&lt;td style="text-align:left">Configure parameters of specific method&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/user/dubbo-config.jpg" alt="undefined">&lt;/p>
&lt;p>Configuration Diagram&lt;/p>
&lt;h6 id="configuration-item-in-detail">Configuration item in detail&lt;/h6>
&lt;ul>
&lt;li>
&lt;p>&amp;lt;dubbo:application name=&amp;ldquo;hello-world-app&amp;rdquo; /&amp;gt;&lt;br>
Apply to specific application name, note that you need to make sure that the application name is unique. The application name can be displayed in the following console admin for easy management.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&amp;lt;dubbo:registry address=&amp;ldquo;multicast://224.5.6.7:1234&amp;rdquo; /&amp;gt;&lt;br>
Configure registry center, related to the specific mechanism of service discovery. It can be zookeeper address or eureka address. The address above is the broadcast address, which is very convenient in the test process of the local service invocation.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&amp;lt;dubbo:protocol name=&amp;ldquo;dubbo&amp;rdquo; port=&amp;ldquo;20880&amp;rdquo; /&amp;gt;&lt;br>
Here is the transport protocol and the default port, generally no changes are required.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;blockquote>
&lt;p>Next, we will focus on the configuration of &amp;lt;dubbo:service/&amp;gt;&lt;/p>
&lt;/blockquote>
&lt;ul>
&lt;li>&amp;lt;dubbo:service/&amp;gt;mainly supports the following properties:&lt;/li>
&lt;/ul>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Properties Name&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>version&lt;/td>
&lt;td>Version number&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>scope&lt;/td>
&lt;td>Service visibility, value can be local or remote,remote by default&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>actives&lt;/td>
&lt;td>Maximum number of activated requests&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>async&lt;/td>
&lt;td>Whether the method called asynchronously,false by default&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>cache&lt;/td>
&lt;td>Service cache,optional value:lru/threadlocal/jcache&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>callbacks&lt;/td>
&lt;td>Limitation of callback instance&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>generic&lt;/td>
&lt;td>Generalized calls which can be bypassed&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>class&lt;/td>
&lt;td>The implementation of the service&amp;rsquo;s class name&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>connections&lt;/td>
&lt;td>The number of connections in the service&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>delay&lt;/td>
&lt;td>The number of milliseconds delay for publicating the service&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>executes&lt;/td>
&lt;td>Upper bound of service execution requests&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>retries&lt;/td>
&lt;td>Timeout retry times&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>timeout&lt;/td>
&lt;td>Invocation timeout time&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>For other configuration properties, please refer to xsd:http://dubbo.apache.org/schema/dubbo/dubbo.xsd&lt;/p>
&lt;ul>
&lt;li>&amp;lt;dubbo:method/&amp;gt; as the sub-element of &amp;lt;dubbo:service/&amp;gt; can be configured corresponding to method. Properties that are commonly used are:&lt;/li>
&lt;/ul>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Properties Name&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>executes&lt;/td>
&lt;td>Upper bound of service execution requests&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>retries&lt;/td>
&lt;td>Timeout retry times&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>timeout&lt;/td>
&lt;td>Invocation timeout time&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>For other properties,you can refer to xsd above。&lt;/p>
&lt;h6 id="configuration-override-relationship">Configuration Override Relationship&lt;/h6>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/user/dubbo-config-override.jpg" alt="undefined">&lt;/p>
&lt;p>Configuration Coverage Relationship Diagram&lt;/p>
&lt;p>The Override relationship here includes the configuration of both provider end and consumer end. If you have any questions about consumer, you can refer to the next chapter, consumer chapter, to understand.&lt;/p>
&lt;h4 id="dubboproperties-configuration">dubbo.properties Configuration&lt;/h4>
&lt;blockquote>
&lt;p>If the public configuration is very simple, no multiple registry centers, no multiple protocols, etc., or if you want multiple Spring containers to share the configuration, you can use dubbo.properties as the default configurations.&lt;/p>
&lt;/blockquote>
&lt;p>Dubbo would load dubbo.properties under the classpath root directory automaticaly,you can change the default configuration location by JVM startup parameter -Ddubbo.properties.file=xxx.properties.&lt;/p>
&lt;h6 id="dubboproperties-configuration-example">dubbo.properties Configuration example&lt;/h6>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span># application name
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.application.name=dubbodemo-provider
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span># registry center address
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.registry.address=zookeeper://localhost:2181
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span># Example of broadcasting registry center
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>#dubbo.registry.address=multicast://224.5.6.7:1234
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span># address for calling protocol
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.protocol.name=dubbo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.protocol.port=28080
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h6 id="mapping-rule">Mapping Rule&lt;/h6>
&lt;p>Split the tag name and properties in XML configuration with dots, and multiple properties should be split into multiple lines&lt;/p>
&lt;ul>
&lt;li>For example: dubbo.application.name=foo equivalents to &amp;lt;dubbo:application name=&amp;ldquo;foo&amp;rdquo; /&amp;gt;&lt;/li>
&lt;li>For example: dubbo.registry.address=10.20.153.10:9090 equivalents to &amp;lt;dubbo:registry address=&amp;ldquo;10.20.153.10:9090&amp;rdquo; /&amp;gt;&lt;/li>
&lt;/ul>
&lt;p>If there are multiple configurations having the same tag name, they can be distinguished by id, and if there is no id, the configurations will be applied to all tags with the same name.&lt;/p>
&lt;ul>
&lt;li>For example: dubbo.protocol.rmi.port=1234 equivalents to &amp;lt;dubbo:protocol id=&amp;ldquo;rmi&amp;rdquo; name=&amp;ldquo;rmi&amp;rdquo; port=&amp;ldquo;1234&amp;rdquo; /&amp;gt;&lt;/li>
&lt;li>For example: dubbo.registry.china.address=10.20.153.10:9090 equivalents to &amp;lt;dubbo:registry id=&amp;ldquo;china&amp;rdquo; address=&amp;ldquo;10.20.153.10:9090&amp;rdquo; /&amp;gt;&lt;/li>
&lt;/ul>
&lt;h6 id="coverage-strategy">Coverage Strategy&lt;/h6>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/user/dubbo-config.jpg" alt="undefined">&lt;/p>
&lt;ul>
&lt;li>When JVM starts, -D parameter has priority, so that users can rewrite the parameters when deploy and start, for example, the protocol port should be changed when start.&lt;/li>
&lt;li>Then comes to XML, the configurations in dubbo.properties are invalid, if they are configured in XML.&lt;/li>
&lt;li>Properties are the last, which can be considered as default value. Only when there is no configuration in XML, the corresponding configuarations in dubbo.properties will become effective, which usually applies to shared public configuration, like application name.&lt;/li>
&lt;/ul>
&lt;blockquote>
&lt;p>Note:&lt;/p>
&lt;/blockquote>
&lt;ol>
&lt;li>If there are multiple dubbo.properties in the classpath root directory, for example, if dubbo.properties exist in multiple JAR files, Dubbo will load anyone arbitrarily and print the Error logs, which may change to throwing exceptions later.↩&lt;/li>
&lt;li>When the protocol&amp;rsquo;s id is not configured, protocol name will be used as id as default.&lt;/li>
&lt;/ol>
&lt;h4 id="annotation">Annotation&lt;/h4>
&lt;h6 id="service-annotation-exposure-service">Service Annotation Exposure Service&lt;/h6>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>import com.alibaba.dubbo.config.annotation.Service;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>@Service(timeout = 5000)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>public class AnnotateServiceImpl implements AnnotateService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> // ...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h6 id="javaconfig-configuration-public-module">Javaconfig Configuration Public Module&lt;/h6>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>@Configuration
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>public class DubboConfiguration {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> @Bean
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> public ApplicationConfig applicationConfig() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ApplicationConfig applicationConfig = new ApplicationConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> applicationConfig.setName(&amp;#34;provider-test&amp;#34;);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> return applicationConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> @Bean
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> public RegistryConfig registryConfig() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> RegistryConfig registryConfig = new RegistryConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> registryConfig.setAddress(&amp;#34;zookeeper://127.0.0.1:2181&amp;#34;);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> registryConfig.setClient(&amp;#34;curator&amp;#34;);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> return registryConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The result of configuration using this method is the same as that of using xml.&lt;/p>
&lt;h6 id="specify-the-dubbo-scan-path">Specify the Dubbo Scan Path&lt;/h6>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>@SpringBootApplication
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>@DubboComponentScan(basePackages = &amp;#34;com.alibaba.dubbo.test.service.impl&amp;#34;)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>public class ProviderTestApp {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> // ...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>or use the spring bean xml configuration:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>&amp;lt;dubbo:annotation package=&amp;#34;com.chanshuyi.service.impl&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="api-trigger-directly">API Trigger Directly&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span style="display:flex;">&lt;span>import com&lt;span style="color:#719e07">.&lt;/span>alibaba&lt;span style="color:#719e07">.&lt;/span>dubbo&lt;span style="color:#719e07">.&lt;/span>rpc&lt;span style="color:#719e07">.&lt;/span>config&lt;span style="color:#719e07">.&lt;/span>ApplicationConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>import com&lt;span style="color:#719e07">.&lt;/span>alibaba&lt;span style="color:#719e07">.&lt;/span>dubbo&lt;span style="color:#719e07">.&lt;/span>rpc&lt;span style="color:#719e07">.&lt;/span>config&lt;span style="color:#719e07">.&lt;/span>RegistryConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>import com&lt;span style="color:#719e07">.&lt;/span>alibaba&lt;span style="color:#719e07">.&lt;/span>dubbo&lt;span style="color:#719e07">.&lt;/span>rpc&lt;span style="color:#719e07">.&lt;/span>config&lt;span style="color:#719e07">.&lt;/span>ProviderConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>import com&lt;span style="color:#719e07">.&lt;/span>alibaba&lt;span style="color:#719e07">.&lt;/span>dubbo&lt;span style="color:#719e07">.&lt;/span>rpc&lt;span style="color:#719e07">.&lt;/span>config&lt;span style="color:#719e07">.&lt;/span>ServiceConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>import com&lt;span style="color:#719e07">.&lt;/span>xxx&lt;span style="color:#719e07">.&lt;/span>XxxService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>import com&lt;span style="color:#719e07">.&lt;/span>xxx&lt;span style="color:#719e07">.&lt;/span>XxxServiceImpl;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">//&lt;/span> Service implementation
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>XxxService xxxService &lt;span style="color:#719e07">=&lt;/span> new XxxServiceImpl();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">//&lt;/span> current application configuration
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ApplicationConfig application &lt;span style="color:#719e07">=&lt;/span> new ApplicationConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>application&lt;span style="color:#719e07">.&lt;/span>setName(&lt;span style="color:#2aa198">&amp;#34;xxx&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">//&lt;/span> connect to registry center configuration
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>RegistryConfig registry &lt;span style="color:#719e07">=&lt;/span> new RegistryConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>registry&lt;span style="color:#719e07">.&lt;/span>setAddress(&lt;span style="color:#2aa198">&amp;#34;10.20.130.230:9090&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>registry&lt;span style="color:#719e07">.&lt;/span>setUsername(&lt;span style="color:#2aa198">&amp;#34;aaa&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>registry&lt;span style="color:#719e07">.&lt;/span>setPassword(&lt;span style="color:#2aa198">&amp;#34;bbb&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">//&lt;/span> service provider&lt;span style="color:#2aa198">&amp;#39;s protocol configuration&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ProtocolConfig protocol &lt;span style="color:#719e07">=&lt;/span> new ProtocolConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>protocol&lt;span style="color:#719e07">.&lt;/span>setName(&lt;span style="color:#2aa198">&amp;#34;dubbo&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>protocol&lt;span style="color:#719e07">.&lt;/span>setPort(&lt;span style="color:#2aa198">12345&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>protocol&lt;span style="color:#719e07">.&lt;/span>setThreads(&lt;span style="color:#2aa198">200&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">//&lt;/span> Note: ServiceConfig is a heavy object, which encapsulated the connection with registry center internally, &lt;span style="color:#719e07">and&lt;/span> open the service port
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">//&lt;/span> Service provider exposes service configuration
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ServiceConfig&lt;span style="color:#719e07">&amp;lt;&lt;/span>XxxService&lt;span style="color:#719e07">&amp;gt;&lt;/span> service &lt;span style="color:#719e07">=&lt;/span> new ServiceConfig&lt;span style="color:#719e07">&amp;lt;&lt;/span>XxxService&lt;span style="color:#719e07">&amp;gt;&lt;/span>(); &lt;span style="color:#719e07">//&lt;/span> This instance is very heavy, which encapsulated the connection with registry center, please cache it by yourself, it might cause memory &lt;span style="color:#719e07">and&lt;/span> connection leakage otherwise&lt;span style="color:#719e07">.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service&lt;span style="color:#719e07">.&lt;/span>setApplication(application);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service&lt;span style="color:#719e07">.&lt;/span>setRegistry(registry); &lt;span style="color:#719e07">//&lt;/span> multiple registry centers can use setRegistries()
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service&lt;span style="color:#719e07">.&lt;/span>setProtocol(protocol); &lt;span style="color:#719e07">//&lt;/span> multiple protocols can use setProtocols()
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service&lt;span style="color:#719e07">.&lt;/span>setInterface(XxxService&lt;span style="color:#719e07">.&lt;/span>&lt;span style="color:#719e07">class&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service&lt;span style="color:#719e07">.&lt;/span>setRef(xxxService);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service&lt;span style="color:#719e07">.&lt;/span>setVersion(&lt;span style="color:#2aa198">&amp;#34;1.0.0&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">//&lt;/span> exposure &lt;span style="color:#719e07">and&lt;/span> register service
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service&lt;span style="color:#719e07">.&lt;/span>&lt;span style="color:#719e07">export&lt;/span>();
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Generally, this method is not recommended in spring applications. The reason can be checked by reading the source code on github, which would not be explained here.&lt;/p>
&lt;h3 id="provider-interface-and-implement">Provider Interface and Implement&lt;/h3>
&lt;p>The above chapters are described mainly from a configuration perspective, and lets explain the complete use of Dubbo provider by going through a complete example.&lt;/p>
&lt;p>There is only one service UserReadService, and one method getUserById in this example.
This service need to be exposed to a remote service by Dubbo. Detail steps are shown below:&lt;/p>
&lt;ol>
&lt;li>Create Project
Skip this step if there is already a project. Create a Spring Boot project, which can be created through &lt;a href="https://start.spring.io/">https://start.spring.io/&lt;/a>.&lt;/li>
&lt;li>Define Interface
Define interface: UserReadService&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>public interface UserReadService{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> public User getUserById(Long userId);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Generally, this interface should be placed in an independent JAR file as a client package.
Generally, the other services need to refer this client package if they want to consume this service(except for generalized call).
3. Implement Interface
Implement UserReadService, and deploy current implementation in the Provider&amp;rsquo;s application.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>public UserReadServiceImpl implements UserReadService{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> public User getUserById(Long userId){
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> return xxx;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="4">
&lt;li>Dubbo Configuration&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-8&amp;#34;?&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;beans xmlns=&amp;#34;http://www.springframework.org/schema/beans&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:xsi=&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:dubbo=&amp;#34;http://dubbo.apache.org/schema/dubbo&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xsi:schemaLocation=&amp;#34;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&amp;#34;&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:application name=&amp;#34;hello-world-app&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:registry address=&amp;#34;multicast://224.5.6.7:1234&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:protocol name=&amp;#34;dubbo&amp;#34; port=&amp;#34;20880&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;bean id=&amp;#34;userReadService&amp;#34; class=&amp;#34;com.package.UserReadServiceImpl&amp;#34;/&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;dubbo:service interface=&amp;#34;com.package.UserReadService&amp;#34; ref=&amp;#34;userReadService&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/beans&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>For the other modes of Dubbo configuration, please refer to the related configurations in the previous chapter, or use the integrated Dubbo Spring Boot starter method.&lt;/p></description></item><item><title>Blog: Manipulating Services Dynamically via QoS</title><link>https://dubbo.apache.org/en/blog/2018/08/14/manipulating-services-dynamically-via-qos/</link><pubDate>Tue, 14 Aug 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/08/14/manipulating-services-dynamically-via-qos/</guid><description>
&lt;h1 id="manipulating-services-dynamically-via-qos">Manipulating Services Dynamically via QoS&lt;/h1>
&lt;p>QoS (short form of &lt;strong>Quality of Service&lt;/strong>), is a common terminology talking about network devices. For example, by adjusting and manipulating the weights of ports of a router dynamically via QoS, engineers could give priority to services running on these ports and make sure these services&amp;rsquo; quality and reliability.&lt;/p>
&lt;p>In Dubbo, QoS is used to query and manipulate services dynamically, like getting a list of active provider and consumer services, and launching or withdrawing services (i.e registering to or unregistering services from registration center).&lt;/p>
&lt;h2 id="mechanism-of-qos">Mechanism of QoS&lt;/h2>
&lt;p>From 2.5.8, QoS is introduced into Dubbo and is activated by default. All QoS&amp;rsquo;s features are abstracted to commands, which could be executed to get responses from QoS.&lt;/p>
&lt;blockquote>
&lt;p>QoS is based on Netty4. In versions earlier than 2.6.x, Dubbo relies on Netty3, so you have to add Netty4 as a dependency explicitly to ensure that Netty4 works. If you generate a Dubbo application on &lt;a href="http://start.dubbo.io">http://start.dubbo.io&lt;/a>, there&amp;rsquo;s no need to add configurations because Netty4 is listed as a dependency by default.&lt;/p>
&lt;/blockquote>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/qos-architecture.png" alt="undefined">&lt;/p>
&lt;p>The picture above shows how QoS works:&lt;/p>
&lt;ol>
&lt;li>Start and listen to a port (22222 by default).&lt;/li>
&lt;li>Choose a corresponding request handler by detecting the protocol (telnet or http) a request comply with.&lt;/li>
&lt;li>Decode and parse the request to generate corresponding command according to the protocol.&lt;/li>
&lt;li>Execute commands and return with responses.&lt;/li>
&lt;/ol>
&lt;h3 id="qos-commands">QoS Commands:&lt;/h3>
&lt;p>Commands that QoS supports at the current moment include:&lt;/p>
&lt;ul>
&lt;li>&lt;code>help&lt;/code>, list available commands&lt;/li>
&lt;li>&lt;code>ls&lt;/code>: list all active provider services and consumer services&lt;/li>
&lt;li>&lt;code>online&lt;/code>: dynamically register a service or all services to registration center&lt;/li>
&lt;li>&lt;code>offline&lt;/code>: dynamically remove (unregister) a services or all services from registration center&lt;/li>
&lt;li>&lt;code>quit&lt;/code>: quit the current telnet session&lt;/li>
&lt;/ul>
&lt;p>Now we are going to demonstrate how to manipulate services dynamically via QoS.&lt;/p>
&lt;h4 id="access-qos-via-telnet">Access QoS via Telnet&lt;/h4>
&lt;p>Assuming that our Dubbo server has started, connect to it via telnet:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ telnet localhost &lt;span style="color:#2aa198">22222&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Trying 127.0.0.1...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Connected to localhost.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Escape character is &lt;span style="color:#2aa198">&amp;#39;^]&amp;#39;&lt;/span>.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ????????? ??? ?? ??????????? ??????????? ????????
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ??? ???? ??? ??? ??? ??? ??? ??? ??? ???
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ??? ??? ??? ??? ?????????? ?????????? ??? ???
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ??? ??? ??? ??? ??????????? ??????????? ??? ???
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ??? ???? ??? ??? ??? ??? ??? ??? ??? ???
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ????????? ????????? ??????????? ??????????? ????????
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>A &lt;code>dubbo&amp;gt;&lt;/code> prompt would show up once you connect to server. Now input &lt;code>help&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>dubbo&amp;gt;help
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+---------+----------------------------------------------------------------------------------+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>| &lt;span style="color:#b58900">help&lt;/span> | &lt;span style="color:#b58900">help&lt;/span> &lt;span style="color:#b58900">command&lt;/span> |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+---------+----------------------------------------------------------------------------------+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>| ls | ls service |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+---------+----------------------------------------------------------------------------------+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>| offline | offline dubbo |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+---------+----------------------------------------------------------------------------------+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>| online | online dubbo |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+---------+----------------------------------------------------------------------------------+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>| quit | quit telnet console |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+---------+----------------------------------------------------------------------------------+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This command lists all available commands with explanations.&lt;/p>
&lt;p>You can also use &lt;code>help&lt;/code> to a specific command to read examples of that command.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>dubbo&amp;gt;help online
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+--------------+----------------------------------------------------------------------------------+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>| COMMAND NAME | online |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+--------------+----------------------------------------------------------------------------------+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>| EXAMPLE | online dubbo |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>| | online xx.xx.xxx.service |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+--------------+----------------------------------------------------------------------------------+
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Use &lt;code>ls&lt;/code> to check services&amp;rsquo; status:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>dubbo&amp;gt;ls
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>As Provider side:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+------------------------------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>| Provider Service Name |PUB|
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+------------------------------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>|org.apache.dubbo.demo.provider.DemoService| Y |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+------------------------------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>As Consumer side:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+---------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>|Consumer Service Name|NUM|
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+---------------------+---+
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>There is a service named &lt;code>org.apache.dubbo.demo.provider.DemoService&lt;/code> in the provider side. &lt;code>PUB=Y&lt;/code> in the second columns means that the service has been published to the registration center, waiting to be called by the consumer side.&lt;/p>
&lt;p>Assuming that we need to withdraw a service dynamically, we can use &lt;code>offline&lt;/code> command:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>dubbo&amp;gt;offline org.apache.dubbo.demo.provider.DemoService
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>OK
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>You can see that the command responds with &lt;code>OK&lt;/code>. Check the services&amp;rsquo; status using &lt;code>ls&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>dubbo&amp;gt;ls
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>As Provider side:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+------------------------------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>| Provider Service Name |PUB|
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+------------------------------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>|org.apache.dubbo.demo.provider.DemoService| N |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+------------------------------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>As Consumer side:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+---------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>|Consumer Service Name|NUM|
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+---------------------+---+
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>You can see that &lt;code>PUB&lt;/code> of &lt;code>org.apache.dubbo.demo.provider.DemoService&lt;/code> has been set to &lt;code>N&lt;/code>.&lt;/p>
&lt;p>Quit the current telnet session using &lt;code>quit&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>dubbo&amp;gt;quit
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>BYE!
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Connection closed by foreign host.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="access-qos-via-http">Access QoS via HTTP&lt;/h4>
&lt;p>In the example above we performed an offline action to &lt;code>org.apache.dubbo.demo.provider.DemoService&lt;/code>. Now we are going to demonstrate how to register the service above via HTTP.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>$ curl -i http://localhost:22222/online?service&lt;span style="color:#719e07">=&lt;/span>org.apache.dubbo.demo.provider.DemoService
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>HTTP/1.1 &lt;span style="color:#2aa198">200&lt;/span> OK
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Content-Type: text/plain
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Content-Length: &lt;span style="color:#2aa198">2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>OK%
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;blockquote>
&lt;p>Beware of the parameters of online action. They need to be provided in the form of &lt;code>key=value&lt;/code>. However, &lt;code>key&lt;/code> would be ignored actually.&lt;/p>
&lt;/blockquote>
&lt;p>The action responds with &lt;code>OK&lt;/code>. Now use &lt;code>ls&lt;/code> to check providers&amp;rsquo; status at the current moment.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>$ curl -i http://localhost:22222/ls
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>HTTP/1.1 200 OK
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Content-Type: text/plain
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Content-Length: 365
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>As Provider side:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+------------------------------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>| Provider Service Name |PUB|
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+------------------------------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>|org.apache.dubbo.demo.provider.DemoService| Y |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+------------------------------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>As Consumer side:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+---------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>|Consumer Service Name|NUM|
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+---------------------+---+
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>You can see that the service&amp;rsquo;s &lt;code>PUB&lt;/code> status has been changed to &lt;code>Y&lt;/code>.&lt;/p>
&lt;h3 id="qos-parameters">QoS&amp;rsquo; Parameters&lt;/h3>
&lt;p>You can use parameters that QoS provides to config its startup. These parameters include:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Parameter&lt;/th>
&lt;th>Explanation&lt;/th>
&lt;th>Default&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>qosEnable&lt;/td>
&lt;td>Activate QoS or not&lt;/td>
&lt;td>true&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>qosPort&lt;/td>
&lt;td>The port QoS would bind to&lt;/td>
&lt;td>22222&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>qosAcceptForeignIp&lt;/td>
&lt;td>Enable remote access or not&lt;/td>
&lt;td>false&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;blockquote>
&lt;p>Attention. From 2.6.4/2.7.0, &lt;code>qosAcceptForeignIp&lt;/code> is set to &lt;code>false&lt;/code> by default, because it&amp;rsquo;s risky if this property is set to &lt;code>true&lt;/code>. Think twice before you turn it on.&lt;/p>
&lt;/blockquote>
&lt;p>You can configure these parameters in the following ways:&lt;/p>
&lt;ul>
&lt;li>System property&lt;/li>
&lt;li>&lt;code>dubbo.properties&lt;/code>&lt;/li>
&lt;li>XML&lt;/li>
&lt;li>Spring-boot auto configuration&lt;/li>
&lt;/ul>
&lt;p>They have priority in the following order: system property &amp;gt; &lt;code>dubbo.properties&lt;/code> &amp;gt; XML &amp;gt; spring-boot.&lt;/p>
&lt;h4 id="system-property">System Property&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>-Ddubbo.application.qos.enable=true
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>-Ddubbo.application.qos.port=33333
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>-Ddubbo.application.qos.accept.foreign.ip=false
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="dubboproperties">&lt;code>Dubbo.properties&lt;/code>&lt;/h4>
&lt;p>Create a &lt;code>dubbo.properties&lt;/code> file in this directory &lt;code>src/main/resources&lt;/code> in your project, and copy the following codes into it:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>dubbo.application.qos.enable=true
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.application.qos.port=33333
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.application.qos.accept.foreign.ip=false
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="xml">XML&lt;/h4>
&lt;p>If you are going to config using XML, you can try this:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-8&amp;#34;?&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;beans&lt;/span> xmlns=&lt;span style="color:#2aa198">&amp;#34;http://www.springframework.org/schema/beans&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:xsi=&lt;span style="color:#2aa198">&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:dubbo=&lt;span style="color:#2aa198">&amp;#34;http://dubbo.apache.org/schema/dubbo&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xsi:schemaLocation=&lt;span style="color:#2aa198">&amp;#34;http://www.springframework.org/schema/beans
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> http://www.springframework.org/schema/beans/spring-beans.xsd
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:application&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;demo-provider&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:parameter&lt;/span> key=&lt;span style="color:#2aa198">&amp;#34;qos.enable&amp;#34;&lt;/span> value=&lt;span style="color:#2aa198">&amp;#34;true&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:parameter&lt;/span> key=&lt;span style="color:#2aa198">&amp;#34;qos.accept.foreign.ip&amp;#34;&lt;/span> value=&lt;span style="color:#2aa198">&amp;#34;false&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:parameter&lt;/span> key=&lt;span style="color:#2aa198">&amp;#34;qos.port&amp;#34;&lt;/span> value=&lt;span style="color:#2aa198">&amp;#34;33333&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dubbo:application&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:registry&lt;/span> address=&lt;span style="color:#2aa198">&amp;#34;multicast://224.5.6.7:1234&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:protocol&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;dubbo&amp;#34;&lt;/span> port=&lt;span style="color:#2aa198">&amp;#34;20880&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:service&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;org.apache.dubbo.demo.provider.DemoService&amp;#34;&lt;/span> ref=&lt;span style="color:#2aa198">&amp;#34;demoService&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;bean&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;demoService&amp;#34;&lt;/span> class=&lt;span style="color:#2aa198">&amp;#34;org.apache.dubbo.demo.provider.DemoServiceImpl&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/beans&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="spring-boot-auto-configuration">&lt;code>spring-boot&lt;/code> auto configuration&lt;/h4>
&lt;p>If you are developing a spring-boot application, you can configure in &lt;code>application.properties&lt;/code> or &lt;code>application.yml&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>dubbo.application.qosEnable=true
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.application.qosPort=33333
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.application.qosAcceptForeignIp=false
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item><item><title>Blog: Source code analysis of spring-boot+Dubbo App start and stop</title><link>https://dubbo.apache.org/en/blog/2018/08/14/source-code-analysis-of-spring-boot-dubbo-app-start-and-stop/</link><pubDate>Tue, 14 Aug 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/08/14/source-code-analysis-of-spring-boot-dubbo-app-start-and-stop/</guid><description>
&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>&lt;a href="https://github.com/apache/dubbo-spring-boot-project">Dubbo Spring Boot&lt;/a> project is dedicated to simplifying the development of the Dubbo RPC framework in the Spring Boot application. It also integrates the feature of Spring Boot:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://github.com/apache/dubbo-spring-boot-project/blob/master/dubbo-spring-boot-autoconfigure">Autoconfigure&lt;/a> (ex: Annotation driver, Autoconfigure, etc.)&lt;/li>
&lt;li>&lt;a href="https://github.com/apache/dubbo-spring-boot-project/blob/master/dubbo-spring-boot-actuator">Production-Ready&lt;/a> (ex: Security, Healthy check, Externalize configuration, etc.)&lt;/li>
&lt;/ul>
&lt;h2 id="the-analysis-of-dubboconsumer-startup">The analysis of DubboConsumer startup&lt;/h2>
&lt;p>Have you ever thought about this : since the &lt;code>DubboConsumerDemo&lt;/code> application in &lt;code>dubbo-spring-boot-project&lt;/code> has only one line of code, why not just exit directly when the &lt;code>main&lt;/code> method is executed?&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@SpringBootApplication&lt;/span>(scanBasePackages &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;com.alibaba.boot.dubbo.demo.consumer.controller&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DubboConsumerDemo&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> SpringApplication.run(DubboConsumerDemo.class,args);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In fact, to answer this question, we need to abstract it first, that is, under what circumstances will a JVM process exit?&lt;/p>
&lt;p>Take Java 8 as an example. By referring to the JVM language specification[1], there is a clear description in Section 12.8:&lt;/p>
&lt;blockquote>
&lt;p>A program terminates all its activity and &lt;em>exits&lt;/em> when one of two things happens:&lt;/p>
&lt;ul>
&lt;li>All the threads that are not daemon threads terminate.&lt;/li>
&lt;li>Some thread invokes the &lt;code>exit&lt;/code> method of class &lt;code>Runtime&lt;/code> or class &lt;code>System&lt;/code>, and the &lt;code>exit&lt;/code> operation is not forbidden by the security manager.&lt;/li>
&lt;/ul>
&lt;/blockquote>
&lt;p>Therefore, in view of the above situation, we judge that there must be some non-daemon thread not exiting. All thread information can be seen by &lt;code>jstack&lt;/code>, including whether they are daemon threads, and &lt;code>jstack&lt;/code> can be used to find out which threads are non-daemon.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>➜ jstack &lt;span style="color:#2aa198">57785&lt;/span> | grep tid | grep -v &lt;span style="color:#2aa198">&amp;#34;daemon&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;container-0&amp;#34;&lt;/span> &lt;span style="color:#586e75">#37 prio=5 os_prio=31 tid=0x00007fbe312f5800 nid=0x7103 waiting on condition [0x0000700010144000]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;container-1&amp;#34;&lt;/span> &lt;span style="color:#586e75">#49 prio=5 os_prio=31 tid=0x00007fbe3117f800 nid=0x7b03 waiting on condition [0x0000700010859000]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;DestroyJavaVM&amp;#34;&lt;/span> &lt;span style="color:#586e75">#83 prio=5 os_prio=31 tid=0x00007fbe30011000 nid=0x2703 waiting on condition [0x0000000000000000]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;VM Thread&amp;#34;&lt;/span> &lt;span style="color:#268bd2">os_prio&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">31&lt;/span> &lt;span style="color:#268bd2">tid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x00007fbe3005e800 &lt;span style="color:#268bd2">nid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x3703 runnable
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;GC Thread#0&amp;#34;&lt;/span> &lt;span style="color:#268bd2">os_prio&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">31&lt;/span> &lt;span style="color:#268bd2">tid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x00007fbe30013800 &lt;span style="color:#268bd2">nid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x5403 runnable
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;GC Thread#1&amp;#34;&lt;/span> &lt;span style="color:#268bd2">os_prio&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">31&lt;/span> &lt;span style="color:#268bd2">tid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x00007fbe30021000 &lt;span style="color:#268bd2">nid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x5303 runnable
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;GC Thread#2&amp;#34;&lt;/span> &lt;span style="color:#268bd2">os_prio&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">31&lt;/span> &lt;span style="color:#268bd2">tid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x00007fbe30021800 &lt;span style="color:#268bd2">nid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x2d03 runnable
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;GC Thread#3&amp;#34;&lt;/span> &lt;span style="color:#268bd2">os_prio&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">31&lt;/span> &lt;span style="color:#268bd2">tid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x00007fbe30022000 &lt;span style="color:#268bd2">nid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x2f03 runnable
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;G1 Main Marker&amp;#34;&lt;/span> &lt;span style="color:#268bd2">os_prio&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">31&lt;/span> &lt;span style="color:#268bd2">tid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x00007fbe30040800 &lt;span style="color:#268bd2">nid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x5203 runnable
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;G1 Conc#0&amp;#34;&lt;/span> &lt;span style="color:#268bd2">os_prio&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">31&lt;/span> &lt;span style="color:#268bd2">tid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x00007fbe30041000 &lt;span style="color:#268bd2">nid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x4f03 runnable
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;G1 Refine#0&amp;#34;&lt;/span> &lt;span style="color:#268bd2">os_prio&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">31&lt;/span> &lt;span style="color:#268bd2">tid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x00007fbe31044800 &lt;span style="color:#268bd2">nid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x4e03 runnable
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;G1 Refine#1&amp;#34;&lt;/span> &lt;span style="color:#268bd2">os_prio&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">31&lt;/span> &lt;span style="color:#268bd2">tid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x00007fbe31045800 &lt;span style="color:#268bd2">nid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x4d03 runnable
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;G1 Refine#2&amp;#34;&lt;/span> &lt;span style="color:#268bd2">os_prio&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">31&lt;/span> &lt;span style="color:#268bd2">tid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x00007fbe31046000 &lt;span style="color:#268bd2">nid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x4c03 runnable
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;G1 Refine#3&amp;#34;&lt;/span> &lt;span style="color:#268bd2">os_prio&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">31&lt;/span> &lt;span style="color:#268bd2">tid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x00007fbe31047000 &lt;span style="color:#268bd2">nid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x4b03 runnable
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;G1 Young RemSet Sampling&amp;#34;&lt;/span> &lt;span style="color:#268bd2">os_prio&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">31&lt;/span> &lt;span style="color:#268bd2">tid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x00007fbe31047800 &lt;span style="color:#268bd2">nid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x3603 runnable
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198">&amp;#34;VM Periodic Task Thread&amp;#34;&lt;/span> &lt;span style="color:#268bd2">os_prio&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">31&lt;/span> &lt;span style="color:#268bd2">tid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x00007fbe31129000 &lt;span style="color:#268bd2">nid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>0x6703 waiting on condition
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;blockquote>
&lt;p>We can find all the thread digests by &lt;code>grep tid&lt;/code> here, and find the line that doesn&amp;rsquo;t contain the daemon keyword by &lt;code>grep -v&lt;/code> command.&lt;/p>
&lt;/blockquote>
&lt;p>We can get some information from the above results:&lt;/p>
&lt;ul>
&lt;li>There are two &amp;ldquo;suspicious&amp;rdquo; threads : &lt;code>container-0&lt;/code>, &lt;code>container-1&lt;/code>. They are non-daemon thread in wait state.&lt;/li>
&lt;li>There are alse some threads about GC, and threads that start with &lt;code>VM&lt;/code>. They are also some non-daemon threads, but they are most likely the JVM&amp;rsquo;s own threads, which we can ignore for now.&lt;/li>
&lt;/ul>
&lt;p>In summary, we can infer that it is likely that the &lt;code>container-0&lt;/code> and &lt;code>container-1&lt;/code> cause the JVM to not exit. Now let&amp;rsquo;s search through the source code to find out who created the two threads.&lt;/p>
&lt;p>By the source code analysis of Spring-boot, we can find these code in the &lt;code>startDaemonAwaitThread&lt;/code> method of &lt;code>org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">startDaemonAwaitThread&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Thread awaitThread &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> Thread(&lt;span style="color:#2aa198">&amp;#34;container-&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> (containerCounter.get())) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">run&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> TomcatEmbeddedServletContainer.this.tomcat.getServer().await();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> };
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> awaitThread.setContextClassLoader(getClass().getClassLoader());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> awaitThread.setDaemon(&lt;span style="color:#cb4b16">false&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> awaitThread.start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Let&amp;rsquo;s add a breakpoint in this method, and focus on the call stack:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-plain" data-lang="plain">&lt;span style="display:flex;">&lt;span>initialize:115, TomcatEmbeddedServletContainer (org.springframework.boot.context.embedded.tomcat)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;init&amp;gt;:84, TomcatEmbeddedServletContainer (org.springframework.boot.context.embedded.tomcat)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>getTomcatEmbeddedServletContainer:554, TomcatEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.tomcat)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>getEmbeddedServletContainer:179, TomcatEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.tomcat)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>createEmbeddedServletContainer:164, EmbeddedWebApplicationContext (org.springframework.boot.context.embedded)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>onRefresh:134, EmbeddedWebApplicationContext (org.springframework.boot.context.embedded)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>refresh:537, AbstractApplicationContext (org.springframework.context.support)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>refresh:122, EmbeddedWebApplicationContext (org.springframework.boot.context.embedded)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>refresh:693, SpringApplication (org.springframework.boot)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>refreshContext:360, SpringApplication (org.springframework.boot)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>run:303, SpringApplication (org.springframework.boot)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>run:1118, SpringApplication (org.springframework.boot)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>run:1107, SpringApplication (org.springframework.boot)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>main:35, DubboConsumerDemo (com.alibaba.boot.dubbo.demo.consumer.bootstrap)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>It can be seen that during the startup process of the Spring-boot application, the above method is executed since the execution of Tomcat exposes the HTTP service by default. Also, all threads started by Tomcat are daemon threads by default, such as the Acceptor of the listening request, threads in working threads, etc. Thus the JVM will also exit after the startup is complete in there is no extra control here. Therefore, it is necessary to explicitly start a thread and continue to wait under certain conditions, thereby avoid thread exit.&lt;/p>
&lt;p>Let&amp;rsquo;s dig deeper to find out how the thread stay alive in Tomcat&amp;rsquo;s &lt;code>this.tomcat.getServer().await()&lt;/code> method.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">await&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// ...&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span>( port&lt;span style="color:#719e07">==-&lt;/span>1 ) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">try&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> awaitThread &lt;span style="color:#719e07">=&lt;/span> Thread.currentThread();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">while&lt;/span>(&lt;span style="color:#719e07">!&lt;/span>stopAwait) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">try&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Thread.sleep( 10000 );
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } &lt;span style="color:#719e07">catch&lt;/span>( InterruptedException ex ) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// continue and check the flag&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } &lt;span style="color:#719e07">finally&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> awaitThread &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// ...&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In the await method, the current thread checks the variable &lt;code>stopAwait&lt;/code> every 10 seconds in a while loop. It is a &lt;code>volatile&lt;/code> variable that is used to ensure that the current thread can see the change immediately after the variable being modified by another thread. If there is no change, it will stay in the loop. This is the reason why the thread does not exit, which is also the reason that the entire Spring-boot application doesn&amp;rsquo;t exit.&lt;/p>
&lt;p>Since Spring-boot application enables port 8080 and 8081(management port) at the same time, there are actually two Tomcats. So there are two threads named &lt;code>container-0&lt;/code> and &lt;code>container-1&lt;/code>.&lt;/p>
&lt;p>Next, let&amp;rsquo;s see how this Spring-boot application exits.&lt;/p>
&lt;h2 id="the-analysis-of-dubboconsumer-exit">The analysis of DubboConsumer exit&lt;/h2>
&lt;p>As mentioned in the previous description, there is a thread that checks the variable &lt;code>stopAwait&lt;/code> continuously. So there must be a thread to modify &lt;code>stopAwait&lt;/code> at Stop, thus break the while loop. But who is modifying this variable?&lt;/p>
&lt;p>By analyzing the source code, we can see that there is only one method that modifies &lt;code>stopAwait&lt;/code> : &lt;code>org.apache.catalina.core.StandardServer#stopAwait&lt;/code>. To figure out who is calling this method, we add a breakpoint here.&lt;/p>
&lt;blockquote>
&lt;p>Note that after adding a breakpoint in Intellij IDEA&amp;rsquo;s Debug mode, we also need to type &lt;code>kill -s INT $PID&lt;/code> or &lt;code>kill -s TERM $PID&lt;/code> in command line to trigger the breakpoint. Due to buggy IDEA, a single click to the stop button won&amp;rsquo;t trigger the breakpoint.&lt;/p>
&lt;/blockquote>
&lt;p>You can see the method is called by a thread called &lt;code>Thread-3&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>stopAwait:390, StandardServer (org.apache.catalina.core)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>stopInternal:819, StandardServer (org.apache.catalina.core)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>stop:226, LifecycleBase (org.apache.catalina.util)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>stop:377, Tomcat (org.apache.catalina.startup)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>stopTomcat:241, TomcatEmbeddedServletContainer (org.springframework.boot.context.embedded.tomcat)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>stop:295, TomcatEmbeddedServletContainer (org.springframework.boot.context.embedded.tomcat)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>stopAndReleaseEmbeddedServletContainer:306, EmbeddedWebApplicationContext (org.springframework.boot.context.embedded)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>onClose:155, EmbeddedWebApplicationContext (org.springframework.boot.context.embedded)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>doClose:1014, AbstractApplicationContext (org.springframework.context.support)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>run:929, AbstractApplicationContext$2 (org.springframework.context.support)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Through source code analysis, it was executed by Spring&amp;rsquo;s registered &lt;code>ShutdownHook&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">registerShutdownHook&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (&lt;span style="color:#719e07">this&lt;/span>.shutdownHook &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// No shutdown hook registered yet.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">this&lt;/span>.shutdownHook &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> Thread() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">run&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">synchronized&lt;/span> (startupShutdownMonitor) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> doClose();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> };
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Runtime.getRuntime().addShutdownHook(&lt;span style="color:#719e07">this&lt;/span>.shutdownHook);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>By reffering the Java API documentation[2], we found that ShutdownHook will be executed under the following two cases.&lt;/p>
&lt;blockquote>
&lt;p>The Java virtual machine &lt;em>shuts down&lt;/em> in response to two kinds of events:&lt;/p>
&lt;ul>
&lt;li>The program &lt;em>exits&lt;/em> normally, when the last non-daemon thread exits or when the &lt;code>exit&lt;/code> (equivalently, &lt;a href="https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#exit-int-">&lt;code>System.exit&lt;/code>&lt;/a>) method is invoked, or&lt;/li>
&lt;li>The virtual machine is &lt;em>terminated&lt;/em> in response to a user interrupt, such as typing &lt;code>^C&lt;/code>, or a system-wide event, such as user logoff or system shutdown.&lt;/li>
&lt;/ul>
&lt;/blockquote>
&lt;ol>
&lt;li>So it&amp;rsquo;s either a call of &lt;code>System.exit()&lt;/code>&lt;/li>
&lt;li>Respond to external signals, such as Ctrl+C(actually sent as SIGINT signal), or &lt;code>SIGTERM&lt;/code> signal (&lt;code>kill $PID&lt;/code> will send &lt;code>SIGTERM&lt;/code> signal by default)&lt;/li>
&lt;/ol>
&lt;p>Therefore, the normal application will execute the above ShutdownHook during the stop process (except &lt;code>kill -9 $PID&lt;/code>). Its function is not only to close the Tomcat, but also to perform other cleanup work. It is unnecessary to go into details.&lt;/p>
&lt;h2 id="summary">Summary&lt;/h2>
&lt;ol>
&lt;li>During the startup of &lt;code>DubboConsumer&lt;/code>, an independent non-daemon thread is launched to query the status of the variable continuously, thus the process can&amp;rsquo;t exit.&lt;/li>
&lt;li>To stop the &lt;code>DubboConsumer&lt;/code>, one should call ShutdownHook to change the variable to let the thread break the loop.&lt;/li>
&lt;/ol>
&lt;h2 id="problems">Problems&lt;/h2>
&lt;p>In the example of DubboProvider, we see that Provider doesn&amp;rsquo;t start Tomcat to provide HTTP service, then how does the program stays alive without exiting? We will answer this question in the next article.&lt;/p>
&lt;h3 id="notice">Notice&lt;/h3>
&lt;p>By running the following unit test which create a thread in &lt;code>Intellij IDEA&lt;/code> , we are surprised to find that the program exits with less than 1000s. Why?(The thread being created is a non-daemon thread)&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Test&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">test&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">new&lt;/span> Thread(&lt;span style="color:#719e07">new&lt;/span> Runnable() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">run&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">try&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Thread.sleep(1000000);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } &lt;span style="color:#719e07">catch&lt;/span> (InterruptedException e) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> e.printStackTrace();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }).start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>[1] &lt;a href="https://docs.oracle.com/javase/specs/jls/se8/html/jls-12.html#jls-12.8">https://docs.oracle.com/javase/specs/jls/se8/html/jls-12.html#jls-12.8&lt;/a>&lt;/p>
&lt;p>[2] &lt;a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#addShutdownHook">https://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#addShutdownHook&lt;/a>&lt;/p></description></item><item><title>Blog: Implementation of cross-language calls by Dubbo2.js</title><link>https://dubbo.apache.org/en/blog/2018/08/14/implementation-of-cross-language-calls-by-dubbo2.js/</link><pubDate>Tue, 14 Aug 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/08/14/implementation-of-cross-language-calls-by-dubbo2.js/</guid><description>
&lt;blockquote>
&lt;p>&lt;a href="https://github.com/dubbo/dubbo2.js">dubbo2.js&lt;/a> is a Dubbo client for node.js developped by &lt;a href="https://www.qianmi.com/">Qianmiwang&lt;/a>. It supports Dubbo&amp;rsquo;s native protocol, which makes the RPC calls between javascript and java efficient and agile. This tool has been contributed to Dubbo&amp;rsquo;s community.&lt;/p>
&lt;/blockquote>
&lt;h2 id="cross-language-calls-for-micro-service">Cross-language calls for micro service&lt;/h2>
&lt;p>Nowadays, Internet architecture tends to be micro-service way. The discussions about micro-service architecture becomes the most mentioned topic in different technical conferences. In China, most of the companies, such as Qianmiwang, choose Dubbo as their micro-servie architecture solution. As most of the internet companies, Qianmiwang uses various of programming languages. Java is for most of the backend services. Each business based on these backend can choose its own programming language such as go, python and javascript. Therefore, here comes a challenge, cross language calls. Some well mentioned solutions are as follows:&lt;/p>
&lt;ul>
&lt;li>Spring cloud. Spring cloud provides a set of components for micro-service development. It is based on HTTP protocol and is designed in the restful way, which makes it support cross-language calls. Other languages can call the services simply by implementing an HTTP interface.&lt;/li>
&lt;li>Service mesh. People call service mesh the next generation of micro-service framework. The core of this solution is SideCar. Even though the concept of SideCar changes a lot during the revolution of Service mesh, its main job never changed: providing reliable communication between different services.&lt;/li>
&lt;li>Motan. &lt;a href="https://github.com/weibocom/motan">Motan&lt;/a> is an open source cross-language service framework developped by Sina Weibo. Its early version only supports motan-java. However, as the new versions come out, more languages are supported in order to handle the cross-language problem. Its newest version(1.1.0) provides motan-go, motan-php, motan-openresty, etc. Similar to SideCar in Service mesh, Motan forwards messages by mortan-go, which can be considered as an agent. Meanwhile, motan2, its own protocol, is built for cross-language calls.&lt;/li>
&lt;/ul>
&lt;p>According to the solutions below, there are two ways to solve the cross-language calls problem:&lt;/p>
&lt;ul>
&lt;li>communicating by a common protocol.&lt;/li>
&lt;li>implementing an agent as a protocol adapter.&lt;/li>
&lt;/ul>
&lt;p>When a new team is choosing technical solutions, what I mentioned below could be our candidates. Meanwhile, the old system&amp;rsquo;s compatibility and migration costs should also be considered. The first trial we did is to work on RPC protocol.&lt;/p>
&lt;h2 id="cross-language-calls-by-a-common-protocol">Cross-language calls by a common protocol&lt;/h2>
&lt;h3 id="springmvc">SpringMVC&lt;/h3>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/springmvc.png" alt="springmvc">&lt;/p>
&lt;p>Before achieving the real cross-language calls, the most common solution is to use the http protocol. We can call Dubbo provider indirectly by controller/restController provided by springmvc. This is easy to carry out, but there are lots of inconveniences. firstly, a call will go through too many nodes. Secondly, an extra communication layer (for http protocol) will be involved, but it could have been handled simply by the TCP protocol. Thirdly, we need to implement the RPC interface in the controller part. This will be extra work for developers.&lt;/p>
&lt;h3 id="we-support-some-common-protocols">We support some common protocols&lt;/h3>
&lt;p>Most of the service management frameworks support multiple protocols, dubbo as well. Besides its own protocol, the common protocols such as Dangdangwang&amp;rsquo;s &lt;a href="https://dangdangdotcom.github.io/dubbox/rest.html">Rest&lt;/a> protocol and Qianmiwang&amp;rsquo;s &lt;a href="https://github.com/apache/dubbo-rpc-jsonrpc">json-rpc&lt;/a> protocol are also supported.&lt;/p>
&lt;p>The developers getting used to traditional RPC interfaces might feel uncomfortable while working on restful RPC interfaces. On the one hand, this is not good for rebuilding new interfaces. On the other hand, restful style might make these interfaces incompatible with the other protocols used by old interfaces. Of course, if there is no old system problems, using Rest protocol is the easiest implementation of cross-language calls, since most of the languages support it.&lt;/p>
&lt;p>Even if Dubbo has tried on restful interface, the difference between rest architecture and RPC architecture should not be ignored. Rest architecture defines each resources, and it needs basic operations of http protocols such as GET, POST, DELETE, PUT. In my opinion, a Rest protocol is more for calls between different systems on the internet, while RPC is suitable for inner system calls. Similar to Rest protocol, json-rpc is also implemented by text sequence and http protocol. Using json-rpc can also solve the cross-language problems, meanwhile, it makes our solution compatible with old interfaces and there is no need to adapt to the restful style.&lt;/p>
&lt;p>Json-rpc is Qianmiwang&amp;rsquo;s early solution for cross-language protocol. They open-sourced their &lt;a href="https://github.com/dubbo/dubbo-client-py">dubbo-client-py&lt;/a> and &lt;a href="https://github.com/QianmiOpen/dubbo-node-client">dubbo-node-client&lt;/a>, two clients based on json-rpc protocol. With these tools, we can easily call the rpc services provided by dubbo-provider-java with while using python or node.js. The inner system calls for java services are still mainly implemented by Dubbo protocol. In addition, in order to adapt the old system, two protocols could be configured.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:protocol&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;dubbo&amp;#34;&lt;/span> port=&lt;span style="color:#2aa198">&amp;#34;20880&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:protocol&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;jsonrpc&amp;#34;&lt;/span> port=&lt;span style="color:#2aa198">&amp;#34;8080&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="customized-protocols-for-cross-language-support">Customized Protocols for Cross-language Support&lt;/h3>
&lt;p>The so-called protocol of the microservice framework can be simply interpreted as: message format and serialization scheme. Generally, the service governance framework would provide numbers of protocol configuration items for users to choose from. In addition to the above two common protocols,there exists some other customized protocols like the dubbo protocol, the default protocol for the dubbo framework, and Motan2, a cross-language protocol provided by the motan framework.&lt;/p>
&lt;h4 id="motan2-for-cross-language-support">Motan2 for cross-language support&lt;/h4>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/motan-protocol-en.png" alt="motan2">&lt;/p>
&lt;p>In the original Motan protocol, the protocol message consisted only of the Header and the Body, making deserialization indispensable for acquiring data stored in the Body, like path, param and group, which is terribly unfriendly for cross-language support. Therefore, the content of the protocol was modifiedin Motan2, Weibo released the open-source projects, &lt;a href="https://github.com/weibocom/motan-go/">motan-go&lt;/a>, &lt;a href="https://github.com/weibocom/motan-php">motan-php&lt;/a> and &lt;a href="https://github.com/weibocom/motan-openresty">motan-openresty&lt;/a>. It used motan-go as an interpreter and the Simple serialization scheme to serialize the Body of protocol message. (Simple is a comparably weaker serialization scheme)&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/motan-agent.png" alt="agent">&lt;/p>
&lt;p>After observation we find out that there is no big difference between the configuration of Motan2 and the dual protocol. It’s just that the agent here is implicit, and it co-exists with the main service. The most obvious difference is that different languages do not interact directly in agent scheme.&lt;/p>
&lt;h4 id="dubbo-for-cross-language-support">Dubbo for cross-language support&lt;/h4>
&lt;p>Instead of cross-language support, the dubbo protocol was originally designed only for common rpc requests. However, it’s not always the case that we can only choose to support it or not. We can always choose to offer different levels of support. It may be hard to offer cross-language support based on the dubbo protocol, but not impossible. Actually, Qianmiwang succeeded. It conquered the front-end cross-language business field built by nodejs with dubbo2.js. It builds the bridge between Nodejs and the native dubbo protocol. Next, we will focus on what we can do with dubbo2.js.&lt;/p>
&lt;h5 id="dubbo-protocol-message-format">Dubbo protocol message format:&lt;/h5>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-protocol.png" alt="dubbo协议">&lt;/p>
&lt;p>Details in dubbo protocol header message:&lt;/p>
&lt;ul>
&lt;li>Magic: similar to magic number in Java bytes code files, which is used to determine whether it is a data pack of dubbo protocol. The magic number is the constant, 0xdabb.&lt;/li>
&lt;li>Flag: contains 8 bits. The lower four bits are used to indicate the type of serialization tool used for message body data (default hessian). Among the upper four bits, the 1 at first bit indicates request, the 1 at second bit indicates dual transfer, 1 at third bits indicates the heartbeat.&lt;/li>
&lt;li>Status: used toset response status. Dubbo defines some types for response. Details can be found in &lt;span data-type="color" style="color:rgb(36, 41, 46)">&lt;span data-type="background" style="background-color:rgba(27, 31, 35, 0.05)">com.alibaba.dubbo.remoting.exchange.Response&lt;/span>&lt;/span>&lt;/li>
&lt;li>Invoke id: Message id,Type long, Unique indentifier for each request (Due to asynchronous communication, it is used to match the request to the corresponding returned response)&lt;/li>
&lt;li>Body length: message body length, type int,record bytes of body content.&lt;/li>
&lt;li>Body content: request param, where serializedresponse parameters are stored.&lt;/li>
&lt;/ul>
&lt;p>Protocol messages will eventually become bytes and be transmitted using TCP. Any language that supports network modules and has a socket will be able to be communicatedwith. Then, why cross-language support is difficult? There are two main obstaclesin calling service in Java using other languages:&lt;/p>
&lt;ol>
&lt;li>&lt;span data-type="color" style="color:#24292E">How &lt;/span>&lt;span data-type="color" style="color:#212121">can different languages ​​represent data types in java, especially dynamiclanguages with possible non-strict data types&lt;/span>?&lt;/li>
&lt;li>&lt;span data-type="color" style="color:#24292E">How to serialize string across language?&lt;/span>&lt;/li>
&lt;/ol>
&lt;h2 id="how-does-dubbo2js-solve-problems">How does dubbo2.js solve problems?&lt;/h2>
&lt;p>We have analyzed two obstacles above. The key to dubbo2.js in solving these two problems depends on two class libraries: &lt;a href="https://github.com/node-modules/js-to-java">js-to-java&lt;/a>,&lt;a href="https://github.com/node-modules/hessian.js">hessian.js&lt;/a>. js-to-java, which makes nodejs have the ability to express Java objects. Hessian.js provides serialization capabilities. With the help of nodejs socket, and a duplicate set of dubbo protocol message format, we can finally achieve nodejs call to java-dubbo-provider.&lt;/p>
&lt;h2 id="quick-start">Quick Start&lt;/h2>
&lt;p>To give an intuitive feeling to readers interested in dubbo2.js, this section presents a quick start example that shows how easy it is to call dubbo service using dubbo2.js.&lt;/p>
&lt;h3 id="1-initiate-dubbo-java-provider">1. Initiate dubbo-java-provider&lt;/h3>
&lt;p>Java provides the backend dubbo service. Firstly, let’s define the service interface:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">DemoProvider&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">echo&lt;/span>() ;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">test&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> UserResponse &lt;span style="color:#268bd2">getUserInfo&lt;/span>(UserRequest request);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Then we implement the interface:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DemoProviderImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> DemoProvider {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;[&amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#719e07">new&lt;/span> SimpleDateFormat(&lt;span style="color:#2aa198">&amp;#34;HH:mm:ss&amp;#34;&lt;/span>).format(&lt;span style="color:#719e07">new&lt;/span> Date()) &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#34;] Hello &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#34;, request from consumer: &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> RpcContext.getContext().getRemoteAddress());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;Hello &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#34;, response form provider: &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> RpcContext.getContext().getLocalAddress();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">echo&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;receive....&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;pang&amp;#34;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">test&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;test&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> UserResponse &lt;span style="color:#268bd2">getUserInfo&lt;/span>(UserRequest request) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(request);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> UserResponse response &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> UserResponse();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> response.setStatus(&lt;span style="color:#2aa198">&amp;#34;ok&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, String&lt;span style="color:#719e07">&amp;gt;&lt;/span> map &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> HashMap&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, String&lt;span style="color:#719e07">&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> map.put(&lt;span style="color:#2aa198">&amp;#34;id&amp;#34;&lt;/span>, &lt;span style="color:#2aa198">&amp;#34;1&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> map.put(&lt;span style="color:#2aa198">&amp;#34;name&amp;#34;&lt;/span>, &lt;span style="color:#2aa198">&amp;#34;test&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> response.setInfo(map);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> response;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>After that,&lt;span data-type="color" style="color:#24292E"> we expose the dubbo service with xml files:&lt;/span>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-8&amp;#34;?&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;beans&lt;/span> xmlns:xsi=&lt;span style="color:#2aa198">&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:dubbo=&lt;span style="color:#2aa198">&amp;#34;http://code.alibabatech.com/schema/dubbo&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns=&lt;span style="color:#2aa198">&amp;#34;http://www.springframework.org/schema/beans&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xsi:schemaLocation=&lt;span style="color:#2aa198">&amp;#34;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- dubbo provider info, used to compute dependency --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:application&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;demo-provider&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:registry&lt;/span> protocol=&lt;span style="color:#2aa198">&amp;#34;zookeeper&amp;#34;&lt;/span> address=&lt;span style="color:#2aa198">&amp;#34;localhost:2181&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- dubbo protocol, used to expose service at port 20880 --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:protocol&lt;/span> name=&lt;span style="color:#2aa198">&amp;#34;dubbo&amp;#34;&lt;/span> port=&lt;span style="color:#2aa198">&amp;#34;20880&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- realize a service as a local bean --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;bean&lt;/span> id=&lt;span style="color:#2aa198">&amp;#34;demoProvider&amp;#34;&lt;/span> class=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.demo.provider.DemoProviderImpl&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">&amp;lt;!-- claim for service interfaces to expose --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dubbo:service&lt;/span> interface=&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.demo.DemoProvider&amp;#34;&lt;/span> ref=&lt;span style="color:#2aa198">&amp;#34;demoProvider&amp;#34;&lt;/span> version=&lt;span style="color:#2aa198">&amp;#34;1.0.0&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/beans&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>After we implemented all the configurations on server side, initiate an object initiater to register a dubbo service locally:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">Provider&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) &lt;span style="color:#268bd2">throws&lt;/span> Exception {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ClassPathXmlApplicationContext context &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ClassPathXmlApplicationContext(&lt;span style="color:#719e07">new&lt;/span> String&lt;span style="color:#719e07">[]&lt;/span>{&lt;span style="color:#2aa198">&amp;#34;META-INF/spring/dubbo-demo-provider.xml&amp;#34;&lt;/span>});
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.in.read();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="2-implement-dubbo-client-side-for-nodejs">2. Implement dubbo client-side for nodejs&lt;/h3>
&lt;p>Install dubbo2.js using npm:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>npm install dubbo2.js --save
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Configure dubboConfig.ts:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-typescript" data-lang="typescript">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">import&lt;/span> { Dubbo, java, TDubboCallResult } &lt;span style="color:#268bd2">from&lt;/span> &lt;span style="color:#2aa198">&amp;#39;dubbo2.js&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">const&lt;/span> dubbo &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> Dubbo({
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> application&lt;span style="color:#719e07">:&lt;/span> {name&lt;span style="color:#719e07">:&lt;/span> &lt;span style="color:#2aa198">&amp;#39;demo-provider&amp;#39;&lt;/span>},
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> register&lt;span style="color:#719e07">:&lt;/span> &lt;span style="color:#2aa198">&amp;#39;localhost:2181&amp;#39;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> dubboVersion&lt;span style="color:#719e07">:&lt;/span> &lt;span style="color:#2aa198">&amp;#39;2.0.0&amp;#39;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> interfaces&lt;span style="color:#719e07">:&lt;/span> [
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">&amp;#39;com.alibaba.dubbo.demo.DemoProvider&amp;#39;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ],
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>});
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">interface&lt;/span> IDemoService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> sayHello(name: &lt;span style="color:#dc322f">string&lt;/span>)&lt;span style="color:#719e07">:&lt;/span> TDubboCallResult&amp;lt;&lt;span style="color:#268bd2">string&lt;/span>&amp;gt;;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">export&lt;/span> &lt;span style="color:#268bd2">const&lt;/span> demoService &lt;span style="color:#719e07">=&lt;/span> dubbo.proxyService&amp;lt;&lt;span style="color:#268bd2">IDemoService&lt;/span>&amp;gt;({
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> dubboInterface&lt;span style="color:#719e07">:&lt;/span> &lt;span style="color:#2aa198">&amp;#39;com.alibaba.dubbo.demo.DemoProvider&amp;#39;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> version&lt;span style="color:#719e07">:&lt;/span> &lt;span style="color:#2aa198">&amp;#39;1.0.0&amp;#39;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> methods&lt;span style="color:#719e07">:&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> sayHello(name: &lt;span style="color:#dc322f">string&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> [java.&lt;span style="color:#b58900">String&lt;/span>(name)];
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> echo() {},
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> test() {},
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> getUserInfo() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> [
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> java.combine(&lt;span style="color:#2aa198">&amp;#39;com.alibaba.dubbo.demo.UserRequest&amp;#39;&lt;/span>, {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> id: &lt;span style="color:#dc322f">1&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> name&lt;span style="color:#719e07">:&lt;/span> &lt;span style="color:#2aa198">&amp;#39;nodejs&amp;#39;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> email&lt;span style="color:#719e07">:&lt;/span> &lt;span style="color:#2aa198">&amp;#39;node@qianmi.com&amp;#39;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }),
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ];
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> },
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>});
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;blockquote>
&lt;p>Using typescript brings better coding experience.&lt;/p>
&lt;/blockquote>
&lt;p>Implement caller class main.ts:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-typescript" data-lang="typescript">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">import&lt;/span> {demoService} &lt;span style="color:#268bd2">from&lt;/span> &lt;span style="color:#2aa198">&amp;#39;./dubboConfig&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>demoService.sayHello(&lt;span style="color:#2aa198">&amp;#39;kirito&amp;#39;&lt;/span>).then(({res,err})&lt;span style="color:#719e07">=&amp;gt;&lt;/span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> console.log(res)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>});
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="3-call-maints">3. Call main.ts:&lt;/h3>
&lt;p>Run nodejs client in Debug mode:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">DEBUG&lt;/span>&lt;span style="color:#719e07">=&lt;/span>dubbo* ts-node main.ts
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Checkout running results:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>Hello kirito, response form provider: 172.19.6.151:20880
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Congratulations!&lt;/p>
&lt;h2 id="features">Features&lt;/h2>
&lt;ul>
&lt;li>Support zookeeper as register center&lt;/li>
&lt;li>Support TCP Dubbo Native protocol&lt;/li>
&lt;li>Support directly Dubbo connection&lt;/li>
&lt;li>Support link tracing&lt;/li>
&lt;li>Generate dubbo interface Automatically&lt;/li>
&lt;/ul>
&lt;h2 id="more-details">More details&lt;/h2>
&lt;p>The sample code in this article is available here, &lt;a href="https://github.com/dubbo/dubbo2.js">https://github.com/dubbo/dubbo2.js&lt;/a>.
If you don't know much about the dubbo protocol and want to understand how it works, the project provides a sub-moudle: java-socket-consumer, which is implemented in a process-oriented approach, realizing a process of sending dubbo protocal message with native socket and making function calls, and then get response.&lt;/p></description></item><item><title>Blog: Generic invoke of Dubbo</title><link>https://dubbo.apache.org/en/blog/2018/08/14/generic-invoke-of-dubbo/</link><pubDate>Tue, 14 Aug 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/08/14/generic-invoke-of-dubbo/</guid><description>
&lt;h1 id="generic-invoke-of-dubbo">Generic invoke of Dubbo&lt;/h1>
&lt;p>The generic invoke could be considered to be used in the following cases:&lt;/p>
&lt;ul>
&lt;li>Service test platform&lt;/li>
&lt;li>API service gateway&lt;/li>
&lt;/ul>
&lt;p>The generic invoke is mainly used when the consumer does not have an API interface;
instead of depending the interface jar package, the service call is initiated directly through the GenericService interface, and all POJOs in the parameters and return values are represented by a &lt;code>Map&lt;/code>.
Generic invoke does not require attention on the server and can be exposed as normal services.&lt;/p>
&lt;p>Next, let&amp;rsquo;s take a look at how the consumer uses generic invoke for service call.&lt;/p>
&lt;h2 id="generic-invoke-through-spring-xml-configuration">Generic invoke through Spring XML configuration&lt;/h2>
&lt;p>Declare &lt;code>generic=&amp;quot;true&amp;quot;&lt;/code> in Spring configuration, such as&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&amp;#34;userService&amp;#34; interface=&amp;#34;com.alibaba.dubbo.samples.generic.api.IUserService&amp;#34; generic=&amp;#34;true&amp;#34;/&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Where you need to use it, you can call it by forcing a type cast to GenericService.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>GenericService userService &lt;span style="color:#719e07">=&lt;/span> (GenericService) context.getBean(&lt;span style="color:#2aa198">&amp;#34;userService&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">// primary param and return value&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>String name &lt;span style="color:#719e07">=&lt;/span> (String) userService.$invoke(&lt;span style="color:#2aa198">&amp;#34;delete&amp;#34;&lt;/span>, &lt;span style="color:#719e07">new&lt;/span> String&lt;span style="color:#719e07">[]&lt;/span>{&lt;span style="color:#dc322f">int&lt;/span>.class.getName()}, &lt;span style="color:#719e07">new&lt;/span> Object&lt;span style="color:#719e07">[]&lt;/span>{1});
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>System.out.println(name);
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Among them,&lt;/p>
&lt;ol>
&lt;li>
&lt;p>The interface GenericService has only one method, named $invoke, which takes three arguments, a method name, an array of method parameter types, and an array of parameter values.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>For arrays of method parameter types&lt;/p>
&lt;p>i. If it is a basic type, such as int or long, use &lt;code>int.class.getName()&lt;/code> to get its type;&lt;/p>
&lt;p>ii. If it is a basic type array, such as int[], use &lt;code>int[].class.getName()&lt;/code>;&lt;/p>
&lt;p>iii. If it is a POJO, use the full class name directly, such as &lt;code>com.alibaba.dubbo.samples.generic.api.Params&lt;/code>.&lt;/p>
&lt;/li>
&lt;/ol>
&lt;h2 id="generic-invoke-through-api-programming">Generic invoke through API programming&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>ApplicationConfig application &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ApplicationConfig()ApplicationConfig application &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ApplicationConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>application.setName(&lt;span style="color:#2aa198">&amp;#34;api-generic-consumer&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>RegistryConfig registry &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> RegistryConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>registry.setAddress(&lt;span style="color:#2aa198">&amp;#34;zookeeper://127.0.0.1:2181&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>application.setRegistry(registry);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ReferenceConfig&lt;span style="color:#719e07">&amp;lt;&lt;/span>GenericService&lt;span style="color:#719e07">&amp;gt;&lt;/span> reference &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ReferenceConfig&lt;span style="color:#719e07">&amp;lt;&lt;/span>GenericService&lt;span style="color:#719e07">&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">// weak type interface name&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>reference.setInterface(&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.generic.api.IUserService&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">// declared as a generalized interface&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>reference.setGeneric(&lt;span style="color:#cb4b16">true&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>reference.setApplication(application);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">// replace all interface references with com.alibaba.dubbo.rpc.service.GenericService&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>GenericService genericService &lt;span style="color:#719e07">=&lt;/span> reference.get();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>String name &lt;span style="color:#719e07">=&lt;/span> (String) genericService.$invoke(&lt;span style="color:#2aa198">&amp;#34;delete&amp;#34;&lt;/span>, &lt;span style="color:#719e07">new&lt;/span> String&lt;span style="color:#719e07">[]&lt;/span>{&lt;span style="color:#dc322f">int&lt;/span>.class.getName()}, &lt;span style="color:#719e07">new&lt;/span> Object&lt;span style="color:#719e07">[]&lt;/span>{1});
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>System.out.println(name);
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Through the API, you don&amp;rsquo;t need to configure the service in advance like XML. You can dynamically construct ReferenceConfig; the API is more common than XML.&lt;/p>
&lt;h2 id="the-case-where-parameters-or-return-values-are-pojos">The case where parameters or return values are POJOs&lt;/h2>
&lt;p>For example, the method signature is &lt;code>User get(Params params)&lt;/code>, where &lt;code>User&lt;/code> has two attributes, id and name, and &lt;code>Params&lt;/code> has one attribute, query.&lt;/p>
&lt;p>The following is the code of the consumer:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>String&lt;span style="color:#719e07">[]&lt;/span> parameterTypes &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> String&lt;span style="color:#719e07">[]&lt;/span>{&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.generic.api.Params&amp;#34;&lt;/span>};
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Map&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Object&lt;span style="color:#719e07">&amp;gt;&lt;/span> params &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> HashMap&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Object&lt;span style="color:#719e07">&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>param.put(&lt;span style="color:#2aa198">&amp;#34;class&amp;#34;&lt;/span>, &lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.generic.api.Params&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>param.put(&lt;span style="color:#2aa198">&amp;#34;query&amp;#34;&lt;/span>, &lt;span style="color:#2aa198">&amp;#34;a=b&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Object user &lt;span style="color:#719e07">=&lt;/span> userService.$invoke(&lt;span style="color:#2aa198">&amp;#34;get&amp;#34;&lt;/span>, parameterTypes, &lt;span style="color:#719e07">new&lt;/span> Object&lt;span style="color:#719e07">[]&lt;/span>{param});
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>System.out.println(&lt;span style="color:#2aa198">&amp;#34;sample one result: &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> user);
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The output of the above code is:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>sample one result: {name=charles, id=1, class=com.alibaba.dubbo.samples.generic.api.User}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Here, the Dubbo framework will automatically convert the return value from POJO to Map.
It can be seen that the return value &lt;code>user&lt;/code> is a HashMap, which stores three k/vs, name, id, and class.&lt;/p>
&lt;h2 id="generic-interface-implementation">Generic interface implementation&lt;/h2>
&lt;p>The implementation of the generic interface is mainly used when the server does not have an API interface. All POJOs in the parameters and return values are represented by Map, which is usually used for framework integration. For example, to implement a generic remote service Mock framework, all service requests can be handled by implementing the interface GenericService.&lt;/p>
&lt;h3 id="implementation-genericservice-on-the-server">Implementation GenericService on the server&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">GenericServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> GenericService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> Object &lt;span style="color:#268bd2">$invoke&lt;/span>(String method, String&lt;span style="color:#719e07">[]&lt;/span> parameterTypes, Object&lt;span style="color:#719e07">[]&lt;/span> args) &lt;span style="color:#268bd2">throws&lt;/span> GenericException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (method.equals(&lt;span style="color:#2aa198">&amp;#34;hi&amp;#34;&lt;/span>)) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;hi, &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> args&lt;span style="color:#719e07">[&lt;/span>0&lt;span style="color:#719e07">]&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } &lt;span style="color:#719e07">else&lt;/span> &lt;span style="color:#719e07">if&lt;/span> (method.equals(&lt;span style="color:#2aa198">&amp;#34;hello&amp;#34;&lt;/span>)) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;hello, &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> args&lt;span style="color:#719e07">[&lt;/span>0&lt;span style="color:#719e07">]&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;welcome&amp;#34;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="server-exposed-service">Server exposed service&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>ApplicationConfig application &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ApplicationConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>application.setName(&lt;span style="color:#2aa198">&amp;#34;api-generic-provider&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>RegistryConfig registry &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> RegistryConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>registry.setAddress(&lt;span style="color:#2aa198">&amp;#34;zookeeper://127.0.0.1:2181&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>application.setRegistry(registry);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>GenericService genericService &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> GenericServiceImpl();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ServiceConfig&lt;span style="color:#719e07">&amp;lt;&lt;/span>GenericService&lt;span style="color:#719e07">&amp;gt;&lt;/span> service &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ServiceConfig&lt;span style="color:#719e07">&amp;lt;&lt;/span>GenericService&lt;span style="color:#719e07">&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service.setApplication(application);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service.setInterface(&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.generic.api.HelloService&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service.setRef(genericService);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service.export();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ServiceConfig&lt;span style="color:#719e07">&amp;lt;&lt;/span>GenericService&lt;span style="color:#719e07">&amp;gt;&lt;/span> service2 &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ServiceConfig&lt;span style="color:#719e07">&amp;lt;&lt;/span>GenericService&lt;span style="color:#719e07">&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service2.setApplication(application);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service2.setInterface(&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.generic.api.HiService&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service2.setRef(genericService);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>service2.export();
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Similarly, you can expose the service using XML configuration; in this case, the server does not depend on the two interfaces HiService and HelloService.&lt;/p>
&lt;h3 id="service-invoke-on-the-consumer">Service invoke on the consumer&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>ApplicationConfig application &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ApplicationConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>application.setName(&lt;span style="color:#2aa198">&amp;#34;api-generic-consumer&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>RegistryConfig registry &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> RegistryConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>registry.setAddress(&lt;span style="color:#2aa198">&amp;#34;zookeeper://127.0.0.1:2181&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>application.setRegistry(registry);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ReferenceConfig&lt;span style="color:#719e07">&amp;lt;&lt;/span>GenericService&lt;span style="color:#719e07">&amp;gt;&lt;/span> reference &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ReferenceConfig&lt;span style="color:#719e07">&amp;lt;&lt;/span>GenericService&lt;span style="color:#719e07">&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">// weak type interface name&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>reference.setInterface(HiService.class);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>reference.setApplication(application);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>HiService hiService &lt;span style="color:#719e07">=&lt;/span> (HiService) reference.get();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>System.out.println(hiService.hi(&lt;span style="color:#2aa198">&amp;#34;dubbo&amp;#34;&lt;/span>));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ReferenceConfig&lt;span style="color:#719e07">&amp;lt;&lt;/span>GenericService&lt;span style="color:#719e07">&amp;gt;&lt;/span> reference2 &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ReferenceConfig&lt;span style="color:#719e07">&amp;lt;&lt;/span>GenericService&lt;span style="color:#719e07">&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">// weak type interface name&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>reference2.setInterface(HelloService.class);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>reference2.setApplication(application);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>HelloService helloService &lt;span style="color:#719e07">=&lt;/span> (HelloService) reference2.get();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>System.out.println(helloService.hello(&lt;span style="color:#2aa198">&amp;#34;community&amp;#34;&lt;/span>));
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Similarly, the consumer can also reference the service using an XML configuration and then make the call. Here you can see that the calling method is a normal service call, not a generic call. Of course, it is also possible to use generic calls.&lt;/p>
&lt;p>So far, a simple service Mock platform has been successfully launched!&lt;/p>
&lt;h2 id="others">Others&lt;/h2>
&lt;ul>
&lt;li>The generic invoke and generic interface implementations introduced in this article are all based on the native Dubbo protocol. Prior to version 2.6.2, other protocols such as http/hessian don&amp;rsquo;t support generic invoke. Version 2.6.3 will support the generic invoke of these two protocols.&lt;/li>
&lt;li>The relevant sample codes mentioned in this article can be found in dubbo-samples: &lt;a href="https://github.com/apache/dubbo-samples/tree/master/2-advanced/dubbo-samples-generic">https://github.com/apache/dubbo-samples/tree/master/2-advanced/dubbo-samples-generic&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Blog: Native Image using GraalVM</title><link>https://dubbo.apache.org/en/blog/2018/08/14/native-image-using-graalvm/</link><pubDate>Tue, 14 Aug 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/08/14/native-image-using-graalvm/</guid><description>
&lt;h2 id="overview">Overview&lt;/h2>
&lt;p>This document will show you how to access GraalVM with a dubbo project and how to compile the project to a binary executable using native-image. The document also introduces the efforts we made in achieving this.&lt;/p>
&lt;p>GraalVM&amp;rsquo;s essential is the Graal compiler, an excellent just-in-time (JIT) compiler. It can be used as both a JIT compiler and a static compiler for ahead-of-time compilation. Graal compiler completes the primary compilation work.&lt;/p>
&lt;p>For more information about GraalVM, read &lt;a href="https://www.graalvm.org/docs/getting-started/container-images/">https://www.graalvm.org/docs/getting-started/container-images/&lt;/a>.&lt;/p>
&lt;h2 id="preparation">Preparation&lt;/h2>
&lt;p>Before compiling the dubbo project, make sure that we are programming based on the GraalVM environment.&lt;/p>
&lt;p>GraalVM&amp;rsquo;s installation process won&amp;rsquo;t be introduced in this document. You can visit &lt;a href="https://www.graalvm.org/">https://www.graalvm.org/&lt;/a> and select the latest version to install. After installation you will be able to see the following in local jdk:&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-graalvm-support/graalvm_env.png" alt="graalvm_env.png">
GraalVM we use here is based on jdk version 1.8.&lt;/p>
&lt;h2 id="get-started">Get Started&lt;/h2>
&lt;p>For user&amp;rsquo;s convenience, we provide the following demo in the &lt;a href="https://github.com/apache/dubbo/">apache dubbo&lt;/a> branch. In module dubbo-demo-native, dubbo&amp;rsquo;s provider and consumer demos are given:&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-graalvm-support/demo_path.png" alt="demo_path.png">&lt;/p>
&lt;p>We used native-image&amp;rsquo;s maven plug-in and customized several native-image starting parameters. Users only need to run maven&amp;rsquo;s compile and package command in consumers&amp;rsquo; and providers&amp;rsquo; modules:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-go" data-lang="go">&lt;span style="display:flex;">&lt;span>mvn &lt;span style="color:#719e07">-&lt;/span>U clean &lt;span style="color:#719e07">package&lt;/span> &lt;span style="color:#719e07">-&lt;/span>Dmaven.test.skip=&lt;span style="color:#cb4b16">true&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>You can see the following output after compilation:&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-graalvm-support/consumer_compiler.png" alt="provider_compiler.png">&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-graalvm-support/provider_compiler.png" alt="img">&lt;/p>
&lt;p>Binary executable file generated can be found in the target catalog:&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-graalvm-support/compile_result.png" alt="compile_result.png">&lt;/p>
&lt;p>Size of the binary executable file is around 40M:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>MacdeMacBook-pro-3:target mac$ du -m demo-native-provider
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>40 demo-native-provider
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Note: example above is the service registration and discovery based on zookeeper. Users have to launch a zk locally before executing the binary executable file.&lt;/p>
&lt;p>Launch the binary executable file:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>MacdeMacBook-pro-3:target mac$ ./demo-native-provider
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>......
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>INFO: [DUBBO] DubboBootstrap is ready., dubbo version: 2.7.12-SNAPSHOT, current host: 10.220.186.228
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Jun 15, 2021 2:29:14 PM org.apache.dubbo.common.logger.jdk.JdkLogger info
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>INFO: [DUBBO] DubboBootstrap has started., dubbo version: 2.7.12-SNAPSHOT, current host: 10.220.186.228
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Jun 15, 2021 2:29:14 PM org.apache.dubbo.common.logger.jdk.JdkLogger info
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>INFO: [DUBBO] DubboBootstrap awaiting ..., dubbo version: 2.7.12-SNAPSHOT, current host: 10.220.186.228
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Enter consumer&amp;rsquo;s target catalog and execute the binary executable file:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>MacdeMacBook-pro-3:target mac$ ./demo-native-consumer
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Hello dubbo, response from provider: 10.220.186.228:20880
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>All the launches and invokes above finish within one second.&lt;/p>
&lt;h2 id="our-efforts">Our Efforts&lt;/h2>
&lt;h3 id="preparations">Preparations&lt;/h3>
&lt;h4 id="class-initializations-auxiliary-configurations">Class Initialization&amp;rsquo;s Auxiliary Configurations&lt;/h4>
&lt;p>Since native-image is constructed prior to runtime, its construction is dependent on the static analysis of which code is accessible. However, this analysis cannot always fully predict all usages of Java Native Interface (JNI) , reflection, dynamic proxy object or classpath resource. In the format of &lt;code>native-image&lt;/code> configuration file, we need to provide the usages whose dynamic functions are not detected.&lt;/p>
&lt;p>Here we add the following to the JVM parameter:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>-agentlib:native-image-agent=config-output-dir=/path/to/config-dir/
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Parameter above will introduce agent and run the project in the conventional way. Agent will interact with JVM and intercept all invokes that look up classes, methods, fields, resources or request proxy access. Later agent will produce the following files in the specified catalog: &lt;code>jni-config.json&lt;/code>, &lt;code>reflect-config.json&lt;/code>, &lt;code>proxy-config.json&lt;/code> and &lt;code>resource-config.json&lt;/code>, etc.&lt;/p>
&lt;p>Copy the files above into project&amp;rsquo;s resource/META-INF/native-image folder. When native-image compiles, operations regarding JNI, reflection, dynamic proxy and resources will be loaded after finding class information from these json files.&lt;/p>
&lt;p>Note: in reality, since agent detects operations while running and not all logic branches can be covered, some classes&amp;rsquo; json info won&amp;rsquo;t be generated. However, native-image compiles all classes. This will lead to unexpected errors. Currently there&amp;rsquo;s no way for users to distinguish which classes&amp;rsquo; information are lacking until the errors are reported. Lacked info has to be added to json files manually.&lt;/p>
&lt;h4 id="import-native-image-plug-in">Import Native-Image Plug-In&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>&amp;lt;plugin&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;groupId&amp;gt;org.graalvm.nativeimage&amp;lt;/groupId&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;artifactId&amp;gt;native-image-maven-plugin&amp;lt;/artifactId&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;version&amp;gt;21.0.0.2&amp;lt;/version&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;executions&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;execution&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;goals&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;goal&amp;gt;native-image&amp;lt;/goal&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;/goals&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;phase&amp;gt;package&amp;lt;/phase&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;/execution&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;/executions&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;configuration&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;skip&amp;gt;false&amp;lt;/skip&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;imageName&amp;gt;demo-native-provider&amp;lt;/imageName&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;mainClass&amp;gt;org.apache.dubbo.demo.graalvm.provider.Application&amp;lt;/mainClass&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;buildArgs&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --no-fallback
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.slf4j.MDC
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.slf4j.LoggerFactory
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.slf4j.impl.StaticLoggerBinder
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.apache.log4j.helpers.Loader
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.apache.log4j.Logger
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.apache.log4j.helpers.LogLog
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.apache.log4j.LogManager
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.apache.log4j.spi.LoggingEvent
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.slf4j.impl.Log4jLoggerFactory
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-build-time=org.slf4j.impl.Log4jLoggerAdapter
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.epoll.Epoll
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.epoll.Native
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.epoll.EpollEventLoop
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.epoll.EpollEventArray
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.DefaultFileRegion
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.kqueue.KQueueEventArray
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.kqueue.KQueueEventLoop
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.kqueue.Native
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.unix.Errors
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.unix.IovArray
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.unix.Limits
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.util.internal.logging.Log4JLogger
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.unix.Socket
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --initialize-at-run-time=io.netty.channel.ChannelHandlerMask
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --report-unsupported-elements-at-runtime
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --allow-incomplete-classpath
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> --enable-url-protocols=http
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> -H:+ReportExceptionStackTraces
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;/buildArgs&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>After importing the plug-in, native-image command can be automatically executed when executing maven commands such as packaging.&lt;/p>
&lt;h4 id="import-generated-spi-dependency-package">Import Generated SPI Dependency Package&lt;/h4>
&lt;p>SPI mode of dubbo grants huge expandability. It depends on some generated code that are adaptive to extensions. These generated code are not supported by binary images. To deal with this problem, we did the following:&lt;/p>
&lt;ul>
&lt;li>Export generated code&lt;/li>
&lt;/ul>
&lt;p>(Note: here we modified compiler&amp;rsquo;s code in dubbo-common. Detailed explanations will be presented later on.)&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>public Class&amp;lt;?&amp;gt; doCompile(String name, String source) throws Throwable {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.*out*.println(&amp;#34;---&amp;gt;write code:&amp;#34; + name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Files.*write*(Paths.*get*(&amp;#34;/tmp/sources/&amp;#34; + name), source.getBytes());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ......
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>
&lt;p>Copy the exported code into dubbo-graalvm module
&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-graalvm-support/graalvm.png" alt="graalvm.png">&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Import module in new project&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>pom dependency:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>&amp;lt;dependency&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;groupId&amp;gt;org.apache.dubbo&amp;lt;/groupId&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;artifactId&amp;gt;dubbo-graalvm&amp;lt;/artifactId&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &amp;lt;version&amp;gt;2.7.12-SNAPSHOT&amp;lt;/version&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;/dependency&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>(Note: dubbo that depends on this branch can directly add dependency. Other versions with new SPI added needs to update by exporting the source code.)&lt;/p>
&lt;p>After importing dependencies, we can directly find classes using class names during the process of doCompiler without dynamically generating code:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>@Override
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>public Class&amp;lt;?&amp;gt; doCompile(String name, String sourceCode) throws Throwable {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> try {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Class&amp;lt;?&amp;gt; res = Class.*forName*(name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> return res;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } catch (Throwable ex) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> //ignore
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> //......
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>At this point, all dependencies required for native-image compilation are completed. Packaging can generate binary executable file.&lt;/p>
&lt;h4 id="modifications-to-dubbo-source-code">Modifications to Dubbo Source Code&lt;/h4>
&lt;p>Branch is named native_dubbo_0611 and modified based on tag version &lt;a href="https://github.com/apache/dubbo/releases/tag/dubbo-2.7.12">dubbo-2.7.12&lt;/a>. Here we will explain the major modifications.&lt;/p>
&lt;ul>
&lt;li>Avoid dynamically generated code&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>//dubbo-common/src/main/java/org/apache/dubbo/common/compiler/support/JavassistCompiler.java
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>@Override
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>public Class&amp;lt;?&amp;gt; doCompile(String name, String source) throws Throwable {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> try {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Class&amp;lt;?&amp;gt; res = Class.*forName*(name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> return res;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } catch (Throwable ex) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> //ignore
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> CtClassBuilder builder = new CtClassBuilder();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> builder.setClassName(name)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> //......
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>//dubbo-common/src/main/java/org/apache/dubbo/common/compiler/support/JdkCompiler.java
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>@Override
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>public Class&amp;lt;?&amp;gt; doCompile(String name, String sourceCode) throws Throwable {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> try {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Class&amp;lt;?&amp;gt; res = Class.*forName*(name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> return res;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } catch (Throwable ex) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> //ignore
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> int i = name.lastIndexOf(&amp;#39;.&amp;#39;);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String packageName = i &amp;lt; 0 ? &amp;#34;&amp;#34; : name.substring(0, i);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> //......
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Here we modified dubbo&amp;rsquo;s both compilation methods. When compiling source code, first determine if the class, which is, in fact, the generated code in dubbo-graalvm that we imported, is loaded locally based on all class name reflection. The loaded class will be returned after importing the package. No compilation required.&lt;/p>
&lt;ul>
&lt;li>Substitute code generation in ExtensionLoader&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>//dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>private Class&amp;lt;?&amp;gt; createAdaptiveExtensionClass() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> try {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Class c = Class.*forName*(generatePackageInfo() + &amp;#34;.&amp;#34; + type.getSimpleName() + &amp;#34;$Adaptive&amp;#34;);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> return c;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } catch (Throwable e) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> //ignore
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String code = new AdaptiveClassCodeGenerator(type,cachedDefaultName).generate();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> //......
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>private static final String *CODE_PACKAGE* = &amp;#34;%s&amp;#34;;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>private String generatePackageInfo() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> return String.*format*(*CODE_PACKAGE*, type.getPackage().getName());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>ExtensionLoader is the main logic class of the whole extension mechanism. Works such as loading configuration, extension class cache and generating self-adopting objects, are all done in the class.&lt;/p>
&lt;p>getAdaptiveExtension() method automatically creates implementation class String for extension points interface.&lt;/p>
&lt;p>Similar to the first modification mentioned above, since we imported the SPI package, code generation is no longer needed. Requesting local class based on class name will work. Return when the implementation class is found. Notice here that the generated extension class names all end with $Adaptive. When looking for classes, remember to add the suffix.&lt;/p>
&lt;ul>
&lt;li>Substitute Wrapper&amp;rsquo;s usage in Reference/ServiceConfig&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>//dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// String[] methods = Wrapper.getWrapper(interfaceClass).getMethodNames();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String[] methods = Arrays.*stream*(interfaceClass.getMethods()).map(it-&amp;gt;it.getName()).toArray(String[]::new);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> if (methods.length == 0) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> l*ogger*.warn(&amp;#34;No method found in service interface &amp;#34; + interfaceClass.getName());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> map.put(*METHODS_KEY*, *ANY_VALUE*);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> //......
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>//dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// String[] methods = Wrapper.getWrapper(interfaceClass).getMethodNames();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String[] methods = Arrays.*stream*(interfaceClass.getMethods()).map(it-&amp;gt;it.getName()).toArray(String[]::new);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> if (methods.length == 0) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> l*ogger*.warn(&amp;#34;No method found in service interface &amp;#34; + interfaceClass.getName());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> map.put(*METHODS_KEY*, *ANY_VALUE*);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> //......
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Since Wrapper&amp;rsquo;s getWrapper needs to be dynamically generated, here we substitute it by reflected getMethods.&lt;/p>
&lt;ul>
&lt;li>Add dubbo-graalvm module&lt;/li>
&lt;/ul>
&lt;p>dubbo-graalvm&amp;rsquo;s uses have been explained previously.&lt;/p>
&lt;ul>
&lt;li>Substitute fastjson by gson&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>//dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/store/InMemoryWritableMetadataService.java
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>@Override
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>public void publishServiceDefinition(URL providerUrl) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> try {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> if (!ProtocolUtils.*isGeneric*(providerUrl.getParameter(*GENERIC_KEY*))) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String interfaceName = providerUrl.getParameter(*INTERFACE_KEY*);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> if (StringUtils.*isNotEmpty*(interfaceName)) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Class interfaceClass = Class.*forName*(interfaceName);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ServiceDefinition serviceDefinition = ServiceDefinitionBuilder.*build*(interfaceClass);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String data = new Gson().toJson(serviceDefinition);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> serviceDefinitions.put(providerUrl.getServiceKey(), data);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> return;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> //......
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>cglib is used in fastjson for dynamic proxy, but native-image does not support cglib. So here we use gson instead.&lt;/p>
&lt;ul>
&lt;li>Substitute set by list for multiple interface proxy invoke&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">//&lt;/span>dubbo&lt;span style="color:#719e07">-&lt;/span>rpc&lt;span style="color:#719e07">/&lt;/span>dubbo&lt;span style="color:#719e07">-&lt;/span>rpc&lt;span style="color:#719e07">-&lt;/span>api&lt;span style="color:#719e07">/&lt;/span>src&lt;span style="color:#719e07">/&lt;/span>main&lt;span style="color:#719e07">/&lt;/span>java&lt;span style="color:#719e07">/&lt;/span>org&lt;span style="color:#719e07">/&lt;/span>apache&lt;span style="color:#719e07">/&lt;/span>dubbo&lt;span style="color:#719e07">/&lt;/span>rpc&lt;span style="color:#719e07">/&lt;/span>proxy&lt;span style="color:#719e07">/&lt;/span>AbstractProxyFactory&lt;span style="color:#719e07">.&lt;/span>java
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>@Override
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>public &lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> T getProxy(Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> invoker, boolean generic) throws RpcException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> List&lt;span style="color:#719e07">&amp;lt;&lt;/span>Class&lt;span style="color:#719e07">&amp;lt;&lt;/span>?&lt;span style="color:#719e07">&amp;gt;&amp;gt;&lt;/span> interfaces &lt;span style="color:#719e07">=&lt;/span> new ArrayList&lt;span style="color:#719e07">&amp;lt;&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#cb4b16">String&lt;/span> config &lt;span style="color:#719e07">=&lt;/span> invoker&lt;span style="color:#719e07">.&lt;/span>getUrl()&lt;span style="color:#719e07">.&lt;/span>getParameter(&lt;span style="color:#719e07">*&lt;/span>INTERFACES&lt;span style="color:#719e07">*&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (config &lt;span style="color:#719e07">!=&lt;/span> null &lt;span style="color:#719e07">&amp;amp;&amp;amp;&lt;/span> config&lt;span style="color:#719e07">.&lt;/span>length() &lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#2aa198">0&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#cb4b16">String&lt;/span>[] types &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">*&lt;/span>COMMA_SPLIT_PATTERN&lt;span style="color:#719e07">*.&lt;/span>split(config);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (&lt;span style="color:#cb4b16">String&lt;/span> type : types) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">//&lt;/span> &lt;span style="color:#719e07">*&lt;/span>TODO can we &lt;span style="color:#b58900">load&lt;/span> successfully &lt;span style="color:#719e07">for&lt;/span> a different classloader?&lt;span style="color:#719e07">.*&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> interfaces&lt;span style="color:#719e07">.&lt;/span>add(ReflectUtils&lt;span style="color:#719e07">.*&lt;/span>forName&lt;span style="color:#719e07">*&lt;/span>(type));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">//......&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The service here has multiple interfaces which have to be in order when requesting proxy. Set does not fulfill the requirement so we use ArrayList instead.&lt;/p>
&lt;p>Major modifications to dubbo source code are listed above.&lt;/p></description></item><item><title>Blog: Dubbo's Load Balance</title><link>https://dubbo.apache.org/en/blog/2018/08/10/dubbos-load-balance/</link><pubDate>Fri, 10 Aug 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/08/10/dubbos-load-balance/</guid><description>
&lt;h2 id="background">Background&lt;/h2>
&lt;p>Dubbo is a distributed service framework that avoids single point of failure and horizontal expansion of support services. A service typically deploys multiple instances. How to select a call from a cluster of multiple service providers involves a load balancing strategy.&lt;/p>
&lt;h2 id="concepts">Concepts&lt;/h2>
&lt;p>Before discussing load balancing, I will explain these three concepts first.&lt;/p>
&lt;ol>
&lt;li>Load Balancing&lt;/li>
&lt;li>Fault-tolerant Cluster&lt;/li>
&lt;li>Service Route&lt;/li>
&lt;/ol>
&lt;p>These three concepts are confusing. They all describe how to choose from multiple Providers to make calls. So what is the difference between them? Let me give a simple example and explain these concepts clearly.&lt;/p>
&lt;p>There is a Dubbo user service, 10 deployed in Beijing and 20 deployed in Shanghai. A service consumer in Hangzhou initiated a call and then the following steps executed:&lt;/p>
&lt;ol>
&lt;li>According to the configured routing rule, if the call is initiated by Hangzhou, it will be routed to the nearest 20 Providers in Shanghai.&lt;/li>
&lt;li>According to the configured random load balancing strategy, one of the 20 Providers is randomly selected to be called, assuming that the 7th Provider is randomly selected.&lt;/li>
&lt;li>As a result, calling the 7th Provider failed.&lt;/li>
&lt;li>Retried other servers according to the configured Fault-tolerant Cluster mode.&lt;/li>
&lt;li>The call to the 13th Provider was successful.&lt;/li>
&lt;/ol>
&lt;p>Steps 1, 2, and 4 above correspond to routing, load balancing, and fault-tolerant cluster. In Dubbo, a subset is selected by routing from multiple Providers according to routing rules, then a Provider selected from the subset according to load balancing to make this call. If the call fails, Dubbo retry or schedule retransmission or fail-fast according to the Fault-tolerant Cluster policy. You can see the routes in Dubbo, load balancing and Fault-tolerant Cluster exectute at different stages of an RPC call. The first stage is routing, then load balancing, and finally cluster fault tolerance. This document only discusses load balancing, routing and cluster fault tolerance are described in other documents.&lt;/p>
&lt;h2 id="dubbos-internal-load-balancing-strategy">Dubbo&amp;rsquo;s Internal Load Balancing Strategy&lt;/h2>
&lt;p>Dubbo has four Internal Load Balancing Strategies:&lt;/p>
&lt;ol>
&lt;li>RandomLoadBalance: Random load balancing. Choose a Provider randomly. It is Dubbo&amp;rsquo;s default load balancing strategy.&lt;/li>
&lt;li>Round Robin Load Balancing: Polling load balancing, then chooses one Provider.&lt;/li>
&lt;li>LeastActiveLoadBalance: The minimum number of active calls, the random number of the same active number. The active number refers to the difference before and after the call. Make slow providers receive fewer requests, because the slower Provider before and after the difference of calls will be larger.&lt;/li>
&lt;li>ConsistentHashLoadBalance: Consistent hash load balancing. Requests with the same parameters always fall on the same machine.&lt;/li>
&lt;/ol>
&lt;h3 id="1-random-load-balancing">1. Random Load Balancing&lt;/h3>
&lt;p>As the name implies, the random load balancing strategy is to select one from multiple Providers randomly. However, random load balancing in Dubbo has a weighting concept that sets the random probability according to the weight. For example, there are 10 Providers, it&amp;rsquo;s not to say that the probability of each Provider is the same, but to assign the probability by combining the weights of these 10 providers.&lt;/p>
&lt;p>In Dubbo, you can set weights on the Provider. For example, if the performance of the machine is better, you can set a larger weight. If the performance is poorer, you can set a smaller weight. Weights have an impact on load balancing. The weight of provider can be set in Dubbo Admin.&lt;/p>
&lt;h4 id="weight-based-load-balancing-algorithm">Weight-based Load Balancing Algorithm&lt;/h4>
&lt;p>The stochastic strategy will determine whether the weights of all the invokers are the same at first. If they are all the same, then the processing is relatively simple. Using &lt;code>random.nexInt(length)&lt;/code>, you can randomly generate an invoker serial number, and select the corresponding invoker according to the serial number. If the service provider not set weight in Dubbo Admin, then all the invokers have the same weight, the default is 100. If the weights are different, then you need to combine the weights to set the random probability. The algorithm is probably as follows: If there are 4 invokers&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Invoker&lt;/th>
&lt;th>Weight&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>A&lt;/td>
&lt;td>10&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>B&lt;/td>
&lt;td>20&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>C&lt;/td>
&lt;td>20&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>D&lt;/td>
&lt;td>30&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The total weight of A, B, C and D is 10 + 20 + 20 + 30 = 80. Spread 80 numbers in the following diagram:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>+-----------------------------------------------------------------------------------+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>| | | | |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+-----------------------------------------------------------------------------------+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>1 10 30 50 80
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>|-----A----|---------B----------|----------C---------|---------------D--------------|
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---------------------15
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>-------------------------------------------37
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>-----------------------------------------------------------54
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>There are four areas in the above picture, and the lengths are the weights of A, B, C and D, respectively. Use &lt;code>random.nextInt(10 + 20 + 20 + 30)&lt;/code> to randomly select one of the 80 numbers. Then determine which area the number is distributed in. For example, if random to 37, 37 is distributed in the C region, then select inboker C. 15 is in the B area, 54 is in the D area.&lt;/p>
&lt;h4 id="random-load-balancing-source-code">Random load balancing Source code&lt;/h4>
&lt;p>Below is the source code for random load balancing. For ease of reading and understanding, I removed the extraneous parts.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span style="display:flex;">&lt;span>public &lt;span style="color:#719e07">class&lt;/span> RandomLoadBalance &lt;span style="color:#719e07">extends&lt;/span> AbstractLoadBalance {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> private final Random random &lt;span style="color:#719e07">=&lt;/span> new Random();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> protected &lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> doSelect(List&lt;span style="color:#719e07">&amp;lt;&lt;/span>Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&amp;gt;&lt;/span> invokers, URL url, Invocation invocation) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#cb4b16">int&lt;/span> length &lt;span style="color:#719e07">=&lt;/span> invokers&lt;span style="color:#719e07">.&lt;/span>size(); &lt;span style="color:#719e07">//&lt;/span> total invoker
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#cb4b16">int&lt;/span> totalWeight &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">0&lt;/span>; &lt;span style="color:#719e07">//&lt;/span> Sum of invokers&lt;span style="color:#2aa198">&amp;#39; weights&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">//&lt;/span> Determine &lt;span style="color:#719e07">if&lt;/span> all the invokers have the same weight
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">//&lt;/span> If the weights are the same, it is simple to generate an index directly from Random&lt;span style="color:#719e07">.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> boolean sameWeight &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#268bd2">true&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (&lt;span style="color:#cb4b16">int&lt;/span> i &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">0&lt;/span>; i &lt;span style="color:#719e07">&amp;lt;&lt;/span> length; i&lt;span style="color:#719e07">++&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#cb4b16">int&lt;/span> weight &lt;span style="color:#719e07">=&lt;/span> getWeight(invokers&lt;span style="color:#719e07">.&lt;/span>get(i), invocation);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> totalWeight &lt;span style="color:#719e07">+=&lt;/span> weight; &lt;span style="color:#719e07">//&lt;/span> Sum
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (sameWeight &lt;span style="color:#719e07">&amp;amp;&amp;amp;&lt;/span> i &lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#2aa198">0&lt;/span> &lt;span style="color:#719e07">&amp;amp;&amp;amp;&lt;/span> weight &lt;span style="color:#719e07">!=&lt;/span> getWeight(invokers&lt;span style="color:#719e07">.&lt;/span>get(i &lt;span style="color:#719e07">-&lt;/span> &lt;span style="color:#2aa198">1&lt;/span>), invocation)) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> sameWeight &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#268bd2">false&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (totalWeight &lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#2aa198">0&lt;/span> &lt;span style="color:#719e07">&amp;amp;&amp;amp;&lt;/span> &lt;span style="color:#719e07">!&lt;/span>sameWeight) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">//&lt;/span> If &lt;span style="color:#719e07">not&lt;/span> all of the invoker weights are the same, &lt;span style="color:#b58900">load&lt;/span> balancer will randomly choose invoker based on its weight&lt;span style="color:#719e07">.&lt;/span> The greater the weight, the greater the probability of being selected
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#cb4b16">int&lt;/span> offset &lt;span style="color:#719e07">=&lt;/span> random&lt;span style="color:#719e07">.&lt;/span>nextInt(totalWeight);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (&lt;span style="color:#cb4b16">int&lt;/span> i &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">0&lt;/span>; i &lt;span style="color:#719e07">&amp;lt;&lt;/span> length; i&lt;span style="color:#719e07">++&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> offset &lt;span style="color:#719e07">-=&lt;/span> getWeight(invokers&lt;span style="color:#719e07">.&lt;/span>get(i), invocation);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (offset &lt;span style="color:#719e07">&amp;lt;&lt;/span> &lt;span style="color:#2aa198">0&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> invokers&lt;span style="color:#719e07">.&lt;/span>get(i);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">//&lt;/span> If all invokers have the same weight
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> invokers&lt;span style="color:#719e07">.&lt;/span>get(random&lt;span style="color:#719e07">.&lt;/span>nextInt(length));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="2-round-robin-load-balancing">2. Round Robin Load Balancing&lt;/h3>
&lt;p>Round Robin Load Balancing, is to call all Providers in turn. As with random load balancing strategies, Round Robin Load Balancing policies also has a weighting concept. The Round Robin Load Balancing algorithm allows RPC calls to be allocated exactly as we set. Whether it is a small or large number of calls. However, there are also some shortcomings in the Round Robin Load Balancing algorithm. There is a problem that the slow provider accumulates the request. For example, the second machine is slow, but it is not crashed. When the request is transferred to the second machine, it is stuck. Over time, all The request get stuck on the second machine, causing the entire system to slow down.&lt;/p>
&lt;h3 id="3-minimum-active-call-load-balancing">3. Minimum Active Call Load Balancing&lt;/h3>
&lt;p>Official explanation:&lt;/p>
&lt;blockquote>
&lt;p>The active number refers to the difference between the counts before and after the call. Select the machine with the minimum number of active calls or choose a random one among machines with the same active number, so that the slower machine can receives less requests.&lt;/p>
&lt;/blockquote>
&lt;p>This explanation seems to be ambigious. We know the purpose is to ensure the slower machine receive less requests, but it is not clear how to achieve it. An example is here: each service maintains an active number counter. When A machine starts processing the request, the counter is incremented by 1. At this time, A is still processing. If the processing is completed, the counter is decremented by 1. B machine processes very quickly after receiving the request. Then the active numbers of A and B are 1,0 respectively. When a new request is generated, the B machine is selected for execution (as B has the minimum active number), so that the slower machine A receives fewer requests.&lt;/p>
&lt;p>When processing a new request, Consumer will check the active number of all Providers. If there is only one Invoker with the minimum active number, the Invoker is returned directly.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>if (leastCount == 1) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> // if there is only one minimum value then return directly
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> return invokers.get(leastIndexs[0]);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>If there are multiple Invokers with the minimum active number, plus the weights are not equal and the total weight is greater than 0, then generate a random weight ranging from 0 to totalWeight. Finally, the Invoker is selected based on the randomly generated weights.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>if (! sameWeight &amp;amp;&amp;amp; totalWeight &amp;gt; 0) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> // if the weights are not equal and the toatl weight is greater than 0 then choose randomly according to total weight
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> int offsetWeight = random.nextInt(totalWeight);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> // and determine which segment the random value falls on.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> for (int i = 0; i &amp;lt; leastCount; i++) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> int leastIndex = leastIndexs[i];
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> offsetWeight -= getWeight(invokers.get(leastIndex), invocation);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> if (offsetWeight &amp;lt;= 0)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> return invokers.get(leastIndex);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="4-consistent-hash-algorithm">4. Consistent Hash Algorithm&lt;/h3>
&lt;p>Use consistent hash algorithm to ensure that requests with same parameters are always sent to the same Provider. When a Provider crashes, requests originally sent to the Provider is spread evenly to other Providers based on the virtual node without causing drastic changes. The algorithm can be seen at: &lt;a href="http://en.wikipedia.org/wiki/Consistent_hashing">http://en.wikipedia.org/wiki/Consistent_hashing&lt;/a>&lt;/p>
&lt;p>By default, only the first parameter is hashed. Configure if you would like to modify it:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>&amp;lt;dubbo:parameter key=&amp;#34;hash.arguments&amp;#34; value=&amp;#34;0,1&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>By default, 160 virtual nodes are used. Configure if you would like to modify it:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>&amp;lt;dubbo:parameter key=&amp;#34;hash.nodes&amp;#34; value=&amp;#34;320&amp;#34; /&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Consistent hash algorithms can be used in conjunction with caching mechanisms. For example, there is a service getUserInfo(String userId). After the hash algorithm is set, the same userId call is sent to the same Provider. This Provider can cache user data in memory, reducing the number of accesses to the database or distributed cache. If this part of the data is allowed to be inconsistent for some time, this approach can be considered. The number of dependencies and accesses to middleware such as databases, caches, etc. and network IO operations is reduced, while the system performance is improved.&lt;/p>
&lt;h2 id="load-balancing-configuration">Load Balancing Configuration&lt;/h2>
&lt;p>If load balancing is not specified, random load balancing is used by default. Load balancing can also be explicitly specified based on our needs. Load balancing can be configured in multiple local classes, such as Provider Side, Consumer Side, Service Level, and Method Level.&lt;/p>
&lt;h3 id="server-side-service-level">Server Side Service Level&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;&lt;/span>dubbo:service interface&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;...&amp;#34;&lt;/span> loadbalance&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;roundrobin&amp;#34;&lt;/span> &lt;span style="color:#719e07">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>All methods of the service use roundrobin load balancing.&lt;/p>
&lt;h3 id="client-side-service-level">Client Side Service Level&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;&lt;/span>dubbo:reference interface&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;...&amp;#34;&lt;/span> loadbalance&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;roundrobin&amp;#34;&lt;/span> &lt;span style="color:#719e07">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>All methods of the service use roundrobin load balancing.&lt;/p>
&lt;h3 id="server-side-method-level">Server Side Method Level&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;&lt;/span>dubbo:service interface&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;...&amp;#34;&lt;/span>&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>dubbo:method name&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;hello&amp;#34;&lt;/span> loadbalance&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;roundrobin&amp;#34;&lt;/span>&lt;span style="color:#719e07">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;/&lt;/span>dubbo:service&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Only the hello method of the service uses roundrobin load balancing.&lt;/p>
&lt;h3 id="client-side-method-level">Client Side Method Level&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;&lt;/span>dubbo:reference interface&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;...&amp;#34;&lt;/span>&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>dubbo:method name&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;hello&amp;#34;&lt;/span> loadbalance&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;roundrobin&amp;#34;&lt;/span>&lt;span style="color:#719e07">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;/&lt;/span>dubbo:reference&lt;span style="color:#719e07">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Only the hello method of the service uses roundrobin load balancing.&lt;/p>
&lt;p>Similar to other Dubbo configurations, multiple configurations are covered:&lt;/p>
&lt;ol>
&lt;li>The method level takes precedence, the interface level is next, and the global configuration comes last.&lt;/li>
&lt;li>If the level is the same, the Consumer is given priority and the Provider is next&lt;/li>
&lt;/ol>
&lt;p>Therefore, the priority of the above four configurations is:&lt;/p>
&lt;ol>
&lt;li>Client side method level configuration.&lt;/li>
&lt;li>Client side interface level configuration.&lt;/li>
&lt;li>Server side method level configuration.&lt;/li>
&lt;li>Server side interface level configuration.&lt;/li>
&lt;/ol>
&lt;h2 id="extended-load-balancing">Extended Load Balancing&lt;/h2>
&lt;p>Four load balancing implementations of Dubbo meet the requirements in most cases. Sometimes, we may need to implement our own load balancing strategy because of the needs of the business. This chapter only explains how to configure the load balancing algorithm. For more on the Dubbo extension mechanism, go to the Dubbo extension mechanism practice.&lt;/p>
&lt;ol>
&lt;li>Implementing the LoadBalance interface&lt;/li>
&lt;/ol>
&lt;p>The following is Dubbo&amp;rsquo;s LoadBalance interface:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span style="display:flex;">&lt;span>@SPI(RandomLoadBalance&lt;span style="color:#719e07">.&lt;/span>NAME)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>public interface LoadBalance {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> @Adaptive(&lt;span style="color:#2aa198">&amp;#34;loadbalance&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> select(List&lt;span style="color:#719e07">&amp;lt;&lt;/span>Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&amp;gt;&lt;/span> invokers, URL url, Invocation invocation) throws RpcException;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This is the interface of the SPI. The parameters of the select method are as follows:&lt;/p>
&lt;ul>
&lt;li>invokers: A list of all service Providers.&lt;/li>
&lt;li>url: Some configuration information, such as interface name, check or not, serialization.&lt;/li>
&lt;li>invocation: Information called by the RPC, including the method name, method parameter type, and method parameters. Here is a LoadBalance implemented by us. The implementation is very simple - Choose the first Invoker:&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-go" data-lang="go">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> com.demo.dubbo;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>public class DemoLoadBalance implements LoadBalance {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> @Override
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> public &amp;lt;T&amp;gt; Invoker&amp;lt;T&amp;gt; &lt;span style="color:#719e07">select&lt;/span>(List&amp;lt;Invoker&amp;lt;T&lt;span style="color:#719e07">&amp;gt;&amp;gt;&lt;/span> invokers, URL url, Invocation invocation) throws RpcException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.&lt;span style="color:#b58900">println&lt;/span>(&lt;span style="color:#2aa198">&amp;#34;[DemoLoadBalance]Select the first invoker...&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> invokers.&lt;span style="color:#268bd2">get&lt;/span>(&lt;span style="color:#2aa198">0&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="2">
&lt;li>Add a resource file&lt;/li>
&lt;/ol>
&lt;p>Add a file:
&lt;code>src/main/resource/META-INF/dubbo/com.alibaba.dubbo.rpc.cluster.LoadBalance&lt;/code>
This is a simple text file. The file contents are as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>demo=my=com.demo.dubbo.DemoLoadBalance
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="3">
&lt;li>Configure to use custom LoadBalance&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;&lt;/span>dubbo:reference id&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;helloService&amp;#34;&lt;/span> interface&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;com.demo.dubbo.api.IHelloService&amp;#34;&lt;/span> loadbalance&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;demo&amp;#34;&lt;/span> &lt;span style="color:#719e07">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Configure &lt;code>&amp;lt;loadbalance=&amp;quot;demo&amp;quot;&amp;gt;&lt;/code> in &lt;code>dubbo:reference&lt;/code> at the Consumer side.&lt;/p>
&lt;p>After 3 steps above, we wrote a custom LoadBalance and told Dubbo to use it. Start Dubbo and we can see that Dubbo has used a custom DemoLoadBalance.&lt;/p></description></item><item><title>Blog: Use Annotations In Dubbo</title><link>https://dubbo.apache.org/en/blog/2018/08/07/use-annotations-in-dubbo/</link><pubDate>Tue, 07 Aug 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/08/07/use-annotations-in-dubbo/</guid><description>
&lt;p>With the widely promotion and implementation of Microservices Architecture, the Microservices Architecture represented by Spring Boot and Spring Cloud, in Java ecosystem, introduced some brand new programming model, like:&lt;/p>
&lt;ul>
&lt;li>Annotation-Driven&lt;/li>
&lt;li>External Configuration&lt;/li>
&lt;li>Auto-Configure&lt;/li>
&lt;/ul>
&lt;p>New programming model have some advantages, for example, it does not require &lt;code>XML&lt;/code> configuration, it can simplify deployment process, beyond that,it can promote development efficiency. In order to implement the microservice architecture better,Dubbo has provided more perfect support for the above three scenarios since version 2.5.8. This article focuses on introduce annotations rather than discuss the traditional XML configuration approach. There are two kinds of automatic assembly, external configuration and automatic assembly, will be introduced in another aricle.&lt;/p>
&lt;h2 id="introduce-annotations">Introduce Annotations&lt;/h2>
&lt;h3 id="enabledubbo">@EnableDubbo&lt;/h3>
&lt;p>The annotations of &lt;code>@EnableDubbo&lt;/code> is a combination of both &lt;code>@EnableDubboConfig&lt;/code> and &lt;code>@DubboComponentScan&lt;/code>.Related to the annotation driver is &lt;code>@DubboComponentScan&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> org.apache.dubbo.config.spring.context.annotation;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@EnableDubboConfig&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@DubboComponentScan&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">@interface&lt;/span> EnableDubbo {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * Base packages to scan for annotated @Service classes.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * &amp;lt;p&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * Use {@link #scanBasePackageClasses()} for a type-safe alternative to String-based
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * package names.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> *
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * @return the base packages to scan
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * @see DubboComponentScan#basePackages()
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@AliasFor&lt;/span>(annotation &lt;span style="color:#719e07">=&lt;/span> DubboComponentScan.class, attribute &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;basePackages&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String&lt;span style="color:#719e07">[]&lt;/span> &lt;span style="color:#268bd2">scanBasePackages&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> {};
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * Type-safe alternative to {@link #scanBasePackages()} for specifying the packages to
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * scan for annotated @Service classes. The package of each class specified will be
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * scanned.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> *
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * @return classes from the base packages to scan
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> * @see DubboComponentScan#basePackageClasses
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@AliasFor&lt;/span>(annotation &lt;span style="color:#719e07">=&lt;/span> DubboComponentScan.class, attribute &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;basePackageClasses&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;[]&lt;/span> scanBasePackageClasses() &lt;span style="color:#719e07">default&lt;/span> {};
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The &lt;code>@bableDubbo&lt;/code> can be used to scan Dubbo&amp;rsquo;s service provider (marked by &lt;code>@Service&lt;/code>) and Dubbo&amp;rsquo;s service consumer (marked by &lt;code>Reference&lt;/code>) under the specified package name (via &lt;code>scanBasePackages&lt;/code>) or in the specified class (via &lt;code>scanBasePackageClasses&lt;/code>). After Dubbo&amp;rsquo;s service providers and consumers have been scanned, they have been assembled corresponding and been initialized, and finally the service is exposed or referenced, if you do not use &lt;code>External Configuration&lt;/code>, you can use &lt;code>@DubboComponentScan&lt;/code> directly.&lt;/p>
&lt;h3 id="service">@Service&lt;/h3>
&lt;p>&lt;code>@service&lt;/code> is used to configure Dubbo&amp;rsquo;s Service provider,for example:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Service&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">AnnotatedGreetingService&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> GreetingService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;hello, &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Via &lt;code>@Service&lt;/code>&amp;rsquo;s properties, you can customize Dubbo&amp;rsquo;s Service provider:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> org.apache.dubbo.config.annotation;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Documented&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Retention&lt;/span>(RetentionPolicy.RUNTIME)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Target&lt;/span>({ElementType.TYPE}) &lt;span style="color:#586e75">// #1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Inherited&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">@interface&lt;/span> Service {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&lt;/span> interfaceClass() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#dc322f">void&lt;/span>.class; &lt;span style="color:#586e75">// #2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">interfaceName&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #3&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">version&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #4&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">group&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #5&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#dc322f">boolean&lt;/span> &lt;span style="color:#268bd2">export&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#cb4b16">true&lt;/span>; &lt;span style="color:#586e75">// #6&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#dc322f">boolean&lt;/span> &lt;span style="color:#268bd2">register&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#cb4b16">true&lt;/span>; &lt;span style="color:#586e75">// #7&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">application&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #8&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">module&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #9&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">provider&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #10&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String&lt;span style="color:#719e07">[]&lt;/span> &lt;span style="color:#268bd2">protocol&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> {}; &lt;span style="color:#586e75">// #11&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">monitor&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #12&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String&lt;span style="color:#719e07">[]&lt;/span> &lt;span style="color:#268bd2">registry&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> {}; &lt;span style="color:#586e75">// #13&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Which is more important:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>@Service&lt;/strong>: Can only be defined on a class, represent a service&lt;/li>
&lt;li>&lt;strong>interfaceClass&lt;/strong>: specified &lt;code>interface&lt;/code>&amp;rsquo;s class implemented by the service provider&lt;/li>
&lt;li>&lt;strong>interfaceName&lt;/strong>: specified &lt;code>interface&lt;/code>&amp;rsquo;s class name implemented by the service provider&lt;/li>
&lt;li>&lt;strong>version&lt;/strong>: specified the version number of the service&lt;/li>
&lt;li>&lt;strong>group&lt;/strong>:specified the group of services&lt;/li>
&lt;li>&lt;strong>export&lt;/strong>:whether to expose service&lt;/li>
&lt;li>&lt;strong>registry&lt;/strong>:Whether to register service to the registry&lt;/li>
&lt;li>&lt;strong>application&lt;/strong>:application configuration&lt;/li>
&lt;li>&lt;strong>module&lt;/strong>:module configuration&lt;/li>
&lt;li>&lt;strong>provider&lt;/strong>:service provider configuration&lt;/li>
&lt;li>&lt;strong>protocol&lt;/strong>:protocol configuration&lt;/li>
&lt;li>&lt;strong>monitor&lt;/strong>:monitoring center configuration&lt;/li>
&lt;li>&lt;strong>registr&lt;/strong>:registry configuration&lt;/li>
&lt;/ol>
&lt;p>In addition, it should be noted that, &lt;code>application&lt;/code>, &lt;code>module&lt;/code>, &lt;code>provider&lt;/code>, &lt;code>protocol&lt;/code>, &lt;code>monitor&lt;/code>, &lt;code>registry&lt;/code> (from 8 to 13) need to provide the name of the corresponding &lt;code>spring bean&lt;/code>,These bean assembly completed either through traditional XML configuration,or by the modern Java Config. This article will show you how to use &lt;code>Java Config&lt;/code>.&lt;/p>
&lt;h3 id="reference">@Reference&lt;/h3>
&lt;p>&lt;code>@Reference&lt;/code> is used to configure Dubbo&amp;rsquo;s Service consumer,for example:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-Java" data-lang="Java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Component&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">GreetingServiceConsumer&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Reference&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> GreetingService greetingService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">doSayHello&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> greetingService.sayHello(name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Via &lt;code>@Reference&lt;/code>&amp;rsquo;s properties, you can customize Dubbo&amp;rsquo;s Service consumer:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-Java" data-lang="Java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> org.apache.dubbo.config.annotation;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Documented&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Retention&lt;/span>(RetentionPolicy.RUNTIME)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Target&lt;/span>({ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE}) &lt;span style="color:#586e75">// #1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">@interface&lt;/span> Reference {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Class&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&lt;/span> interfaceClass() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#dc322f">void&lt;/span>.class; &lt;span style="color:#586e75">// #2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">interfaceName&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #3&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">version&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #4&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">group&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #5&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">url&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #6&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">application&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #7&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">module&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #8&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">consumer&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #9&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">protocol&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #10&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">monitor&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> &lt;span style="color:#2aa198">&amp;#34;&amp;#34;&lt;/span>; &lt;span style="color:#586e75">// #11&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String&lt;span style="color:#719e07">[]&lt;/span> &lt;span style="color:#268bd2">registry&lt;/span>() &lt;span style="color:#719e07">default&lt;/span> {}; &lt;span style="color:#586e75">// #12&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Which is more important:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>@Reference&lt;/strong>:you can define it on a field in a class, you can define it on a method, you can even modify another annotation, it represent a reference to a service.Normally &lt;code>@Reference&lt;/code> is defined in one field&lt;/li>
&lt;li>&lt;strong>interfaceClass&lt;/strong> : specified &lt;code>interface&lt;/code>&amp;rsquo;s class implemented by the service provider&lt;/li>
&lt;li>&lt;strong>interfaceName&lt;/strong>: specified &lt;code>interface&lt;/code>&amp;rsquo;s class name implemented by the service provider&lt;/li>
&lt;li>&lt;strong>version&lt;/strong>: specified the version number of the service&lt;/li>
&lt;li>&lt;strong>group&lt;/strong>:pecified the group of services&lt;/li>
&lt;li>&lt;strong>url&lt;/strong>: invoking the registry directly by specifying the URL of the service provider&lt;/li>
&lt;li>&lt;strong>application&lt;/strong>:application configuration&lt;/li>
&lt;li>&lt;strong>module&lt;/strong>:module configuration&lt;/li>
&lt;li>&lt;strong>consumer&lt;/strong>:service consumer configuration&lt;/li>
&lt;li>&lt;strong>protocol&lt;/strong>:protocol configuration&lt;/li>
&lt;li>&lt;strong>monitor&lt;/strong>:monitoring center configuration&lt;/li>
&lt;li>&lt;strong>registr&lt;/strong>:registry configuration&lt;/li>
&lt;/ol>
&lt;p>In addition, it should be noted that, &lt;code>application&lt;/code>, &lt;code>module&lt;/code>, &lt;code>consumer&lt;/code>, &lt;code>protocol&lt;/code>, &lt;code>monitor&lt;/code>, &lt;code>registry&lt;/code> (from 7 to 12) need to provide the name of the corresponding &lt;code>spring bean&lt;/code>,These bean assembly completed either through traditional XML configuration,or by the modern Java Config. This article will show you how to use &lt;code>Java Config&lt;/code>.&lt;/p>
&lt;h2 id="example-practice">Example practice&lt;/h2>
&lt;p>After learn what &lt;code>@EnableDubbo&lt;/code>, &lt;code>@Service&lt;/code>, &lt;code>@Reference&lt;/code> is, there is a practical example showing how to use the annotation to develop a Dubbo application.The following code can be found at &lt;a href="https://github.com/dubbo/dubbo-samples/tree/master/1-basic/dubbo-samples-annotation">https://github.com/dubbo/dubbo-samples/tree/master/1-basic/dubbo-samples-annotation&lt;/a>&lt;/p>
&lt;h3 id="1interface-definition">1.Interface Definition&lt;/h3>
&lt;p>Define a simple &lt;code>GreetingService&lt;/code> interface with only a simple method &lt;code>sayHello&lt;/code> to the caller.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-Java" data-lang="Java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">GreetingService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="2serverservice-implementation">2.Server:Service Implementation&lt;/h3>
&lt;p>Implement the &lt;code>GreetingService&lt;/code> interface, and mark it as a service for Dubbo via @Service.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-Java" data-lang="Java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Service&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">AnnotatedGreetingService&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> GreetingService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;hello, &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="3serverassembly-service-provider">3.Server:Assembly Service Provider&lt;/h3>
&lt;p>You can discover, assemble, and provide Dubbo&amp;rsquo;s services through the Java config technology (@Configuration) and annotation scan (@EnableDubbo) in Spring.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-Java" data-lang="Java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Configuration&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@EnableDubbo&lt;/span>(scanBasePackages &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.impl&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">ProviderConfiguration&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Bean&lt;/span> &lt;span style="color:#586e75">// #1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> ProviderConfig &lt;span style="color:#268bd2">providerConfig&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ProviderConfig providerConfig &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ProviderConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> providerConfig.setTimeout(1000);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> providerConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Bean&lt;/span> &lt;span style="color:#586e75">// #2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> ApplicationConfig &lt;span style="color:#268bd2">applicationConfig&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ApplicationConfig applicationConfig &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ApplicationConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> applicationConfig.setName(&lt;span style="color:#2aa198">&amp;#34;dubbo-annotation-provider&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> applicationConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Bean&lt;/span> &lt;span style="color:#586e75">// #3&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> RegistryConfig &lt;span style="color:#268bd2">registryConfig&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> RegistryConfig registryConfig &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> RegistryConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> registryConfig.setProtocol(&lt;span style="color:#2aa198">&amp;#34;zookeeper&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> registryConfig.setAddress(&lt;span style="color:#2aa198">&amp;#34;localhost&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> registryConfig.setPort(2181);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> registryConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Bean&lt;/span> &lt;span style="color:#586e75">// #4&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> ProtocolConfig &lt;span style="color:#268bd2">protocolConfig&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ProtocolConfig protocolConfig &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ProtocolConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> protocolConfig.setName(&lt;span style="color:#2aa198">&amp;#34;dubbo&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> protocolConfig.setPort(20880);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> protocolConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Description:&lt;/p>
&lt;ul>
&lt;li>Scan all classes marked with &lt;code>@Service&lt;/code> under &lt;code>com.alibaba.dubbo.samples.impl&lt;/code> with &lt;code>@EnableDubbo&lt;/code>&lt;/li>
&lt;li>Via @Configuration, all @Beans in the ProviderConfiguration are assembled using the way of &lt;code>Java Config&lt;/code> and then injected into the Dubbo service, which means the class marked with &lt;code>@Service&lt;/code>.Which included:
i. &lt;strong>ProviderConfig&lt;/strong>:Service provider configuration
ii. &lt;strong>ApplicationConfig&lt;/strong>:Application configuration
iii.&lt;strong>RegistryConfig&lt;/strong>:registry configuration
iv. &lt;strong>ProtocolConfig&lt;/strong>:Protocol configuration&lt;/li>
&lt;/ul>
&lt;h3 id="4serverstart-service">4.Server:Start Service&lt;/h3>
&lt;p>In the &lt;code>main&lt;/code> method to provide external &lt;code>Dubbo&lt;/code> service by starting a &lt;code>Spring Context&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-Java" data-lang="Java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">ProviderBootstrap&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) &lt;span style="color:#268bd2">throws&lt;/span> Exception {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">new&lt;/span> EmbeddedZooKeeper(2181, &lt;span style="color:#cb4b16">false&lt;/span>).start(); &lt;span style="color:#586e75">// #1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> AnnotationConfigApplicationContext context &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> AnnotationConfigApplicationContext(ProviderConfiguration.class); &lt;span style="color:#586e75">// #2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.start(); &lt;span style="color:#586e75">// #3&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.in.read(); &lt;span style="color:#586e75">// #4&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Description:&lt;/p>
&lt;ol>
&lt;li>Start an embedded &lt;code>zookeeper&lt;/code> and provide service registry on port &lt;code>2181&lt;/code>&lt;/li>
&lt;li>Initialize an example of an AnnotationConfigApplicationContext and pass the &lt;code>ProviderConfiguration&lt;/code> into the example to complete the automatic discovery and assembly of the &lt;code>Dubbo&lt;/code> service.&lt;/li>
&lt;li>Start the &lt;code>Spring Context&lt;/code> and start providing external &lt;code>Dubbo&lt;/code> services.&lt;/li>
&lt;li>Because it is a server, you need to prevent the process exit by blocking the main thread.&lt;/li>
&lt;/ol>
&lt;p>Start the &lt;code>main&lt;/code> method of the server, you will see the following output, on behalf of the server startup success, and registered the &lt;code>GreetingService&lt;/code> service in the &lt;code>ZookeeperRegistry&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>01/08/18 02:12:51:051 CST&lt;span style="color:#719e07">]&lt;/span> main INFO transport.AbstractServer: &lt;span style="color:#719e07">[&lt;/span>DUBBO&lt;span style="color:#719e07">]&lt;/span> Start NettyServer &lt;span style="color:#b58900">bind&lt;/span> /0.0.0.0:20880, &lt;span style="color:#b58900">export&lt;/span> /192.168.99.1:20880, dubbo version: 2.6.2, current host: 192.168.99.1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>01/08/18 02:12:51:051 CST&lt;span style="color:#719e07">]&lt;/span> main INFO zookeeper.ZookeeperRegistry: &lt;span style="color:#719e07">[&lt;/span>DUBBO&lt;span style="color:#719e07">]&lt;/span> Register: dubbo://192.168.99.1:20880/com.alibaba.dubbo.samples.api.GreetingService?anyhost&lt;span style="color:#719e07">=&lt;/span>true&amp;amp;&lt;span style="color:#268bd2">application&lt;/span>&lt;span style="color:#719e07">=&lt;/span>dubbo-annotation-provider&amp;amp;default.timeout&lt;span style="color:#719e07">=&lt;/span>1000&amp;amp;&lt;span style="color:#268bd2">dubbo&lt;/span>&lt;span style="color:#719e07">=&lt;/span>2.6.2&amp;amp;&lt;span style="color:#268bd2">generic&lt;/span>&lt;span style="color:#719e07">=&lt;/span>false&amp;amp;&lt;span style="color:#268bd2">interface&lt;/span>&lt;span style="color:#719e07">=&lt;/span>com.alibaba.dubbo.samples.api
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="5serverreference-service">5.Server:Reference Service&lt;/h3>
&lt;p>Marking the member variable of the &lt;code>GreetingService&lt;/code> via &lt;code>@Reference&lt;/code> .The &lt;code>greetingService&lt;/code> is a reference to the &lt;code>Dubbo&lt;/code> service, which means that it can simply provide through the interface to the remote party to initiate service calls, and the client does not implement &lt;code>GreetingService&lt;/code> interface.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-Java" data-lang="Java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Component&lt;/span>(&lt;span style="color:#2aa198">&amp;#34;annotatedConsumer&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">GreetingServiceConsumer&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Reference&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> GreetingService greetingService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">doSayHello&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> greetingService.sayHello(name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="6serverassembly-service-consumer">6.Server:Assembly Service consumer&lt;/h3>
&lt;p>Just like &lt;strong>3. Server:Assembly Service Provider&lt;/strong> You can discover, assemble, and provide Dubbo&amp;rsquo;s service consumer through the Java config technology (@Configuration) and annotation scan (@EnableDubbo) in Spring.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-Java" data-lang="Java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Configuration&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@EnableDubbo&lt;/span>(scanBasePackages &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.action&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@ComponentScan&lt;/span>(value &lt;span style="color:#719e07">=&lt;/span> {&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.action&amp;#34;&lt;/span>})
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">ConsumerConfiguration&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Bean&lt;/span> &lt;span style="color:#586e75">// #1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> ApplicationConfig &lt;span style="color:#268bd2">applicationConfig&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ApplicationConfig applicationConfig &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ApplicationConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> applicationConfig.setName(&lt;span style="color:#2aa198">&amp;#34;dubbo-annotation-consumer&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> applicationConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Bean&lt;/span> &lt;span style="color:#586e75">// #2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> ConsumerConfig &lt;span style="color:#268bd2">consumerConfig&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ConsumerConfig consumerConfig &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ConsumerConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> consumerConfig.setTimeout(3000);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> consumerConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Bean&lt;/span> &lt;span style="color:#586e75">// #3&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> RegistryConfig &lt;span style="color:#268bd2">registryConfig&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> RegistryConfig registryConfig &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> RegistryConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> registryConfig.setProtocol(&lt;span style="color:#2aa198">&amp;#34;zookeeper&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> registryConfig.setAddress(&lt;span style="color:#2aa198">&amp;#34;localhost&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> registryConfig.setPort(2181);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> registryConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Description:&lt;/p>
&lt;ul>
&lt;li>Scan all classes marked with &lt;code>@Service&lt;/code> under &lt;code>com.alibaba.dubbo.samples.impl&lt;/code> with &lt;code>@Reference&lt;/code>&lt;/li>
&lt;li>Via @Configuration, all @Beans in the ProviderConfiguration are assembled using the way of &lt;code>Java Config&lt;/code> and then injected into the Dubbo service, which means the class marked with &lt;code>@Reference&lt;/code>.Which included:
i. &lt;code>ApplicationConfig&lt;/code>: Application configuration
ii. &lt;code>ConsumerConfig&lt;/code>:Service consumer configuration
iii.&lt;code>RegistryConfig&lt;/code>:Registry configuration.Note:The configuration here needs to be consistent with the configuration information of the EmbeddedZooKeeper when started by the service provider.&lt;/li>
&lt;/ul>
&lt;h3 id="7server-initiate-remote-calls">7.Server: Initiate Remote Calls&lt;/h3>
&lt;p>In the &lt;code>main&lt;/code> method, you can start a &lt;code>Spring Context&lt;/code> to find the service consumer of the assembled &lt;code>Dubbo&lt;/code> from it, and initiate a remote call.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-Java" data-lang="Java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">ConsumerBootstrap&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> AnnotationConfigApplicationContext context &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> AnnotationConfigApplicationContext(ConsumerConfiguration.class); &lt;span style="color:#586e75">// #1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.start(); &lt;span style="color:#586e75">// #2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> GreetingServiceConsumer greetingServiceConsumer &lt;span style="color:#719e07">=&lt;/span> context.getBean(GreetingServiceConsumer.class); &lt;span style="color:#586e75">// #3&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String hello &lt;span style="color:#719e07">=&lt;/span> greetingServiceConsumer.doSayHello(&lt;span style="color:#2aa198">&amp;#34;annotation&amp;#34;&lt;/span>); &lt;span style="color:#586e75">// #4&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;result: &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> hello); &lt;span style="color:#586e75">// #5&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Description:&lt;/p>
&lt;ul>
&lt;li>Initialize an example of an AnnotationConfigApplicationContext and pass the &lt;code>ProviderConfiguration&lt;/code> into the example to complete the automatic discovery and assembly of the &lt;code>Dubbo&lt;/code> service consumer.&lt;/li>
&lt;li>start &lt;code>Spring Context&lt;/code>.&lt;/li>
&lt;li>Find &lt;code>bean&lt;/code> which type is &lt;code>GreetingServiceConsumer&lt;/code> from &lt;code>Context&lt;/code>.&lt;/li>
&lt;li>Call the &lt;code>doSayHello&lt;/code> method and finally initiate a remote call via Dubbo&amp;rsquo;s service reference (marked by @Reference)&lt;/li>
&lt;li>Print call result
Start the Server&amp;rsquo;s &lt;code>main&lt;/code> method, you will see the following output, which returns the &lt;code>result&lt;/code>: hello, annotation:&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>01/08/18 02:38:40:040 CST&lt;span style="color:#719e07">]&lt;/span> main INFO config.AbstractConfig: &lt;span style="color:#719e07">[&lt;/span>DUBBO&lt;span style="color:#719e07">]&lt;/span> Refer dubbo service com.alibaba.dubbo.samples.api.GreetingService from url zookeeper://localhost:2181/com.alibaba.dubbo.registry.RegistryService?anyhost&lt;span style="color:#719e07">=&lt;/span>true&amp;amp;&lt;span style="color:#268bd2">application&lt;/span>&lt;span style="color:#719e07">=&lt;/span>dubbo-annotation-consumer&amp;amp;&lt;span style="color:#268bd2">check&lt;/span>&lt;span style="color:#719e07">=&lt;/span>false&amp;amp;default.timeout&lt;span style="color:#719e07">=&lt;/span>3000&amp;amp;&lt;span style="color:#268bd2">dubbo&lt;/span>&lt;span style="color:#719e07">=&lt;/span>2.6.2&amp;amp;&lt;span style="color:#268bd2">generic&lt;/span>&lt;span style="color:#719e07">=&lt;/span>false&amp;amp;&lt;span style="color:#268bd2">interface&lt;/span>&lt;span style="color:#719e07">=&lt;/span>com.alibaba.dubbo.samples.api.GreetingService&amp;amp;&lt;span style="color:#268bd2">methods&lt;/span>&lt;span style="color:#719e07">=&lt;/span>sayHello&amp;amp;&lt;span style="color:#268bd2">pid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>33001&amp;amp;register.ip&lt;span style="color:#719e07">=&lt;/span>192.168.99.1&amp;amp;remote.timestamp&lt;span style="color:#719e07">=&lt;/span>1533105502086&amp;amp;&lt;span style="color:#268bd2">side&lt;/span>&lt;span style="color:#719e07">=&lt;/span>consumer&amp;amp;&lt;span style="color:#268bd2">timestamp&lt;/span>&lt;span style="color:#719e07">=&lt;/span>1533105519216, dubbo version: 2.6.2, current host: 192.168.99.1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>01/08/18 02:38:40:040 CST&lt;span style="color:#719e07">]&lt;/span> main INFO annotation.ReferenceBeanBuilder: &amp;lt;dubbo:reference &lt;span style="color:#268bd2">object&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.common.bytecode.proxy0@673be18f&amp;#34;&lt;/span> &lt;span style="color:#268bd2">singleton&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;true&amp;#34;&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.api.GreetingService&amp;#34;&lt;/span> &lt;span style="color:#268bd2">uniqueServiceName&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.api.GreetingService&amp;#34;&lt;/span> &lt;span style="color:#268bd2">generic&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;false&amp;#34;&lt;/span> &lt;span style="color:#268bd2">id&lt;/span>&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.api.GreetingService&amp;#34;&lt;/span> /&amp;gt; has been built.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>result: hello, annotation
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>By studying this article, the reader can master the basic concepts of &lt;code>Dubbo&lt;/code>&amp;rsquo;s exclusive &lt;code>annotations&lt;/code> , &lt;code>@EnableDubbo&lt;/code>, &lt;code>@Service&lt;/code>, &lt;code>@Reference&lt;/code>, and master it&amp;rsquo;s basic usage through a simple &lt;code>Dubbo&lt;/code> application.&lt;/p>
&lt;p>In addition to traditional &lt;code>XML&lt;/code> configuration, &lt;code>Spring&lt;/code> offers more modern configurations such as annotation drivers, externalization, and auto-assembly.This article focuses on the development of &lt;code>Dubbo&lt;/code> applications through annotations. You can be seen that annotation mode programming is more concise and simple than XML configuration. In future, we will introduce the use of externalization configuration and automatic assembly in &lt;code>Dubbo&lt;/code> further.&lt;/p></description></item><item><title>Blog: Using Zookeeper in Dubbo</title><link>https://dubbo.apache.org/en/blog/2018/08/07/using-zookeeper-in-dubbo/</link><pubDate>Tue, 07 Aug 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/08/07/using-zookeeper-in-dubbo/</guid><description>
&lt;h2 id="introduction-of-zookeeper">Introduction of Zookeeper&lt;/h2>
&lt;h3 id="the-basic-concept">The basic concept&lt;/h3>
&lt;p>In the mordern distrbuted applications, there are multiple coordination problems between nodes and nodes, including: leader election, group service, locking, configuration management, naming and synchronization. Apache Zookeeper, as its name implied, is a distributed, open-source coordination service framwork to address these demand.&lt;/p>
&lt;p>In order to ensure the high performance, highly available and strictly ordered access, the performance aspects of ZooKeeper means it can be used in large, distributed systems and can also be deployed in cluster mode, which called &amp;lsquo;ZooKeeper ensemble&amp;rsquo;. In ZooKeeper ensemble, all write requests from clients are forwarded to a single server, called the leader, through the ZAB(Zookeeper Atomic Broadcast Protocol) to make sure the message in each nodes are same. Clients can access any one of the clusters to read and write data without worrying about inconsistencies in the data.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/zk-emsemble.png" alt="Diagram shows client-server architecture of ZooKeeper">
&lt;em>Image Credit : ebook -Zookeeper-Distributed Process Coordination from O&amp;rsquo;Reilly&lt;/em>&lt;/p>
&lt;p>The method to store the data in Zookeeper is similar as the standard UNIX file system, as a data model styled after the familiar directory tree structure of file systems. When we talking about ZooKeeper data nodes, we call it Znodes to clarify it.&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/zk-tree.png" alt="zk-tree">
&lt;em>Image Credit : ebook -Zookeeper-Distributed Process Coordination from O&amp;rsquo;Reilly&lt;/em>&lt;/p>
&lt;h3 id="basic-implementation">Basic Implementation&lt;/h3>
&lt;p>You could donwload and install Zookeeper directly&lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup>.
Or you could use Homebrew &lt;sup id="fnref:2">&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref">2&lt;/a>&lt;/sup> &lt;code>brew install zookeeper&lt;/code> to install Zookeeper in Mac OS.
Considering the versatility, we run the Zookeeper by using docker in this blog. If you have not installed the docker yet, please prepare the docker environment first. &lt;sup id="fnref:3">&lt;a href="#fn:3" class="footnote-ref" role="doc-noteref">3&lt;/a>&lt;/sup>&lt;/p>
&lt;h4 id="1-running-the-zookeeper">1. Running the Zookeeper&lt;/h4>
&lt;p>Execute the command to run zookeeper in a docker container&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>docker run --rm --name zookeeper -p 2181:2181 zookeeper
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="2-entering-the-zookeeper-container">2. Entering the zookeeper container&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>docker &lt;span style="color:#b58900">exec&lt;/span> -it zookeeper bash
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In the &lt;code>bin&lt;/code> directory, there is a command to start zookeeper &lt;code>zkServer&lt;/code> and the Management Console &lt;code>zkCli&lt;/code>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>bash-4.4# ls -l bin
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>total &lt;span style="color:#2aa198">36&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>-rwxr-xr-x &lt;span style="color:#2aa198">1&lt;/span> zookeepe zookeepe &lt;span style="color:#2aa198">232&lt;/span> Mar &lt;span style="color:#2aa198">27&lt;/span> 04:32 README.txt
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>-rwxr-xr-x &lt;span style="color:#2aa198">1&lt;/span> zookeepe zookeepe &lt;span style="color:#2aa198">1937&lt;/span> Mar &lt;span style="color:#2aa198">27&lt;/span> 04:32 zkCleanup.sh
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>-rwxr-xr-x &lt;span style="color:#2aa198">1&lt;/span> zookeepe zookeepe &lt;span style="color:#2aa198">1056&lt;/span> Mar &lt;span style="color:#2aa198">27&lt;/span> 04:32 zkCli.cmd
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>-rwxr-xr-x &lt;span style="color:#2aa198">1&lt;/span> zookeepe zookeepe &lt;span style="color:#2aa198">1534&lt;/span> Mar &lt;span style="color:#2aa198">27&lt;/span> 04:32 zkCli.sh
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>-rwxr-xr-x &lt;span style="color:#2aa198">1&lt;/span> zookeepe zookeepe &lt;span style="color:#2aa198">1759&lt;/span> Mar &lt;span style="color:#2aa198">27&lt;/span> 04:32 zkEnv.cmd
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>-rwxr-xr-x &lt;span style="color:#2aa198">1&lt;/span> zookeepe zookeepe &lt;span style="color:#2aa198">2696&lt;/span> Mar &lt;span style="color:#2aa198">27&lt;/span> 04:32 zkEnv.sh
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>-rwxr-xr-x &lt;span style="color:#2aa198">1&lt;/span> zookeepe zookeepe &lt;span style="color:#2aa198">1089&lt;/span> Mar &lt;span style="color:#2aa198">27&lt;/span> 04:32 zkServer.cmd
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>-rwxr-xr-x &lt;span style="color:#2aa198">1&lt;/span> zookeepe zookeepe &lt;span style="color:#2aa198">6773&lt;/span> Mar &lt;span style="color:#2aa198">27&lt;/span> 04:32 zkServer.sh
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="3-entering-the-zookeeper-management-interface-via-zkcli">3. Entering the zookeeper management interface via zkCli&lt;/h4>
&lt;p>Since it was started through docker, the process of Zookeeper has been started and will provide the services to the public via port 2181.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>bash-4.4# ps
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>PID USER TIME COMMAND
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">1&lt;/span> zookeepe 0:02 /usr/lib/jvm/java-1.8-openjdk/jre/bin/java -Dzookeeper.log.dir&lt;span style="color:#719e07">=&lt;/span>. -Dzookeeper.root
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">32&lt;/span> root 0:00 bash
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#2aa198">42&lt;/span> root 0:00 ps
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>So, it allows you to access Zookeeper&amp;rsquo;s console directly through &lt;code>zkCli &lt;/code> for management.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>bash-4.4# bin/zkCli.sh -server 127.0.0.1:2181
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Connecting to 127.0.0.1:2181
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>WATCHER::
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>WatchedEvent state:SyncConnected type:None path:null
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>zk: 127.0.0.1:2181&lt;span style="color:#719e07">(&lt;/span>CONNECTED&lt;span style="color:#719e07">)&lt;/span> 0&lt;span style="color:#719e07">]&lt;/span> &lt;span style="color:#b58900">help&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ZooKeeper -server host:port cmd args
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> stat path &lt;span style="color:#719e07">[&lt;/span>watch&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#b58900">set&lt;/span> path data &lt;span style="color:#719e07">[&lt;/span>version&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ls path &lt;span style="color:#719e07">[&lt;/span>watch&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> delquota &lt;span style="color:#719e07">[&lt;/span>-n|-b&lt;span style="color:#719e07">]&lt;/span> path
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ls2 path &lt;span style="color:#719e07">[&lt;/span>watch&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> setAcl path acl
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> setquota -n|-b val path
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#b58900">history&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> redo cmdno
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> printwatches on|off
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> delete path &lt;span style="color:#719e07">[&lt;/span>version&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> sync path
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> listquota path
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> rmr path
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> get path &lt;span style="color:#719e07">[&lt;/span>watch&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> create &lt;span style="color:#719e07">[&lt;/span>-s&lt;span style="color:#719e07">]&lt;/span> &lt;span style="color:#719e07">[&lt;/span>-e&lt;span style="color:#719e07">]&lt;/span> path data acl
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> addauth scheme auth
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> quit
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> getAcl path
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> close
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> connect host:port
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="4-basic-examples-on-zkcli">4. Basic Examples on zkCli&lt;/h4>
&lt;p>Create &lt;code>/hello-zone&lt;/code> node:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>zk: 127.0.0.1:2181&lt;span style="color:#719e07">(&lt;/span>CONNECTED&lt;span style="color:#719e07">)&lt;/span> 19&lt;span style="color:#719e07">]&lt;/span> create /hello-zone &lt;span style="color:#2aa198">&amp;#39;world&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Created /hello-zone
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>List the child nodes under &lt;code>/&lt;/code> and confirm that &lt;code>hello-zone&lt;/code> is created:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>zk: 127.0.0.1:2181&lt;span style="color:#719e07">(&lt;/span>CONNECTED&lt;span style="color:#719e07">)&lt;/span> 20&lt;span style="color:#719e07">]&lt;/span> ls /
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>zookeeper, hello-zone&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>List the child nodes for &lt;code>/hello-zone&lt;/code> and verify that it is empty:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>zk: 127.0.0.1:2181&lt;span style="color:#719e07">(&lt;/span>CONNECTED&lt;span style="color:#719e07">)&lt;/span> 21&lt;span style="color:#719e07">]&lt;/span> ls /hello-zone
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[]&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Get the data stored on the &lt;code>/hello-zone&lt;/code> node:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>zk: 127.0.0.1:2181&lt;span style="color:#719e07">(&lt;/span>CONNECTED&lt;span style="color:#719e07">)&lt;/span> 22&lt;span style="color:#719e07">]&lt;/span> get /hello-zone
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>world
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="using-zookeeper-in-dubbo">Using Zookeeper in Dubbo&lt;/h2>
&lt;p>Zookeeper is used for service registration discovery and configuration management in Dubbo, and the structure of data in Zookeeper is shown in the following figure:&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-in-zk.jpg" alt="dubbo-in-zk">&lt;/p>
&lt;p>First, all data related to Dubbo is organized under the root node of &lt;code>/dubbo&lt;/code>.&lt;/p>
&lt;p>The secondary directory is the service name like &lt;code>com.foo.BarService&lt;/code>.&lt;/p>
&lt;p>The three-level directory has two child nodes, &lt;code>providers&lt;/code> and &lt;code>consumers&lt;/code>, representing the supplier and customers of the service.&lt;/p>
&lt;p>The URL information for each application instance associated with the service will be recorded by the Level 4 directory. The &lt;code>providers&lt;/code> and &lt;code>consumer&lt;/code> will stored the providers information and the consumers information of the services seperately.&lt;br>
For example, the service provider of &lt;code>com.foo.BarService&lt;/code> will register its URL Information to &lt;code>/dubbo/com.foo.BarService/providers&lt;/code>; Similarly, service consumers will register their information under the corresponding &lt;code>consumer&lt;/code> node. At the same time, consumers will subscribe to the corresponding &lt;code>providers&lt;/code> node to be able to detect the changes of the service provider address list.&lt;/p>
&lt;h3 id="prepare-the-sample-code">Prepare the sample code&lt;/h3>
&lt;p>The code in this document can be found in &lt;a href="https://github.com/dubbo/dubbo-samples/tree/master/3-extensions/registry/dubbo-samples-zookeeper">https://github.com/dubbo/dubbo-samples/tree/master/3-extensions/registry/dubbo-samples-zookeeper&lt;/a>.&lt;/p>
&lt;h4 id="1-interface-definition">1. Interface definition&lt;/h4>
&lt;p>Define a simple &lt;code>greetingservice&lt;/code> interface with only one simple method named &lt;code>sayHello&lt;/code> to greet to the caller.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">GreetingService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="2-server-implementation">2. Server: Implementation&lt;/h4>
&lt;p>Implement the &lt;code>GreetingService&lt;/code> interface and mark it as a service for Dubbo via &lt;code>@Service&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Service&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">AnnotatedGreetingService&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> GreetingService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;hello, &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="3-server-assembly">3. Server: Assembly&lt;/h4>
&lt;p>Define ProviderConfiguration to assemble Dubbo services.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Configuration&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@EnableDubbo&lt;/span>(scanBasePackages &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.impl&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@PropertySource&lt;/span>(&lt;span style="color:#2aa198">&amp;#34;classpath:/spring/dubbo-provider.properties&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">ProviderConfiguration&lt;/span> {}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Dubbo-provider.properties is an external configuration in a spring application, as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-properties" data-lang="properties">&lt;span style="display:flex;">&lt;span>dubbo.application.name&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">demo-provider&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.registry.address&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">zookeeper://$DOCKER_HOST:2181&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.protocol.name&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">dubbo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.protocol.port&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">20880&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Since zookeeper runs in a docker container, please be noted that:&lt;/p>
&lt;ul>
&lt;li>We assumes that Dubbo applications is running on the host machine (outside the docker container) in this document, and needs to replace the PATH of Zookeeper with the IP address of the Environment Variable &lt;em>${DOCKER_HOST}&lt;/em>. Please find more detail in the official Docker documentation.&lt;/li>
&lt;li>When the Dubbo application is a docker application, the container&amp;rsquo;s name is equivalent to Zookeeper&amp;rsquo;s. The container&amp;rsquo;s name is ** zookeeper ** in this document.&lt;/li>
&lt;li>Of course, if you don&amp;rsquo;t want to run the Zookeeper in a container mode, just simply replace &lt;em>$DOCKER_HOST&lt;/em> with &lt;strong>localhost&lt;/strong>.&lt;/li>
&lt;/ul>
&lt;h4 id="4-server-starting-service">4. Server: Starting Service&lt;/h4>
&lt;p>In the &lt;code>main&lt;/code> method, you could provide the Dubbo service by running a Spring Context.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">ProviderBootstrap&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) &lt;span style="color:#268bd2">throws&lt;/span> Exception {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> AnnotationConfigApplicationContext context &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> AnnotationConfigApplicationContext(ProviderConfiguration.class);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.in.read();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Start the &lt;code>main&lt;/code> method of server, you will get the following output, which represents the success of the server&amp;rsquo;s startup, and the &lt;code>GreetingService&lt;/code> service is registered on the ZookeeperRegistry:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>03/08/18 10:50:33:033 CST&lt;span style="color:#719e07">]&lt;/span> main INFO zookeeper.ZookeeperRegistry: &lt;span style="color:#719e07">[&lt;/span>DUBBO&lt;span style="color:#719e07">]&lt;/span> Register: dubbo://192.168.99.1:20880/com.alibaba.dubbo.samples.api.GreetingService?anyhost&lt;span style="color:#719e07">=&lt;/span>true&amp;amp;&lt;span style="color:#268bd2">application&lt;/span>&lt;span style="color:#719e07">=&lt;/span>demo-provider&amp;amp;&lt;span style="color:#268bd2">dubbo&lt;/span>&lt;span style="color:#719e07">=&lt;/span>2.6.2&amp;amp;&lt;span style="color:#268bd2">generic&lt;/span>&lt;span style="color:#719e07">=&lt;/span>false&amp;amp;&lt;span style="color:#268bd2">interface&lt;/span>&lt;span style="color:#719e07">=&lt;/span>com.alibaba.dubbo.samples.api.GreetingService&amp;amp;&lt;span style="color:#268bd2">methods&lt;/span>&lt;span style="color:#719e07">=&lt;/span>sayHello&amp;amp;&lt;span style="color:#268bd2">pid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>12938&amp;amp;&lt;span style="color:#268bd2">side&lt;/span>&lt;span style="color:#719e07">=&lt;/span>provider&amp;amp;&lt;span style="color:#268bd2">timestamp&lt;/span>&lt;span style="color:#719e07">=&lt;/span>1533264631849, dubbo version: 2.6.2, current host: 192.168.99.1
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>You could find the registration information of the service provider through the Zookeeper management terminal:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>$ docker &lt;span style="color:#b58900">exec&lt;/span> -it zookeeper bash
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>bash-4.4# bin/zkCli.sh -server localhost:218
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Connecting to localhost:2181
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Welcome to ZooKeeper!
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>JLine support is enabled
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>zk: localhost:2181&lt;span style="color:#719e07">(&lt;/span>CONNECTED&lt;span style="color:#719e07">)&lt;/span> 0&lt;span style="color:#719e07">]&lt;/span> ls /dubbo/com.alibaba.dubbo.samples.api.GreetingService/providers
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>dubbo%3A%2F%2F192.168.99.1%3A20880%2Fcom.alibaba.dubbo.samples.api.GreetingService%3Fanyhost%3Dtrue%26application%3Ddemo-provider%26dubbo%3D2.6.2%26generic%3Dfalse%26interface%3Dcom.alibaba.dubbo.samples.api.GreetingService%26methods%3DsayHello%26pid%3D12938%26side%3Dprovider%26timestamp%3D1533264631849&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>You could find that the Dubbo services just registered its URL address at the &lt;code>providers&lt;/code> node as follows:
&lt;em>dubbo://192.168.99.1:20880/com.alibaba.dubbo.samples.api.GreetingService?anyhost=true&amp;amp;application=demo-provider&amp;amp;dubbo=2.6.2&amp;amp;generic=false&amp;amp;interface=com.alibaba.dubbo.samples.api.GreetingService&amp;amp;methods=sayHello&amp;amp;pid=12938&amp;amp;side=provider&amp;amp;timestamp=1533264631849&lt;/em>&lt;/p>
&lt;h4 id="5-client-reference-service">5. Client: Reference Service&lt;/h4>
&lt;p>You could declare the reference service by @Reference, while it will generate a full call. The target address of the service could be queried by the Zookeeper&amp;rsquo;s &lt;code>provider&lt;/code> node.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Component&lt;/span>(&lt;span style="color:#2aa198">&amp;#34;annotatedConsumer&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">GreetingServiceConsumer&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Reference&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> GreetingService greetingService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">doSayHello&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> greetingService.sayHello(name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="6-client-assembling">6. Client: Assembling&lt;/h4>
&lt;p>Define the ConsumerConfiguration to assemble Dubbo service.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Configuration&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@EnableDubbo&lt;/span>(scanBasePackages &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.action&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@PropertySource&lt;/span>(&lt;span style="color:#2aa198">&amp;#34;classpath:/spring/dubbo-consumer.properties&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@ComponentScan&lt;/span>(value &lt;span style="color:#719e07">=&lt;/span> {&lt;span style="color:#2aa198">&amp;#34;com.alibaba.dubbo.samples.action&amp;#34;&lt;/span>})
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">ConsumerConfiguration&lt;/span> {}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&amp;ldquo;dubbo-consumer.properties&amp;rdquo; is a method of external configuration in a Spring application, as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-properties" data-lang="properties">&lt;span style="display:flex;">&lt;span>dubbo.application.name&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">demo-consumer&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.registry.address&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">zookeeper://$DOCKER_HOST:2181&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.consumer.timeout&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">3000&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Same as &lt;strong>3. Server: Assembling&lt;/strong>, You need to modify &lt;em>$DOCKER_HOST&lt;/em> defined in &lt;em>dubbo.registry.address&lt;/em> according to your own environment. You could find more instructions in step 3.&lt;/p>
&lt;h4 id="7-client-initiating-a-remote-call">7. Client: Initiating A Remote Call&lt;/h4>
&lt;p>Run &lt;code>main&lt;/code> to initiate a remote call from a existed service provider. Dubbo first subscribes to the zookeeper service address and then selects one from the list of returned addresses to invoke the client:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">ConsumerBootstrap&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">ConsumerBootstrap&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) &lt;span style="color:#268bd2">throws&lt;/span> IOException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> AnnotationConfigApplicationContext context &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> AnnotationConfigApplicationContext(ConsumerConfiguration.class);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> context.start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> GreetingServiceConsumer greetingServiceConsumer &lt;span style="color:#719e07">=&lt;/span> context.getBean(GreetingServiceConsumer.class);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String hello &lt;span style="color:#719e07">=&lt;/span> greetingServiceConsumer.doSayHello(&lt;span style="color:#2aa198">&amp;#34;zookeeper&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(&lt;span style="color:#2aa198">&amp;#34;result: &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> hello);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.in.read();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The output are as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>03/08/18 01:42:31:031 CST&lt;span style="color:#719e07">]&lt;/span> main INFO zookeeper.ZookeeperRegistry: &lt;span style="color:#719e07">[&lt;/span>DUBBO&lt;span style="color:#719e07">]&lt;/span> Register: consumer://192.168.99.1/com.alibaba.dubbo.samples.api.GreetingService?application&lt;span style="color:#719e07">=&lt;/span>demo-consumer&amp;amp;&lt;span style="color:#268bd2">category&lt;/span>&lt;span style="color:#719e07">=&lt;/span>consumers&amp;amp;&lt;span style="color:#268bd2">check&lt;/span>&lt;span style="color:#719e07">=&lt;/span>false&amp;amp;default.timeout&lt;span style="color:#719e07">=&lt;/span>3000&amp;amp;&lt;span style="color:#268bd2">dubbo&lt;/span>&lt;span style="color:#719e07">=&lt;/span>2.6.2&amp;amp;&lt;span style="color:#268bd2">interface&lt;/span>&lt;span style="color:#719e07">=&lt;/span>com.alibaba.dubbo.samples.api.GreetingService&amp;amp;&lt;span style="color:#268bd2">methods&lt;/span>&lt;span style="color:#719e07">=&lt;/span>sayHello&amp;amp;&lt;span style="color:#268bd2">pid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>82406&amp;amp;&lt;span style="color:#268bd2">side&lt;/span>&lt;span style="color:#719e07">=&lt;/span>consumer&amp;amp;&lt;span style="color:#268bd2">timestamp&lt;/span>&lt;span style="color:#719e07">=&lt;/span>1533274951195, dubbo version: 2.6.2, current host: 192.168.99.1 &lt;span style="color:#586e75">#1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>03/08/18 01:42:31:031 CST&lt;span style="color:#719e07">]&lt;/span> main INFO zookeeper.ZookeeperRegistry: &lt;span style="color:#719e07">[&lt;/span>DUBBO&lt;span style="color:#719e07">]&lt;/span> Subscribe: consumer://192.168.99.1/com.alibaba.dubbo.samples.api.GreetingService?application&lt;span style="color:#719e07">=&lt;/span>demo-consumer&amp;amp;&lt;span style="color:#268bd2">category&lt;/span>&lt;span style="color:#719e07">=&lt;/span>providers,configurators,routers&amp;amp;default.timeout&lt;span style="color:#719e07">=&lt;/span>3000&amp;amp;&lt;span style="color:#268bd2">dubbo&lt;/span>&lt;span style="color:#719e07">=&lt;/span>2.6.2&amp;amp;&lt;span style="color:#268bd2">interface&lt;/span>&lt;span style="color:#719e07">=&lt;/span>com.alibaba.dubbo.samples.api.GreetingService&amp;amp;&lt;span style="color:#268bd2">methods&lt;/span>&lt;span style="color:#719e07">=&lt;/span>sayHello&amp;amp;&lt;span style="color:#268bd2">pid&lt;/span>&lt;span style="color:#719e07">=&lt;/span>82406&amp;amp;&lt;span style="color:#268bd2">side&lt;/span>&lt;span style="color:#719e07">=&lt;/span>consumer&amp;amp;&lt;span style="color:#268bd2">timestamp&lt;/span>&lt;span style="color:#719e07">=&lt;/span>1533274951195, dubbo version: 2.6.2, current host: 192.168.99.1 &lt;span style="color:#586e75">#2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>result: hello, zookeeper
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Description:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Register&lt;/strong>: consumer://192.168.99.1/&amp;hellip;&amp;amp;&lt;strong>category=consumers&lt;/strong>&amp;amp;: In Zookeeper, consumers could register their information and store it at the &lt;code>consumers&lt;/code> node&lt;/li>
&lt;li>&lt;strong>Subscribe&lt;/strong>: consumer://192.168.99.1/&amp;hellip;&amp;amp;&lt;strong>category=providers,configurators,routers&lt;/strong>&amp;amp;:Consumers subscribe &lt;code>providers&lt;/code>, &lt;code>configurators&lt;/code>, &lt;code>routers&lt;/code> from Zookeepers. The &lt;code>configurations&lt;/code> is related to the Dubbo configuration, and &lt;code>routers&lt;/code> is related to routing rules. The providers node subscription should be noted. When a new service provider to join, due to the relationship between the subscription, the new address list will be pushed to the subscriber. So service consumers also dynamically perceive changes in address lists.&lt;/li>
&lt;/ol>
&lt;p>You could find the registration information of the service provider through the Zookeeper management terminal:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>$ docker &lt;span style="color:#b58900">exec&lt;/span> -it zookeeper bash
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>bash-4.4# bin/zkCli.sh -server localhost:218
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Connecting to localhost:2181
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Welcome to ZooKeeper!
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>JLine support is enabled
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>zk: localhost:2181&lt;span style="color:#719e07">(&lt;/span>CONNECTED&lt;span style="color:#719e07">)&lt;/span> 4&lt;span style="color:#719e07">]&lt;/span> ls /dubbo/com.alibaba.dubbo.samples.api.GreetingService/consumers
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>consumer%3A%2F%2F192.168.99.1%2Fcom.alibaba.dubbo.samples.api.GreetingService%3Fapplication%3Ddemo-consumer%26category%3Dconsumers%26check%3Dfalse%26default.timeout%3D3000%26dubbo%3D2.6.2%26interface%3Dcom.alibaba.dubbo.samples.api.GreetingService%26methods%3DsayHello%26pid%3D82406%26side%3Dconsumer%26timestamp%3D1533274951195&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>You could see that consumers of Dubbo&amp;rsquo;s servicehas registered its URL address at the &lt;code>consumers&lt;/code> node:&lt;/p>
&lt;p>&lt;em>consumer://192.168.99.1/com.alibaba.dubbo.samples.api.GreetingService?application=demo-consumer&amp;amp;category=providers,configurators,routers&amp;amp;default.timeout=3000&amp;amp;dubbo=2.6.2&amp;amp;interface=com.alibaba.dubbo.samples.api.GreetingService&amp;amp;methods=sayHello&amp;amp;pid=82406&amp;amp;side=consumer&amp;amp;timestamp=1533274951195&lt;/em>&lt;/p>
&lt;h2 id="summary">Summary&lt;/h2>
&lt;p>This document focuses on how to use ZooKeeper as a registry in Dubbo. This document also mentioned that the Zookeeper could be a configuration center and a service management in Dubbo. Zookeeper is a single-node, standalone mode. However, developers always bulid a Zookeeper server cluster called * Zookeeper ensemble * in the real world.&lt;/p>
&lt;p>Through this document, readers can learn:&lt;/p>
&lt;ul>
&lt;li>Basic concepts and applications of ZooKeeper&lt;/li>
&lt;li>The function of Zookeeper in Dubbo application&lt;/li>
&lt;li>Learn about Zookeeper&amp;rsquo;s interaction through practical sample codes&lt;/li>
&lt;li>The storage of service registration and consumption information of Dubbo with ZooKeeper&lt;/li>
&lt;/ul>
&lt;div class="footnotes" role="doc-endnotes">
&lt;hr>
&lt;ol>
&lt;li id="fn:1">
&lt;p>&lt;a href="https://www.apache.org/dyn/closer.cgi/zookeeper/">https://www.apache.org/dyn/closer.cgi/zookeeper/&lt;/a>&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:2">
&lt;p>&lt;a href="https://brew.sh">https://brew.sh&lt;/a>&amp;#160;&lt;a href="#fnref:2" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:3">
&lt;p>&lt;a href="https://www.docker.com/community-edition">https://www.docker.com/community-edition&lt;/a>&amp;#160;&lt;a href="#fnref:3" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;/ol>
&lt;/div></description></item><item><title>Blog: Your First Dubbo Demo</title><link>https://dubbo.apache.org/en/blog/2018/08/07/dubbo-101/</link><pubDate>Tue, 07 Aug 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/08/07/dubbo-101/</guid><description>
&lt;h2 id="java-rmi-introduction">Java RMI Introduction&lt;/h2>
&lt;p>Java RMI (Remote Method Invocation) is a mechanism that allows users to access or invocate an object and a method running on another JVM (Java Virtual Machine). RMI is an implementation of RPC (Remote Procedure Call) in java with support of OOP (Object Oriented Paradigms). Instead of bothering IDL (Interface Define Language), users can build distributed applications by depending on interfaces in an easy and natural way.&lt;/p>
&lt;h3 id="java-rmi-work-flow">Java RMI Work Flow&lt;/h3>
&lt;p>Here is how a typical RMI invocation usually works:&lt;/p>
&lt;ol>
&lt;li>The server registers service from RMI and binds its address.&lt;/li>
&lt;li>The client registers service from RMI and obtains target address.&lt;/li>
&lt;li>The client invokes methods of local stub object in the same way of invoking other local objects.&lt;/li>
&lt;li>Local stub object zips invoking information and send it to the server via network.&lt;/li>
&lt;li>The Skeleton object of server receives the network request and unzips the information.&lt;/li>
&lt;li>Server runs invocation on the target object based on the information and return the zipped results back to client via network.&lt;/li>
&lt;/ol>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/rmi-flow.png" alt="RMI Flow">&lt;/p>
&lt;p>(source:https://www.cs.rutgers.edu/~pxk/417/notes/images/rpc-rmi_flow.png)&lt;/p>
&lt;h3 id="java-rmi-concepts">Java RMI Concepts&lt;/h3>
&lt;p>Java RMI is a technique foundation stone of creating distributed applications in Java. The following EJB techniques and current framework of distributed services still inherit the fundamental concepts of Java RMI. In RMI invocation, there are some core concepts:&lt;/p>
&lt;ol>
&lt;li>The invocation is run remotely on &lt;strong>interface&lt;/strong>.&lt;/li>
&lt;li>Disguise remote invocation as local invocation by &lt;strong>Stub object&lt;/strong> on client and &lt;strong>Skeleton object&lt;/strong> on server.&lt;/li>
&lt;li>The service is registered and looked up by &lt;strong>RMI&lt;/strong> registry service.&lt;/li>
&lt;/ol>
&lt;p>For 1. users are dependent on interfaces which should be implemented by server.&lt;/p>
&lt;p>For 2. In J2SE 1.5 version and before, it needs to pre-compile Stub on client and Skeleton on server by rmic. In the later versions there is no need to do so.&lt;/p>
&lt;p>The following is a code example of registry and look-up in RMI.&lt;/p>
&lt;h4 id="server-service-registry">Server service registry&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>Hello obj &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> HelloImpl(); &lt;span style="color:#586e75">// #1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Hello stub &lt;span style="color:#719e07">=&lt;/span> (Hello) UnicastRemoteObject.exportObject(obj, 0); &lt;span style="color:#586e75">// #2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Registry registry &lt;span style="color:#719e07">=&lt;/span> LocateRegistry.createRegistry(1099); &lt;span style="color:#586e75">// #3&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>registry.rebind(&lt;span style="color:#2aa198">&amp;#34;Hello&amp;#34;&lt;/span>, stub); &lt;span style="color:#586e75">// #4&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Notes:&lt;/p>
&lt;ol>
&lt;li>
&lt;p>Initiate service object instance.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Create stub object to communicate with the server by UnicastRemoteObject.exportObject.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Create a local RMI registry service on port 1099 which is run on server. It can also be registered as an independent process.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Bind stub object into registry so the client can find the remote object by looking up Hello.&lt;/p>
&lt;/li>
&lt;/ol>
&lt;h4 id="client-service-look-up">Client service look-up&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>Registry registry &lt;span style="color:#719e07">=&lt;/span> LocateRegistry.getRegistry(); &lt;span style="color:#586e75">// #1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Hello stub &lt;span style="color:#719e07">=&lt;/span> (Hello) registry.lookup(&lt;span style="color:#2aa198">&amp;#34;Hello&amp;#34;&lt;/span>); &lt;span style="color:#586e75">// #2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>String response &lt;span style="color:#719e07">=&lt;/span> stub.sayHello(); &lt;span style="color:#586e75">// #3&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Notes:&lt;/p>
&lt;ol>
&lt;li>Acquire registry service instances. In this case, there is no input parameters so it is assumed that the acquired instance is located on port 1099.&lt;/li>
&lt;li>Look up the remote object named Hello in registry service.&lt;/li>
&lt;li>Run a RMI invocation via acquired Stub object and get results.
Understand the work flow and basic concepts of RMI is helpful to handle current framework of distributed service. It is recommended to refer to RMI official documents for further information[^1].&lt;/li>
&lt;/ol>
&lt;h2 id="basic-concepts-of-dubbo">Basic Concepts of Dubbo&lt;/h2>
&lt;p>The basic concepts of current framework of distributed service is similar to the one of RMI. They both use Java interface as service contract, register and look up by registry center and use agency to block the details of remote communications. Specifically, Dubbo has following four types of roles to play when running:&lt;/p>
&lt;ol>
&lt;li>Serve the provider – Expose service at assigned ports at initialization and register the service address and ports at registry center&lt;/li>
&lt;li>Serve the consumer – Subscribe the service of interests at registry center at initialization to acquire the list of addresses provided by the service provider.&lt;/li>
&lt;li>Registry center – Register and look up service. Store the address provided by the service provider and send it to the consumer.&lt;/li>
&lt;li>Monitor center – Collect and monitor running status of providers and consumers, e.g., times of invocations, delay of invocations, etc.&lt;/li>
&lt;li>Running container – Initialize and load the provider and manage the lifecycle of running.&lt;/li>
&lt;/ol>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-architecture.png" alt="dubbo-architecture">&lt;/p>
&lt;p>&lt;strong>Deploy stage&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Service providers expose service at assigned ports and register information of service at registry center.&lt;/li>
&lt;li>Service consumers subscribe the list of service addresses from registry center.&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Run stage&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Registry center sends the address to service consumers.&lt;/li>
&lt;li>After receiving the list of addresses, service consumers select one of them and invoke an object service.&lt;/li>
&lt;li>During invocation, the running status of service providers and consumers is reported to the monitor center.&lt;/li>
&lt;/ul>
&lt;h2 id="dubbo-applications-based-on-api">Dubbo Applications Based on API&lt;/h2>
&lt;p>The applications of Dubbo are usually assembled by Spring. To obtain an available Dubbo application quickly, the example shown here abandons complex configurations but to create service provider and consumer in Dubbo API oriented way. Additionally, the registry center and monitor center do not need installation or configuration in this example.&lt;/p>
&lt;p>In production environment, the service of Dubbo usually requires cooperation with a distributed service registry center, such as ZooKeeper. For convenience, Dubbo offers two ways to avoid extra work of building registry center, namely direct connection [2] and assembled podcast [3] respectively. In this example, the latter way is applied to register and look up service.&lt;/p>
&lt;h3 id="define-service-contract">Define Service Contract&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">interface&lt;/span> &lt;span style="color:#268bd2">GreetingsService&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">sayHi&lt;/span>(String name); &lt;span style="color:#586e75">// #1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Notes&lt;/strong>:&lt;/p>
&lt;ol>
&lt;li>The codes define a simple service contract where there is only one function, sayHi, can be invoked. The type of input parameter and return value are both String.&lt;/li>
&lt;/ol>
&lt;h3 id="provide-contract-implementation">Provide Contract Implementation&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">GreetingsServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> GreetingsService { &lt;span style="color:#586e75">// #1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">sayHi&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;hi, &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name; &lt;span style="color:#586e75">// #2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Notes&lt;/strong>:&lt;/p>
&lt;ol>
&lt;li>Service providers need to implement the interface of service contract, GreetingsService.&lt;/li>
&lt;li>This function simply returns a welcome message. For example, if the input value is &lt;em>dubbo&lt;/em>,it will return &lt;em>hi, dubbo&lt;/em>.&lt;/li>
&lt;/ol>
&lt;h3 id="implement-dubbo-service-provider">Implement Dubbo Service Provider&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">Application&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) &lt;span style="color:#268bd2">throws&lt;/span> IOException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ServiceConfig&lt;span style="color:#719e07">&amp;lt;&lt;/span>GreetingsService&lt;span style="color:#719e07">&amp;gt;&lt;/span> service &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ServiceConfig&lt;span style="color:#719e07">&amp;lt;&amp;gt;&lt;/span>(); &lt;span style="color:#586e75">// #1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> service.setApplication(&lt;span style="color:#719e07">new&lt;/span> ApplicationConfig(&lt;span style="color:#2aa198">&amp;#34;first-dubbo-provider&amp;#34;&lt;/span>)); &lt;span style="color:#586e75">// #2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> service.setRegistry(&lt;span style="color:#719e07">new&lt;/span> RegistryConfig(&lt;span style="color:#2aa198">&amp;#34;multicast://224.5.6.7:1234&amp;#34;&lt;/span>)); &lt;span style="color:#586e75">// #3&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> service.setInterface(GreetingsService.class); &lt;span style="color:#586e75">// #4&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> service.setRef(&lt;span style="color:#719e07">new&lt;/span> GreetingsServiceImpl()); &lt;span style="color:#586e75">// #5&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> service.export(); &lt;span style="color:#586e75">// #6&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.in.read(); &lt;span style="color:#586e75">// #7&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Notes&lt;/strong>:&lt;/p>
&lt;ol>
&lt;li>Create an instance &lt;em>ServiceConfig&lt;/em> with service interface type as generics parameters, which is &lt;em>GreetingsService&lt;/em> in this example.&lt;/li>
&lt;li>Generate an instance of &lt;em>ApplicationConfig&lt;/em> and assemble it into &lt;em>ServiceConfig&lt;/em>.&lt;/li>
&lt;li>Generate an instance &lt;em>RegistryConfig&lt;/em> and assemble it into &lt;em>ServiceConfig&lt;/em>. Since the assembled way is applied here, the parameter should be &lt;code>multicast://224.5.6.7:1234&lt;/code>. The valid range of assembled address is &lt;em>224.0.0.0 - 239.255.255.255&lt;/em>&lt;/li>
&lt;li>Assemble the service contract &lt;em>GreetingsService&lt;/em> into &lt;em>ServiceConfig&lt;/em>.&lt;/li>
&lt;li>Assemble the instance with implementation of &lt;em>GreetingsServicelmpl&lt;/em> provided by service providers into &lt;em>ServiceConfig&lt;/em>.&lt;/li>
&lt;li>&lt;em>ServiceConfig&lt;/em> starts to expose itself at default ports &lt;em>20880&lt;/em>. after being equipped with enough information.&lt;/li>
&lt;li>Press any key or &lt;em>ctrl-C&lt;/em> to exit to avoid server halt.&lt;/li>
&lt;/ol>
&lt;h3 id="implement-dubbo-service-consumer">Implement Dubbo Service Consumer&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">Application&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ReferenceConfig&lt;span style="color:#719e07">&amp;lt;&lt;/span>GreetingsService&lt;span style="color:#719e07">&amp;gt;&lt;/span> reference &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ReferenceConfig&lt;span style="color:#719e07">&amp;lt;&amp;gt;&lt;/span>(); &lt;span style="color:#586e75">// #1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> reference.setApplication(&lt;span style="color:#719e07">new&lt;/span> ApplicationConfig(&lt;span style="color:#2aa198">&amp;#34;first-dubbo-client&amp;#34;&lt;/span>)); &lt;span style="color:#586e75">// #2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> reference.setRegistry(&lt;span style="color:#719e07">new&lt;/span> RegistryConfig(&lt;span style="color:#2aa198">&amp;#34;multicast://224.5.6.7:1234&amp;#34;&lt;/span>)); &lt;span style="color:#586e75">// #3&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> reference.setInterface(GreetingsService.class); &lt;span style="color:#586e75">// #4&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> GreetingsService greetingsService &lt;span style="color:#719e07">=&lt;/span> reference.get(); &lt;span style="color:#586e75">// #5&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String message &lt;span style="color:#719e07">=&lt;/span> greetingsService.sayHi(&lt;span style="color:#2aa198">&amp;#34;dubbo&amp;#34;&lt;/span>); &lt;span style="color:#586e75">// #6&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> System.out.println(message); &lt;span style="color:#586e75">// #7&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Notes&lt;/strong>:&lt;/p>
&lt;ol>
&lt;li>Create an instance of &lt;em>ReferenceConfig&lt;/em> with service interface type as generics parameters, which is &lt;em>GreetingsService&lt;/em> in this example.&lt;/li>
&lt;li>Create an instance of &lt;em>ApplicationConfig&lt;/em>, and assemble it into &lt;em>ReferenceConfig&lt;/em>.&lt;/li>
&lt;li>Generate an instance &lt;em>RegistryConfig&lt;/em>, and assemble it into &lt;em>ReferenceConfig&lt;/em>. Note that the address information here should be the same as the one of the service provider.&lt;/li>
&lt;li>Assemble the service contract &lt;em>GreetingsService&lt;/em> into &lt;em>ReferenceConfig&lt;/em>.&lt;/li>
&lt;li>Obtain the agency of &lt;em>GreetingsService&lt;/em> from &lt;em>ReferenceConfig&lt;/em>.&lt;/li>
&lt;li>Invoke a remote call through &lt;em>GreetingsSerive&lt;/em>’s agency and pass in &lt;code>dubbo&lt;/code> as input parameter.&lt;/li>
&lt;li>Return and print results &lt;code>hi, dubbo&lt;/code>.&lt;/li>
&lt;/ol>
&lt;h3 id="run">Run&lt;/h3>
&lt;p>The complete example can be found at &lt;a href="https://github.com/apache/dubbo-samples/tree/master/1-basic/dubbo-samples-api">https://github.com/apache/dubbo-samples/tree/master/1-basic/dubbo-samples-api&lt;/a>. In the complete version, it is convenient to execute by maven in command line with the configuration of &lt;em>exec-maven-plugin&lt;/em>. Of course, it can also be executed directly in IDE. However, there is one noteworthy thing that because of using assembled way to look up service, it needs to assign &lt;em>-Djava.net.preferIPv4Stack=true&lt;/em> when running.&lt;/p>
&lt;h4 id="build-example">Build Example&lt;/h4>
&lt;p>Synchronize the example codes and build by the following command lines:&lt;/p>
&lt;ol>
&lt;li>Synchronize the example codes: git clone &lt;a href="https://github.com/apache/dubbo-samples.git">https://github.com/apache/dubbo-samples.git&lt;/a>&lt;/li>
&lt;li>Build:mvn clean package&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>$ git clone https://github.com/apache/dubbo-samples.git
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ &lt;span style="color:#b58900">cd&lt;/span> dubbo-samples/java/dubbo-samples-api/
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ mvn clean package
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>INFO&lt;span style="color:#719e07">]&lt;/span> Scanning &lt;span style="color:#719e07">for&lt;/span> projects...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> ------------------------------------------------------------------------
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> Building dubbo-samples-api 1.0-SNAPSHOT
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> ------------------------------------------------------------------------
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> --- maven-clean-plugin:2.5:clean &lt;span style="color:#719e07">(&lt;/span>default-clean&lt;span style="color:#719e07">)&lt;/span> @ dubbo-samples-api ---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> ------------------------------------------------------------------------
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> BUILD SUCCESS
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> ------------------------------------------------------------------------
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> Total time: 2.182 s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> Finished at: 2018-05-28T14:56:08+08:00
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> Final Memory: 20M/353M
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> ------------------------------------------------------------------------
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The build is finished when it shows &lt;code>BUILD SUCCESS&lt;/code>. Then comes the running stage.&lt;/p>
&lt;h4 id="run-the-server">Run the server&lt;/h4>
&lt;p>Run the service provider by the following maven command lines:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>$ mvn -Djava.net.preferIPv4Stack&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#b58900">true&lt;/span> -Dexec.mainClass&lt;span style="color:#719e07">=&lt;/span>org.apache.dubbo.samples.provider.Application exec:java
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> Scanning &lt;span style="color:#719e07">for&lt;/span> projects...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> ------------------------------------------------------------------------
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> Building dubbo-samples-api 1.0-SNAPSHOT
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> ------------------------------------------------------------------------
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> --- exec-maven-plugin:1.6.0:java &lt;span style="color:#719e07">(&lt;/span>default-cli&lt;span style="color:#719e07">)&lt;/span> @ dubbo-samples-api ---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>log4j:WARN No appenders could be found &lt;span style="color:#719e07">for&lt;/span> logger &lt;span style="color:#719e07">(&lt;/span>org.apache.dubbo.common.logger.LoggerFactory&lt;span style="color:#719e07">)&lt;/span>.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>log4j:WARN Please initialize the log4j system properly.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig &lt;span style="color:#719e07">for&lt;/span> more info.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>first-dubbo-provider is running.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>When &lt;em>first-dubbo-provider is running&lt;/em> appears, the service provider is ready to be called by the client.&lt;/p>
&lt;h4 id="run-the-client">Run the client&lt;/h4>
&lt;p>Run the service consumer by the following maven command lines:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>$ mvn -Djava.net.preferIPv4Stack&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#b58900">true&lt;/span> -Dexec.mainClass&lt;span style="color:#719e07">=&lt;/span>org.apache.dubbo.samples.consumer.Application exec:java
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> Scanning &lt;span style="color:#719e07">for&lt;/span> projects...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> ------------------------------------------------------------------------
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> Building dubbo-samples-api 1.0-SNAPSHOT
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> ------------------------------------------------------------------------
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">[&lt;/span>INFO&lt;span style="color:#719e07">]&lt;/span> --- exec-maven-plugin:1.6.0:java &lt;span style="color:#719e07">(&lt;/span>default-cli&lt;span style="color:#719e07">)&lt;/span> @ dubbo-samples-api ---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>log4j:WARN No appenders could be found &lt;span style="color:#719e07">for&lt;/span> logger &lt;span style="color:#719e07">(&lt;/span>org.apache.dubbo.common.logger.LoggerFactory&lt;span style="color:#719e07">)&lt;/span>.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>log4j:WARN Please initialize the log4j system properly.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig &lt;span style="color:#719e07">for&lt;/span> more info.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>hi, dubbo
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>hi, dubbo&lt;/code> is the execution results from service provider.&lt;/p>
&lt;h2 id="quick-creation-of-a-dubbo-application">Quick Creation of A Dubbo Application&lt;/h2>
&lt;p>Dubbo also provides a public platform that can create a Dubbo application quickly based on Spring Boot. Visit &lt;a href="http://start.dubbo.io">http://start.dubbo.io&lt;/a> and follow the figure below to create an example project:&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/dubbo-initializr.png" alt="dubbo initializr">&lt;/p>
&lt;p>&lt;strong>Notes&lt;/strong>:&lt;/p>
&lt;ol>
&lt;li>Provide maven groupId in &lt;em>Group&lt;/em> with default value &lt;code>com.example&lt;/code>.&lt;/li>
&lt;li>Provide maven artifactId in &lt;em>Artifact&lt;/em> with default value &lt;code>demo&lt;/code>.&lt;/li>
&lt;li>Provide the name of service in &lt;em>DubboServiceName&lt;/em> with default value &lt;code>com.example.HelloService&lt;/code>.&lt;/li>
&lt;li>Provide the version of service in &lt;em>DubboServiceVersion&lt;/em> with default value &lt;code>1.0.0&lt;/code>.&lt;/li>
&lt;li>Choose server or client in &lt;em>Client/Server&lt;/em> with default value &lt;code>server&lt;/code>.&lt;/li>
&lt;li>&lt;em>embeddedZookeeper&lt;/em> is selected by default as service registry look up.&lt;/li>
&lt;li>qos ports activation is not selected by default but if it is, it can be accessed by port &lt;em>22222&lt;/em>.&lt;/li>
&lt;li>Click &lt;em>Generate Project&lt;/em> to download the generated project.&lt;/li>
&lt;/ol>
&lt;p>This example shows how to generate a server. Similarly, it can generate a &lt;em>client&lt;/em> by selecting client on the generation interface.&lt;/p>
&lt;h3 id="run-1">Run&lt;/h3>
&lt;p>Open the generated project with an IDE and to see the application is a typical Spring Boot application with the following program entry:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@SpringBootApplication&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DemoApplication&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">new&lt;/span> EmbeddedZooKeeper(2181, &lt;span style="color:#cb4b16">false&lt;/span>).start(); &lt;span style="color:#586e75">// #1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> SpringApplication.run(DemoApplication.class, args); &lt;span style="color:#586e75">// #2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Notes&lt;/strong>:&lt;/p>
&lt;ol>
&lt;li>Launch embedded &lt;em>ZooKeeper&lt;/em> on port &lt;em>2181&lt;/em>.&lt;/li>
&lt;li>Launch the context of &lt;em>Spring Boot&lt;/em>.&lt;/li>
&lt;/ol>
&lt;p>Run it directly in IDE and here are the results:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>2018-05-28 16:59:38.072 INFO &lt;span style="color:#2aa198">59943&lt;/span> --- &lt;span style="color:#719e07">[&lt;/span> main&lt;span style="color:#719e07">]&lt;/span> a.b.d.c.e.WelcomeLogoApplicationListener :
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ████████▄ ███ █▄ ▀█████████▄ ▀█████████▄ ▄██████▄
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ███ ▀███ ███ ███ ███ ███ ███ ███ ███ ███
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ███ ███ ███ ███ ▄███▄▄▄██▀ ▄███▄▄▄██▀ ███ ███
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ███ ███ ███ ███ ▀▀███▀▀▀██▄ ▀▀███▀▀▀██▄ ███ ███
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ███ ███ ███ ███ ███ ██▄ ███ ██▄ ███ ███
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ███ ▄███ ███ ███ ███ ███ ███ ███ ███ ███
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ████████▀ ████████▀ ▄█████████▀ ▄█████████▀ ▀██████▀
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> :: Dubbo Spring Boot &lt;span style="color:#719e07">(&lt;/span>v0.1.0&lt;span style="color:#719e07">)&lt;/span> : https://github.com/dubbo/dubbo-spring-boot-project
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> :: Dubbo &lt;span style="color:#719e07">(&lt;/span>v2.0.1&lt;span style="color:#719e07">)&lt;/span> : https://github.com/alibaba/dubbo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> :: Google group : http://groups.google.com/group/dubbo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>2018-05-28 16:59:38.079 INFO &lt;span style="color:#2aa198">59943&lt;/span> --- &lt;span style="color:#719e07">[&lt;/span> main&lt;span style="color:#719e07">]&lt;/span> e.OverrideDubboConfigApplicationListener : Dubbo Config was overridden by externalized configuration &lt;span style="color:#719e07">{&lt;/span>dubbo.application.name&lt;span style="color:#719e07">=&lt;/span>dubbo-demo-server, dubbo.application.qosAcceptForeignIp&lt;span style="color:#719e07">=&lt;/span>false, dubbo.application.qosEnable&lt;span style="color:#719e07">=&lt;/span>true, dubbo.application.qosPort&lt;span style="color:#719e07">=&lt;/span>22222, dubbo.registry.address&lt;span style="color:#719e07">=&lt;/span>zookeeper://localhost:2181?client&lt;span style="color:#719e07">=&lt;/span>curator, dubbo.registry.id&lt;span style="color:#719e07">=&lt;/span>my-registry, dubbo.scan.basePackages&lt;span style="color:#719e07">=&lt;/span>com.example&lt;span style="color:#719e07">}&lt;/span> &lt;span style="color:#586e75">#1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>2018-05-28 16:59:39.624 INFO &lt;span style="color:#2aa198">59943&lt;/span> --- &lt;span style="color:#719e07">[&lt;/span> main&lt;span style="color:#719e07">]&lt;/span> com.example.demo.DemoApplication : Started DemoApplication in 1.746 seconds &lt;span style="color:#719e07">(&lt;/span>JVM running &lt;span style="color:#719e07">for&lt;/span> 2.963&lt;span style="color:#719e07">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Notes&lt;/strong>:&lt;/p>
&lt;ol>
&lt;li>In the printouts, the configuration starting with &lt;code>dubbo.&lt;/code> Is defined in &lt;em>main/resources/application.properties&lt;/em>.&lt;/li>
&lt;/ol>
&lt;h3 id="manage-service-by-telnet">Manage service by Telnet&lt;/h3>
&lt;p>If &lt;em>qos&lt;/em> is activated during generation, the service can be watched and managed by &lt;em>telnet&lt;/em> or &lt;em>nc&lt;/em>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>$ telnet localhost &lt;span style="color:#2aa198">22222&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Trying 127.0.0.1...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Connected to localhost.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Escape character is &lt;span style="color:#2aa198">&amp;#39;^]&amp;#39;&lt;/span>.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ████████▄ ███ █▄ ▀█████████▄ ▀█████████▄ ▄██████▄
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ███ ▀███ ███ ███ ███ ███ ███ ███ ███ ███
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ███ ███ ███ ███ ▄███▄▄▄██▀ ▄███▄▄▄██▀ ███ ███
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ███ ███ ███ ███ ▀▀███▀▀▀██▄ ▀▀███▀▀▀██▄ ███ ███
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ███ ███ ███ ███ ███ ██▄ ███ ██▄ ███ ███
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ███ ▄███ ███ ███ ███ ███ ███ ███ ███ ███
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ████████▀ ████████▀ ▄█████████▀ ▄█████████▀ ▀██████▀
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo&amp;gt;ls
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>As Provider side:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+------------------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>| Provider Service Name |PUB|
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+------------------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>|com.example.HelloService:1.0.0| Y |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+------------------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>As Consumer side:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+---------------------+---+
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>|Consumer Service Name|NUM|
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>+---------------------+---+
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Currently, &lt;em>qos&lt;/em> supports following command lines. For more information please refer to the official document. [^4]:&lt;/p>
&lt;ul>
&lt;li>&lt;em>ls&lt;/em>:List the information of client and server.&lt;/li>
&lt;li>&lt;em>online&lt;/em>:Bring the service online.&lt;/li>
&lt;li>&lt;em>offline&lt;/em>:Bring the service offline.&lt;/li>
&lt;li>&lt;em>help&lt;/em>:View online help.&lt;/li>
&lt;/ul>
&lt;h2 id="summary">Summary&lt;/h2>
&lt;p>In this tutorial, we start with RMI and introduce the basic concepts in Java distributed invocations. Based on interface programming, it disguises remote calls as local by agency and run the service registry and looking up by registry center.&lt;/p>
&lt;p>Then for simplicity, we introduce how to develop a complete Dubbo demo in an easy way of assembled registry and direct Dubbo API oriented programming. Additionally, we look into the usage of &lt;em>ServiceConfig&lt;/em> and &lt;em>RefenceConfig&lt;/em>, which is of great help for further using Spring XML configuration and the programming pattern of Spring Boot.&lt;/p>
&lt;p>Eventually, we give an outline of how to create a Dubbo application quickly based on Spring Boot using the public resources, start.dubbo.io, provided by the Dubbo development team and operate and maintain the Dubbo service by &lt;em>qos&lt;/em>.&lt;/p>
&lt;hr>
&lt;ol>
&lt;li>&lt;a href="https://docs.oracle.com/javase/6/docs/technotes/guides/rmi/hello/hello-world.html">Getting Started Using JavaTM RMI&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://dubbo.apache.org/en/docs/v2.7/user/examples/explicit-target/">Explicit target&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://dubbo.apache.org/en/docs/v2.7/user/references/registry/multicast/">Multicast Registry&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://dubbo.apache.org/en/docs/v2.7/user/references/qos/">Online QOS command&lt;/a>&lt;/li>
&lt;/ol></description></item><item><title>Blog: The third Dubbo meetup has been held in Shenzhen</title><link>https://dubbo.apache.org/en/blog/2018/07/30/the-third-dubbo-meetup-has-been-held-in-shenzhen/</link><pubDate>Mon, 30 Jul 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/07/30/the-third-dubbo-meetup-has-been-held-in-shenzhen/</guid><description>
&lt;p>The third Dubbo meetup has successfully been held in Shenzhen, over 2000 people submitted registration, and over 700 were present, more than 17,000 watched the live online.&lt;/p>
&lt;p>Please enjoy the slides of the topics:&lt;/p>
&lt;ul>
&lt;li>Zhixuan Chen: Dubbo-present-and-2.7-update (Chinese) &lt;a href="https://github.com/dubbo/awesome-dubbo/blob/master/slides/meetup/201807%40shenzhen/dubbo-present-and-2.7-update.pdf">slides&lt;/a>&lt;/li>
&lt;li>Bin Kang: Microservice-in-lexinfintech (Chinese) &lt;a href="https://github.com/dubbo/awesome-dubbo/blob/master/slides/meetup/201807%40shenzhen/microservice-in-lexinfintech.pdf">slides&lt;/a>&lt;/li>
&lt;li>Jialiang lin: sentinel (Chinese) &lt;a href="https://github.com/dubbo/awesome-dubbo/blob/master/slides/meetup/201807%40shenzhen/sentinel.pdf">slides&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Blog: Sentinel: The flow sentinel of Dubbo services</title><link>https://dubbo.apache.org/en/blog/2018/07/27/sentinel-the-flow-sentinel-of-dubbo-services/</link><pubDate>Fri, 27 Jul 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/07/27/sentinel-the-flow-sentinel-of-dubbo-services/</guid><description>
&lt;p>In large clusters there may be thousands of Dubbo service instances in production, with continuous traffic coming in. However, in distributed systems, some services may be unavailable due to various of failure such as traffic surge, high system load, and network latency. If no control actions are performed, this may cause cascading failure, affecting the availability of the service. So we need a powerful library - Sentinel, which can guarantee the stability of the service, to protect the Dubbo service.&lt;/p>
&lt;h2 id="introduction-to-sentinel">Introduction to Sentinel&lt;/h2>
&lt;p>&lt;a href="https://github.com/alibaba/Sentinel">Sentinel&lt;/a> is a powerful library opensourced by Alibaba Middleware Team. Sentinel takes &amp;ldquo;&lt;strong>flow&lt;/strong>&amp;rdquo; as the breakthrough point, and covers multiple fields including flow control, concurrency, circuit breaking and load protection to protect service stability.&lt;/p>
&lt;p>There are mainly three features in Sentinel:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Flow Control&lt;/strong>: Sentinel can control the traffic flow of resource calls based on different runtime metrics (such as QPS, number of threads, system load, etc.), for different invocation paths, and adjust random traffic to appropriate shapes (e.g. uniform speed).&lt;/li>
&lt;li>&lt;strong>Circuit Breaking&lt;/strong>: When a resource in the invocation chain is unstable (average RT increase or exception ratio increase), Sentinel will fast-fail the call request for this resource to avoid affecting other resources, causing cascade failure.&lt;/li>
&lt;li>&lt;strong>System Load Protection&lt;/strong>: Sentinel can be used to protect your server in case the system load goes too high. It helps you to achieve a good balance between system load and incoming requests.&lt;/li>
&lt;/ul>
&lt;p>The commonly used circuit breaker/isolation library in production is &lt;a href="https://github.com/Netflix/Hystrix">Netflix Hystrix&lt;/a>. Hystrix focuses on the concept of isolation, which isolates dependencies (that is resource in Sentinel) through thread pools or semaphores. The benefit of Hystrix thread pool isolation is that the isolation is thorough, but the downside is that you have to create a lot of thread pools, pre-divide dependencies, and allocate thread pools to each dependency. Sentinel provides another idea for resource isolation: it is controlled by &lt;strong>the number of concurrent threads&lt;/strong>. In this way, developer does not need to specify the size of the thread pool in advance, and there is less loss of thread context switching. When the resource is in an unstable state, the response time becomes longer and the number of threads gradually increases. When the number of threads of a resource is raised to a threshold, traffic flow limit is triggered until the stacked thread completes the task and then continues to accept the requests.&lt;/p>
&lt;p>Hystrix uses Circuit Breaker Pattern to automatically fast-fail the service when exception ratio exceeds the threshold. Sentinel&amp;rsquo;s circuit breaking feature is more versatile, which supports two metrics: average response time and failure ratio. Sentinel also provides various invocation chain path and flow control effects support, as well as the ability to adjust the traffic in real time according to the system load to protect the system. At the same time, Sentinel also provides a real-time monitoring API and dashboard, which allows developers to quickly understand the current state of the system and understand the stability of the service. The scenarios are more abundant.&lt;/p>
&lt;h2 id="best-practice-for-using-dubbo-with-sentinel">Best Practice for using Dubbo with Sentinel&lt;/h2>
&lt;p>&lt;a href="https://github.com/dubbo/dubbo-sentinel-support">Sentinel Dubbo Adapter&lt;/a> provides service consumer filter and provider filter for Dubbo services. We can add the following dependency in &lt;code>pom.xml&lt;/code> (if you are using Maven):&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>com.alibaba.csp&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>sentinel-dubbo-adapter&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>x.y.z&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The two filters are enabled by default. Once you add the dependency, the Dubbo services and methods will become protected resources in Sentinel, which can leverage Sentinel&amp;rsquo;s flow control and guard ability when rules are configured. If you don&amp;rsquo;t want to enable the filter, you can manually disable it. For example:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Bean&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> ConsumerConfig &lt;span style="color:#268bd2">consumerConfig&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ConsumerConfig consumerConfig &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ConsumerConfig();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> consumerConfig.setFilter(&lt;span style="color:#2aa198">&amp;#34;-sentinel.dubbo.consumer.filter&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> consumerConfig;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>We&amp;rsquo;ve provided sereval demos, you can check here: &lt;a href="https://github.com/alibaba/Sentinel/tree/master/sentinel-demo/sentinel-demo-dubbo">sentinel-demo-dubbo&lt;/a>。&lt;/p>
&lt;h3 id="service-provider">Service Provider&lt;/h3>
&lt;p>Dubbo service providers provide services for outside world and handle requests from consumers. To protect the service provider from suffering the proliferation of traffic flow, you can set flow rules in &lt;strong>QPS mode&lt;/strong> to the service provider. Thus, when the number of requests per second exceeds the threshold, new requests are automatically rejected.&lt;/p>
&lt;p>The flow control for Dubbo services has two granularities: service interface and service method.&lt;/p>
&lt;ul>
&lt;li>Service interface:resourceName format is &lt;code>interfaceName&lt;/code>,e.g. &lt;code>com.alibaba.csp.sentinel.demo.dubbo.FooService&lt;/code>&lt;/li>
&lt;li>Service method:resourceName format is &lt;code>interfaceName:methodSignature&lt;/code>,e.g. &lt;code>com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String)&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>For the detail of flow rule configuration and flow control, please refer to &lt;a href="https://github.com/alibaba/Sentinel/wiki/Flow-Control">Flow Control | Sentinel&lt;/a>.&lt;/p>
&lt;p>Let&amp;rsquo;s take a look at the effect of the QPS flow control. Assume that we have a service interface &lt;code>com.alibaba.csp.sentinel.demo.dubbo.FooService&lt;/code>, which contains a method &lt;code>sayHello(java.lang.String)&lt;/code>. We set flow rule for service provider (QPS count = 10). Then we do RPC 15 times at service consumer continuously in 1s. We can see the blocked metrics in the log. The log of blocked calls is located in &lt;code>~/logs/csp/sentinel-block.log&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>2018-07-24 17:13:43|1|com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String),FlowException,default,|5,0
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Log messages will also appear in provider&amp;rsquo;s metric log:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>1532423623000|2018-07-24 17:13:43|com.alibaba.csp.sentinel.demo.dubbo.FooService|15|0|15|0|3
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>1532423623000|2018-07-24 17:13:43|com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String)|10|5|10|0|0
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In many circumstances, it&amp;rsquo;s also significant to control traffic flow based on the &lt;strong>caller&lt;/strong>. For example, assuming that there are two services A and B, both of them initiate remote call requests to the service provider. If we want to limit the calls from service B only, we can set the &lt;code>limitApp&lt;/code> of flow rule as the identifier of service B (e.g. service name). The Sentinel Dubbo Adapter will automatically resolve the Dubbo consumer&amp;rsquo;s &lt;em>application name&lt;/em> as the caller&amp;rsquo;s name (&lt;code>origin&lt;/code>), and will bring the caller&amp;rsquo;s name when doing resource protection. If &lt;code>limitApp&lt;/code> of flow rules is not configured (&lt;code>default&lt;/code>), flow control will take effects on all callers. If &lt;code>limitApp&lt;/code> of a flow rule is configured with a caller, then the corresponding flow rule will only take effect on the specific caller.&lt;/p>
&lt;blockquote>
&lt;p>Note: Dubbo consumer does not provide its Dubbo application name when doing RPC, so developers should manually put the application name into &lt;em>attachment&lt;/em> at consumer side, then extract it at provider side. Sentinel Dubbo Adapter has implemented a filter where consumer can carry application name information to provider automatically. If the counsmer does not use Sentinel Dubbo Adapter but requires flow control based on caller, developers can manually put the application name into attachment with the key &lt;code>dubboApplication&lt;/code>.&lt;/p>
&lt;/blockquote>
&lt;p>The &lt;code>sentinel-block.log&lt;/code> will also record caller name. For example:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>2018-07-25 16:26:48|1|com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String),FlowException,default,demo-consumer|5,0
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The &lt;code>demo-consumer&lt;/code> in the log is the caller name (origin).&lt;/p>
&lt;h3 id="service-consumer">Service Consumer&lt;/h3>
&lt;p>Dubbo service consumers act as a client to invoke the remote service. Each service may depend on several downstream services. If a service A depends on the downstream service B, and service B is unstable (i.e. the response time becomes longer), the number of threads where service A invokes service B will accumulate, thus may eventually run out of service A&amp;rsquo;s thread pool. We use the thread count to control access to downstream service B. This can ensure service itself not affected by others when downstream services are not stable and reliable. Based on this scenario, it is recommended to set flow rules with &lt;strong>thread count mode&lt;/strong> to consumers so that it&amp;rsquo;s not affected by unstable services.&lt;/p>
&lt;p>The thread-count-based flow control mode does not require us to explicitly perform thread pool isolation. Sentinel will control the number of threads of the resource, and the excess requests will be rejected directly until the stacked tasks are completed.&lt;/p>
&lt;h3 id="sentinel-dashboard">Sentinel Dashboard&lt;/h3>
&lt;p>For ease of use, Sentinel provides a Dashboard for configuring rules, viewing monitoring metrics, machine discovery, and more. We only need to start the dashborad according to the &lt;a href="https://github.com/alibaba/Sentinel/wiki/Dashboard">Sentinel dashboard documentation&lt;/a>, then add the appropriate parameters to the corresponding application and launch it. For example, the startup parameters of the service provider demo in this article is:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>-Djava.net.preferIPv4Stack&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#b58900">true&lt;/span> -Dcsp.sentinel.api.port&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">8720&lt;/span> -Dcsp.sentinel.dashboard.server&lt;span style="color:#719e07">=&lt;/span>localhost:8080 -Dproject.name&lt;span style="color:#719e07">=&lt;/span>dubbo-provider-demo
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>After launching the service provider demo, we can find our application in the Sentinel dashboard. It&amp;rsquo;s convenient to configure the rules in the dashboard:&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/sentinel-dashboard-view-rules.png" alt="Rule List">&lt;/p>
&lt;p>Or view real-time metrics:&lt;/p>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/sentinel-dashboard-metrics.png" alt="Real-time metrics monitoring">&lt;/p>
&lt;h2 id="summary">Summary&lt;/h2>
&lt;p>This blog post only introduces the simplest scenario in Sentinel - Traffic Flow Control. Sentinel can handle more complex scenarios like circuit breaking, cold starting and uniform traffic flow. For more scenarios, you can dig into &lt;a href="https://github.com/alibaba/Sentinel/wiki">Sentinel Wiki&lt;/a>.&lt;/p></description></item><item><title>Blog: Tracking with Pinpoint</title><link>https://dubbo.apache.org/en/blog/2018/07/12/tracking-with-pinpoint/</link><pubDate>Thu, 12 Jul 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/07/12/tracking-with-pinpoint/</guid><description>
&lt;p>After using Dubbo to serve or integrate applications, assuming that a service backstage log shows an exception and that the service is invoked by multiple applications, it is often difficult to determine which application is called, and what is the cause of the problem, so we need a set of distributed tracking systems to quickly locate the problem. Pinpoint can help us quickly locate problems (of course, there are more than one solution).&lt;/p>
&lt;h2 id="what-is-pinpoint">What is Pinpoint&lt;/h2>
&lt;p>&lt;a href="https://github.com/naver/pinpoint">Pinpoint&lt;/a> is an APM (Application Performance Management) tool for large-scale distributed systems written in Java. Inspired by Dapper, Pinpoint provides a solution to help analyze the overall structure of the system and how components within them are interconnected by tracing transactions across distributed applications.&lt;/p>
&lt;p>You should definitely check Pinpoint out If you want to&lt;/p>
&lt;p>understand your application topology at a glance
monitor your application in Real-Time
gain code-level visibility to every transaction
install APM Agents without changing a single line of code
have minimal impact on the performance (approximately 3% increase in resource usage)&lt;/p>
&lt;h3 id="servermap">ServerMap&lt;/h3>
&lt;p>Understand the topology of any distributed systems by visualizing how their components are interconnected. Clicking on a node reveals details about the component, such as its current status, and transaction count.&lt;/p>
&lt;h3 id="realtime-active-thread-chart">Realtime Active Thread Chart&lt;/h3>
&lt;p>Monitor active threads inside applications in real-time.&lt;/p>
&lt;h3 id="requestresponse-scatter-chart">Request/Response Scatter Chart&lt;/h3>
&lt;p>Visualize request count and response patterns over time to identify potential problems. Transactions can be selected for additional detail by dragging over the chart.&lt;/p>
&lt;h3 id="callstack">CallStack&lt;/h3>
&lt;p>Gain code-level visibility to every transaction in a distributed environment, identifying bottlenecks and points of failure in a single view.&lt;/p>
&lt;h3 id="inspector">Inspector&lt;/h3>
&lt;p>View additional details on the application such as CPU usage, Memory/Garbage Collection, TPS, and JVM arguments.&lt;/p>
&lt;h3 id="supported-modules-last-updated-20180401">Supported Modules (last updated 2018/04/01)&lt;/h3>
&lt;ul>
&lt;li>JDK 6+&lt;/li>
&lt;li>Tomcat 6/7/8, Jetty 8/9, JBoss EAP 6, Resin 4, Websphere 6/7/8, Vertx 3.3/3.4/3.5&lt;/li>
&lt;li>Spring, Spring Boot (Embedded Tomcat, Jetty)&lt;/li>
&lt;li>Apache HTTP Client 3.x/4.x, JDK HttpConnector, GoogleHttpClient, OkHttpClient, NingAsyncHttpClient&lt;/li>
&lt;li>Thrift Client, Thrift Service, DUBBO PROVIDER, DUBBO CONSUMER&lt;/li>
&lt;li>ActiveMQ, RabbitMQ&lt;/li>
&lt;li>MySQL, Oracle, MSSQL, CUBRID,POSTGRESQL, MARIA&lt;/li>
&lt;li>Arcus, Memcached, Redis, CASSANDRA&lt;/li>
&lt;li>iBATIS, MyBatis&lt;/li>
&lt;li>DBCP, DBCP2, HIKARICP&lt;/li>
&lt;li>gson, Jackson, Json Lib&lt;/li>
&lt;li>log4j, Logback&lt;/li>
&lt;/ul>
&lt;h2 id="pinpoint-and-dubbo">Pinpoint and Dubbo&lt;/h2>
&lt;h3 id="quickstart-pinpoint">Quickstart Pinpoint&lt;/h3>
&lt;p>&lt;a href="https://pinpoint-apm.github.io/pinpoint/quickstart.html">Quick start&lt;/a>(No neet to start TestApp)&lt;/p>
&lt;h3 id="dubbo-demo">Dubbo demo&lt;/h3>
&lt;h4 id="create-api-module">Create API module&lt;/h4>
&lt;p>pom.xml&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-8&amp;#34;?&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;project&lt;/span> xmlns=&lt;span style="color:#2aa198">&amp;#34;http://maven.apache.org/POM/4.0.0&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xmlns:xsi=&lt;span style="color:#2aa198">&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xsi:schemaLocation=&lt;span style="color:#2aa198">&amp;#34;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;modelVersion&amp;gt;&lt;/span>4.0.0&lt;span style="color:#268bd2">&amp;lt;/modelVersion&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>com.example&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>demo-api&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>0.0.1-SNAPSHOT&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/project&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Create API interface:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-go" data-lang="go">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> com.example.demoapi;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>public &lt;span style="color:#268bd2">interface&lt;/span> HelloService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="dubbo-provider">Dubbo provider&lt;/h4>
&lt;p>pom.xml&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-8&amp;#34;?&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;project&lt;/span> xmlns=&lt;span style="color:#2aa198">&amp;#34;http://maven.apache.org/POM/4.0.0&amp;#34;&lt;/span> xmlns:xsi=&lt;span style="color:#2aa198">&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xsi:schemaLocation=&lt;span style="color:#2aa198">&amp;#34;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;modelVersion&amp;gt;&lt;/span>4.0.0&lt;span style="color:#268bd2">&amp;lt;/modelVersion&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>com.example&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>demo-provider&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>0.0.1-SNAPSHOT&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;packaging&amp;gt;&lt;/span>jar&lt;span style="color:#268bd2">&amp;lt;/packaging&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;name&amp;gt;&lt;/span>demo-provider&lt;span style="color:#268bd2">&amp;lt;/name&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;parent&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.springframework.boot&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>spring-boot-starter-parent&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>2.0.3.RELEASE&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;relativePath/&amp;gt;&lt;/span> &lt;span style="color:#586e75">&amp;lt;!-- lookup parent from repository --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/parent&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;properties&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;project.build.sourceEncoding&amp;gt;&lt;/span>UTF-8&lt;span style="color:#268bd2">&amp;lt;/project.build.sourceEncoding&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;project.reporting.outputEncoding&amp;gt;&lt;/span>UTF-8&lt;span style="color:#268bd2">&amp;lt;/project.reporting.outputEncoding&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;java.version&amp;gt;&lt;/span>1.8&lt;span style="color:#268bd2">&amp;lt;/java.version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/properties&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;repositories&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;repository&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;id&amp;gt;&lt;/span>sonatype-nexus-snapshots&lt;span style="color:#268bd2">&amp;lt;/id&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;url&amp;gt;&lt;/span>https://oss.sonatype.org/content/repositories/snapshots&lt;span style="color:#268bd2">&amp;lt;/url&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;releases&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;enabled&amp;gt;&lt;/span>false&lt;span style="color:#268bd2">&amp;lt;/enabled&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/releases&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;snapshots&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;enabled&amp;gt;&lt;/span>true&lt;span style="color:#268bd2">&amp;lt;/enabled&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/snapshots&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/repository&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/repositories&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dependencies&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.springframework.boot&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>spring-boot-starter&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>com.alibaba.boot&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>dubbo-spring-boot-starter&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>0.2.0&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>com.example&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>demo-api&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>0.0.1-SNAPSHOT&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.springframework.boot&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>spring-boot-starter-test&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;scope&amp;gt;&lt;/span>test&lt;span style="color:#268bd2">&amp;lt;/scope&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dependencies&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;build&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;plugins&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;plugin&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.springframework.boot&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>spring-boot-maven-plugin&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/plugin&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/plugins&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/build&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/project&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>&lt;code>HelloService&lt;/code> interface:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> com.example.demoprovider.provider;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> com.alibaba.dubbo.config.annotation.Service;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> com.example.demoapi.HelloService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Service&lt;/span>(version &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;${demo.service.version}&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> application &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;${dubbo.application.id}&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> protocol &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;${dubbo.protocol.id}&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> registry &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;${dubbo.registry.id}&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">HelloServiceImpl&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> HelloService {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">int&lt;/span> i &lt;span style="color:#719e07">=&lt;/span> 0;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> i&lt;span style="color:#719e07">++&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (i &lt;span style="color:#719e07">%&lt;/span> 3 &lt;span style="color:#719e07">==&lt;/span> 0) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">throw&lt;/span> &lt;span style="color:#719e07">new&lt;/span> RuntimeException(&lt;span style="color:#2aa198">&amp;#34;ex&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#2aa198">&amp;#34;Hello &amp;#34;&lt;/span> &lt;span style="color:#719e07">+&lt;/span> name &lt;span style="color:#719e07">+&lt;/span> &lt;span style="color:#2aa198">&amp;#34;!&amp;#34;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="2">
&lt;li>Spring Boot bootstrap:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> com.example.demoprovider;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.springframework.boot.SpringApplication;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.springframework.boot.autoconfigure.SpringBootApplication;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@SpringBootApplication&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DemoProviderApplication&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> SpringApplication.run(DemoProviderApplication.class, args);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="3">
&lt;li>&lt;code>application.properties&lt;/code>:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-properties" data-lang="properties">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"># Spring boot application&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>spring.application.name &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">dubbo-provider-demo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>server.port &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">9090&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>management.port &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">9091&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"># Service version&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>demo.service.version &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">1.0.0&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"># Base packages to scan Dubbo Components (e.g @Service , @Reference)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.scan.basePackages &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">com.example.demoprovider&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"># Dubbo Config properties&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">## ApplicationConfig Bean&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.application.id &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">dubbo-provider-demo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.application.name &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">dubbo-provider-demo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">## ProtocolConfig Bean&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.protocol.id &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">dubbo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.protocol.name &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">dubbo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.protocol.port &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">12345&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">## RegistryConfig Bean&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.registry.id &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">my-registry&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.registry.address &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">N/A&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="dubbo-consumer">Dubbo consumer&lt;/h4>
&lt;p>pom.xml&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-8&amp;#34;?&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;project&lt;/span> xmlns=&lt;span style="color:#2aa198">&amp;#34;http://maven.apache.org/POM/4.0.0&amp;#34;&lt;/span> xmlns:xsi=&lt;span style="color:#2aa198">&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> xsi:schemaLocation=&lt;span style="color:#2aa198">&amp;#34;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&amp;#34;&lt;/span>&lt;span style="color:#268bd2">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;modelVersion&amp;gt;&lt;/span>4.0.0&lt;span style="color:#268bd2">&amp;lt;/modelVersion&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>com.example&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>demo-consumer&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>0.0.1-SNAPSHOT&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;packaging&amp;gt;&lt;/span>jar&lt;span style="color:#268bd2">&amp;lt;/packaging&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;name&amp;gt;&lt;/span>demo-consumer&lt;span style="color:#268bd2">&amp;lt;/name&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;parent&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.springframework.boot&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>spring-boot-starter-parent&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>2.0.3.RELEASE&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;relativePath/&amp;gt;&lt;/span> &lt;span style="color:#586e75">&amp;lt;!-- lookup parent from repository --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/parent&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;properties&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;project.build.sourceEncoding&amp;gt;&lt;/span>UTF-8&lt;span style="color:#268bd2">&amp;lt;/project.build.sourceEncoding&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;project.reporting.outputEncoding&amp;gt;&lt;/span>UTF-8&lt;span style="color:#268bd2">&amp;lt;/project.reporting.outputEncoding&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;java.version&amp;gt;&lt;/span>1.8&lt;span style="color:#268bd2">&amp;lt;/java.version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/properties&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;repositories&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;repository&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;id&amp;gt;&lt;/span>sonatype-nexus-snapshots&lt;span style="color:#268bd2">&amp;lt;/id&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;url&amp;gt;&lt;/span>https://oss.sonatype.org/content/repositories/snapshots&lt;span style="color:#268bd2">&amp;lt;/url&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;releases&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;enabled&amp;gt;&lt;/span>false&lt;span style="color:#268bd2">&amp;lt;/enabled&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/releases&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;snapshots&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;enabled&amp;gt;&lt;/span>true&lt;span style="color:#268bd2">&amp;lt;/enabled&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/snapshots&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/repository&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/repositories&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dependencies&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.springframework.boot&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>spring-boot-starter-web&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>com.alibaba.boot&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>dubbo-spring-boot-starter&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>0.2.0&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>com.example&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>demo-api&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;version&amp;gt;&lt;/span>0.0.1-SNAPSHOT&lt;span style="color:#268bd2">&amp;lt;/version&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.springframework.boot&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>spring-boot-starter-test&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;scope&amp;gt;&lt;/span>test&lt;span style="color:#268bd2">&amp;lt;/scope&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dependency&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/dependencies&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;build&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;plugins&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;plugin&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;groupId&amp;gt;&lt;/span>org.springframework.boot&lt;span style="color:#268bd2">&amp;lt;/groupId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;artifactId&amp;gt;&lt;/span>spring-boot-maven-plugin&lt;span style="color:#268bd2">&amp;lt;/artifactId&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;configuration&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;classifier&amp;gt;&lt;/span>exec&lt;span style="color:#268bd2">&amp;lt;/classifier&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/configuration&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/plugin&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/plugins&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">&amp;lt;/build&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;/project&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>&lt;code>@Reference&lt;/code> injection &lt;code>HelloService&lt;/code>&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> com.example.democonsumer.controller;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> com.alibaba.dubbo.config.annotation.Reference;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> com.example.demoapi.HelloService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.springframework.web.bind.annotation.RequestMapping;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.springframework.web.bind.annotation.RequestParam;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.springframework.web.bind.annotation.RestController;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@RestController&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DemoConsumerController&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Reference&lt;/span>(version &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;${demo.service.version}&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> application &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;${dubbo.application.id}&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> url &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;dubbo://&amp;lt;Real IP Address&amp;gt;:12345&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> HelloService helloService;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@RequestMapping&lt;/span>(&lt;span style="color:#2aa198">&amp;#34;/sayHello&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">sayHello&lt;/span>(&lt;span style="color:#268bd2">@RequestParam&lt;/span> String name) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> helloService.sayHello(name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="2">
&lt;li>Spring Boot bootstrap:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> com.example.democonsumer;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.springframework.boot.SpringApplication;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">import&lt;/span> org.springframework.boot.autoconfigure.SpringBootApplication;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@SpringBootApplication&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">DemoConsumerApplication&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">main&lt;/span>(String&lt;span style="color:#719e07">[]&lt;/span> args) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> SpringApplication.run(DemoConsumerApplication.class, args);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="3">
&lt;li>&lt;code>application.properties&lt;/code>:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-properties" data-lang="properties">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"># Spring boot application&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>spring.application.name&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">dubbo-consumer-demo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>server.port&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">8080&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>management.port&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">8081&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"># Service Version&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>demo.service.version&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">1.0.0&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75"># Dubbo Config properties&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">## ApplicationConfig Bean&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.application.id&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">dubbo-consumer-demo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.application.name&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">dubbo-consumer-demo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">## ProtocolConfig Bean&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.protocol.id&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">dubbo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.protocol.name&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">dubbo&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dubbo.protocol.port&lt;span style="color:#719e07">=&lt;/span>&lt;span style="color:#2aa198">12345&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="using-pinpoint-agent-to-start-dubbo-provider-and-dubbo-consumer">Using Pinpoint-agent to start &lt;code>Dubbo provider&lt;/code> and &lt;code>Dubbo consumer&lt;/code>&lt;/h3>
&lt;ol>
&lt;li>Maven clean package&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>mvn clean package
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="2">
&lt;li>Start provider&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>java -jar -javaagent:$AGENT_PATH/pinpoint-bootstrap-$VERSION.jar -Dpinpoint.agentId=demo-provider -Dpinpoint.applicationName=DP target/demo-provider-0.0.1-SNAPSHOT.jar
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="3">
&lt;li>Start consumer&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>java -jar -javaagent:$AGENT_PATH/pinpoint-bootstrap-$VERSION.jar -Dpinpoint.agentId=demo-consumer -Dpinpoint.applicationName=DC target/demo-comsumer-0.0.1-SNAPSHOT-exec.jar
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol start="4">
&lt;li>Access the consumer address to simulate user requests&lt;/li>
&lt;/ol>
&lt;p>&lt;code>http://localhost:8080/sayHello?name=ABC&lt;/code>&lt;/p>
&lt;h2 id="using-pinpoint-locate-problems">Using Pinpoint locate problems&lt;/h2>
&lt;h3 id="homepage">Homepage&lt;/h3>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/en_pinpoint-home.png" alt="/admin-guide/images/pinpoint-home.png">&lt;/p>
&lt;blockquote>
&lt;p>The user request here is double the number of requests for DubboProvider, because the favicon.ico icon request is recorded.&lt;/p>
&lt;/blockquote>
&lt;h3 id="call-tree">Call tree&lt;/h3>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/en_pinpoint-calltree.png" alt="/admin-guide/images/pinpoint-calltree.png">&lt;/p>
&lt;h3 id="mixed-view">Mixed view&lt;/h3>
&lt;p>&lt;img src="https://dubbo.apache.org/imgs/blog/en_pinpoint-mixedview.png" alt="/admin-guide/images/pinpoint-mixedview.png">&lt;/p>
&lt;h3 id="other">Other&lt;/h3>
&lt;p>The example simply simulates the provision and call of Dubbo, and does not carry out the application of other middleware such as database. For detailed use, please refer to the Pinpoint document.&lt;/p></description></item><item><title>Blog: Your First Dubbo Filter</title><link>https://dubbo.apache.org/en/blog/2018/07/01/your-first-dubbo-filter/</link><pubDate>Sun, 01 Jul 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/07/01/your-first-dubbo-filter/</guid><description>
&lt;h3 id="overview">Overview&lt;/h3>
&lt;p>In overall design of Dubbo, Filter is a very important concept, most of Dubbo&amp;rsquo;s functions are based on this
extension point, and the Filter interception will be executed during each call.&lt;/p>
&lt;h4 id="extension-mechanism-of-dubbo-filter">Extension Mechanism of Dubbo Filter&lt;/h4>
&lt;p>There are already about 20 Filters implemented in Dubbo. Their entry is ProtocolFilterWrapper, ProtocolFilterWrapper
makes a Wrapper on Protocol and will be loaded when the extension is loaded. Then, let&amp;rsquo;s see how
the Filter chain is constructed.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">//ProtocolFilterWrapper.java&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">refer&lt;/span>(Class&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> type, URL url) &lt;span style="color:#268bd2">throws&lt;/span> RpcException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (Constants.REGISTRY_PROTOCOL.equals(url.getProtocol())) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> protocol.refer(type, url);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> buildInvokerChain(protocol.refer(type, url), Constants.REFERENCE_FILTER_KEY, Constants.CONSUMER);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">private&lt;/span> &lt;span style="color:#268bd2">static&lt;/span> &lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">buildInvokerChain&lt;/span>(&lt;span style="color:#268bd2">final&lt;/span> Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> invoker, String key, String group) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> last &lt;span style="color:#719e07">=&lt;/span> invoker;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> List&lt;span style="color:#719e07">&amp;lt;&lt;/span>Filter&lt;span style="color:#719e07">&amp;gt;&lt;/span> filters &lt;span style="color:#719e07">=&lt;/span> ExtensionLoader.getExtensionLoader(Filter.class).getActivateExtension(invoker.getUrl(), key, group);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (filters.size() &lt;span style="color:#719e07">&amp;gt;&lt;/span> 0) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (&lt;span style="color:#dc322f">int&lt;/span> i &lt;span style="color:#719e07">=&lt;/span> filters.size() &lt;span style="color:#719e07">-&lt;/span> 1; i &lt;span style="color:#719e07">&amp;gt;=&lt;/span> 0; i &lt;span style="color:#719e07">--&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">final&lt;/span> Filter filter &lt;span style="color:#719e07">=&lt;/span> filters.get(i);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">final&lt;/span> Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> next &lt;span style="color:#719e07">=&lt;/span> last;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> last &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> Invoker&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> Class&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">getInterface&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> invoker.getInterface();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> URL &lt;span style="color:#268bd2">getUrl&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> invoker.getUrl();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">boolean&lt;/span> &lt;span style="color:#268bd2">isAvailable&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> invoker.isAvailable();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> Result &lt;span style="color:#268bd2">invoke&lt;/span>(Invocation invocation) &lt;span style="color:#268bd2">throws&lt;/span> RpcException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> filter.invoke(next, invocation);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#dc322f">void&lt;/span> &lt;span style="color:#268bd2">destroy&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> invoker.destroy();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">@Override&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> String &lt;span style="color:#268bd2">toString&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> invoker.toString();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> };
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> last;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="activation-mechanism-of-dubbo-filter">Activation Mechanism of Dubbo Filter&lt;/h4>
&lt;p>Through the above code we can see that, in the method buildInvokerChain, first get all
activated chains, the chain here is already sorted. Then construct a call chain of Filter
through the Invoker, finally the constructed call chain can be roughly expressed as: Filter1-&amp;gt;Filter2-&amp;gt;Filter3-&amp;gt;&amp;hellip;&amp;hellip;-&amp;gt;Invoker,
now let&amp;rsquo;s see the detailed flow of the activated chain in the above step.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> List&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">getActivateExtension&lt;/span>(URL url, String key, String group) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String value &lt;span style="color:#719e07">=&lt;/span> url.getParameter(key);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> getActivateExtension(url, value &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span> &lt;span style="color:#719e07">||&lt;/span> value.length() &lt;span style="color:#719e07">==&lt;/span> 0 &lt;span style="color:#719e07">?&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span> : Constants.COMMA_SPLIT_PATTERN.split(value), group);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> List&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> &lt;span style="color:#268bd2">getActivateExtension&lt;/span>(URL url, String&lt;span style="color:#719e07">[]&lt;/span> values, String group) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> List&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> exts &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ArrayList&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> List&lt;span style="color:#719e07">&amp;lt;&lt;/span>String&lt;span style="color:#719e07">&amp;gt;&lt;/span> names &lt;span style="color:#719e07">=&lt;/span> values &lt;span style="color:#719e07">==&lt;/span> &lt;span style="color:#cb4b16">null&lt;/span> &lt;span style="color:#719e07">?&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ArrayList&lt;span style="color:#719e07">&amp;lt;&lt;/span>String&lt;span style="color:#719e07">&amp;gt;&lt;/span>(0) : Arrays.asList(values);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (&lt;span style="color:#719e07">!&lt;/span> names.contains(Constants.REMOVE_VALUE_PREFIX &lt;span style="color:#719e07">+&lt;/span> Constants.DEFAULT_KEY)) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> getExtensionClasses();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (Map.Entry&lt;span style="color:#719e07">&amp;lt;&lt;/span>String, Activate&lt;span style="color:#719e07">&amp;gt;&lt;/span> entry : cachedActivates.entrySet()) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String name &lt;span style="color:#719e07">=&lt;/span> entry.getKey();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Activate activate &lt;span style="color:#719e07">=&lt;/span> entry.getValue();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (isMatchGroup(group, activate.group())) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> T ext &lt;span style="color:#719e07">=&lt;/span> getExtension(name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (&lt;span style="color:#719e07">!&lt;/span> names.contains(name) &lt;span style="color:#719e07">&amp;amp;&amp;amp;&lt;/span> &lt;span style="color:#719e07">!&lt;/span> names.contains(Constants.REMOVE_VALUE_PREFIX &lt;span style="color:#719e07">+&lt;/span> name)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;amp;&amp;amp;&lt;/span> isActive(activate, url)) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> exts.add(ext);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Collections.sort(exts, ActivateComparator.COMPARATOR);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> List&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span> usrs &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#719e07">new&lt;/span> ArrayList&lt;span style="color:#719e07">&amp;lt;&lt;/span>T&lt;span style="color:#719e07">&amp;gt;&lt;/span>();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">for&lt;/span> (&lt;span style="color:#dc322f">int&lt;/span> i &lt;span style="color:#719e07">=&lt;/span> 0; i &lt;span style="color:#719e07">&amp;lt;&lt;/span> names.size(); i &lt;span style="color:#719e07">++&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> String name &lt;span style="color:#719e07">=&lt;/span> names.get(i);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (&lt;span style="color:#719e07">!&lt;/span> name.startsWith(Constants.REMOVE_VALUE_PREFIX)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">&amp;amp;&amp;amp;&lt;/span> &lt;span style="color:#719e07">!&lt;/span> names.contains(Constants.REMOVE_VALUE_PREFIX &lt;span style="color:#719e07">+&lt;/span> name)) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (Constants.DEFAULT_KEY.equals(name)) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (usrs.size() &lt;span style="color:#719e07">&amp;gt;&lt;/span> 0) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> exts.addAll(0, usrs);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> usrs.clear();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } &lt;span style="color:#719e07">else&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> T ext &lt;span style="color:#719e07">=&lt;/span> getExtension(name);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> usrs.add(ext);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (usrs.size() &lt;span style="color:#719e07">&amp;gt;&lt;/span> 0) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> exts.addAll(usrs);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> exts;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Through the above code we can see that, some of the Filters configured by the user are activated by default,
and some need to be activated by the configuration file. The loading order of all Filters is to process Dubbo&amp;rsquo;s
default Filter first, and then to process the Filter defined by the user. With the &amp;ldquo;-&amp;rdquo; configuration, Dubbo&amp;rsquo;s defualt Filter
can be replaced, with this configuration, the user can flexibly replace or modify the Filter&amp;rsquo;s load order.&lt;/p>
&lt;h4 id="built-in-filter-of-dubbo">Built-in Filter of Dubbo&lt;/h4>
&lt;p>Dubbo has lots of built-in Filter. RpcContext, accesslog and other functions can be implemented by Dubbo.
Now let&amp;rsquo;s see the ConsumerContextFilter which used by the Consumer side for context delivery:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> Result &lt;span style="color:#268bd2">invoke&lt;/span>(Invoker&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&lt;/span> invoker, Invocation invocation) &lt;span style="color:#268bd2">throws&lt;/span> RpcException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> RpcContext.getContext()
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> .setInvoker(invoker)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> .setInvocation(invocation)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> .setLocalAddress(NetUtils.getLocalHost(), 0)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> .setRemoteAddress(invoker.getUrl().getHost(),
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> invoker.getUrl().getPort());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">if&lt;/span> (invocation &lt;span style="color:#719e07">instanceof&lt;/span> RpcInvocation) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ((RpcInvocation)invocation).setInvoker(invoker);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">try&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> invoker.invoke(invocation);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> } &lt;span style="color:#719e07">finally&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> RpcContext.getContext().clearAttachments();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This Filter records the state information during call, and passes the attachments parameter set
by the client to the server through the invocation object, and these parameters will be cleared
after the call is completed, which is why the request status information can be recorded by times
and delivered.&lt;/p>
&lt;h4 id="implement-a-dubbo-filter">Implement A Dubbo Filter&lt;/h4>
&lt;p>Because of Dubbo&amp;rsquo;s flexible design and good scalability, we can implement business logic
in the call chain by implementing our own Dubbo Filter, such as time-consuming statistics, monitor information statistics, etc.
Now, let&amp;rsquo;s implement a simple Filter:&lt;/p>
&lt;p>Maven project structure:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>src
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> |-main
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> |-java
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> |-com
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> |-xxx
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> |-XxxFilter.java (impelement Filter interface)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> |-resources
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> |-META-INF
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> |-dubbo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> |-com.alibaba.dubbo.rpc.Filter (Plain text file with content:xxx=com.xxx.XxxFilter)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>XxxFilter.java:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">XxxFilter&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> Filter {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">public&lt;/span> Result &lt;span style="color:#268bd2">invoke&lt;/span>(Invoker&lt;span style="color:#719e07">&amp;lt;?&amp;gt;&lt;/span> invoker, Invocation invocation) &lt;span style="color:#268bd2">throws&lt;/span> RpcException {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// before filter ...&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Result result &lt;span style="color:#719e07">=&lt;/span> invoker.invoke(invocation);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// after filter ...&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#719e07">return&lt;/span> result;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>META-INF/dubbo/com.alibaba.dubbo.rpc.Filter:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>xxx=com.xxx.XxxFilter
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>configure in xml as:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">&amp;lt;!-- Consumer call process interception --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:reference&lt;/span> filter=&lt;span style="color:#2aa198">&amp;#34;xxx&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">&amp;lt;!-- Consumer call process default interception,intercept all reference --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:consumer&lt;/span> filter=&lt;span style="color:#2aa198">&amp;#34;xxx&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">&amp;lt;!-- Provider call process interception --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:service&lt;/span> filter=&lt;span style="color:#2aa198">&amp;#34;xxx&amp;#34;&lt;/span> &lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#586e75">&amp;lt;!-- Provider call process default interception,intercept all service --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">&amp;lt;dubbo:provider&lt;/span> filter=&lt;span style="color:#2aa198">&amp;#34;xxx&amp;#34;&lt;/span>&lt;span style="color:#268bd2">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>or use annotation as:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-java" data-lang="java">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">@Activate&lt;/span>(group &lt;span style="color:#719e07">=&lt;/span> &lt;span style="color:#2aa198">&amp;#34;consumer&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">public&lt;/span> &lt;span style="color:#268bd2">class&lt;/span> &lt;span style="color:#268bd2">XxxFilter&lt;/span> &lt;span style="color:#268bd2">implements&lt;/span> Filter {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#586e75">// ...&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Using xml configuration is more flexible and granular.&lt;/p>
&lt;p>In before and after, you can implement your own business logic to give the filter a certain function.
Once written and configured, the filter is activated by the Dubbo and executed in the call chain.&lt;/p></description></item><item><title>Blog: The second Dubbo Shanghai meetup has been held successfully</title><link>https://dubbo.apache.org/en/blog/2018/06/23/the-second-dubbo-shanghai-meetup-has-been-held-successfully/</link><pubDate>Sat, 23 Jun 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/06/23/the-second-dubbo-shanghai-meetup-has-been-held-successfully/</guid><description>
&lt;p>The sencond Dubbo meetup has successfully been held in Shanghai, over 700 people submitted registration, and over 300 were present, more than 10,000 watched the live online.&lt;/p>
&lt;p>Please enjoy the slides of the topics:&lt;/p>
&lt;ul>
&lt;li>Jerrick Zhu: Dubbo Status and Roadmap (Chinese) &lt;a href="https://github.com/dubbo/awesome-dubbo/blob/master/slides/meetup/201806%40Shanghai/dubbo-status-and-roadmap.pdf">slides&lt;/a>&lt;/li>
&lt;li>Mercy Ma: Dubbo Cloud Native Practices and Thoughts (Chinese) &lt;a href="https://github.com/dubbo/awesome-dubbo/blob/master/slides/meetup/201806%40Shanghai/dubbo-cloud-native-practices-and-thoughts.pdf">slides&lt;/a>&lt;/li>
&lt;li>Ping Guo: Nacos Open Source Initiative (Chinese) &lt;a href="https://github.com/dubbo/awesome-dubbo/blob/master/slides/meetup/201806%40Shanghai/nacos-open-source-initiative.pdf">slides&lt;/a>&lt;/li>
&lt;li>Zhiwei Pan: Dubbo Practices on Internet Finance Industries (Chinese) &lt;a href="https://github.com/dubbo/awesome-dubbo/blob/master/slides/meetup/201806%40Shanghai/dubbo-practices-on-internet-finance-industries.pdf">slides&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Blog: The first Dubbo meetup has been held in Beijing</title><link>https://dubbo.apache.org/en/blog/2018/05/12/the-first-dubbo-meetup-has-been-held-in-beijing/</link><pubDate>Sat, 12 May 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/05/12/the-first-dubbo-meetup-has-been-held-in-beijing/</guid><description>
&lt;p>The first Dubbo meetup has successfully been held in Beijing, over 400+ people were present. What a great event!&lt;/p>
&lt;p>Please enjoy the slides of the topics:&lt;/p>
&lt;ul>
&lt;li>Ian Luo: Dubbo&amp;rsquo;s present and future (Chinese) &lt;a href="https://github.com/dubbo/awesome-dubbo/raw/master/slides/meetup/201805%40Beijing/dubbo-present-and-future.pdf">slides&lt;/a>&lt;/li>
&lt;li>Jun Liu: Introduction to the 4th Aliware Performance Challenge (Chinese) &lt;a href="https://github.com/dubbo/awesome-dubbo/raw/master/slides/meetup/201805%40Beijing/introduction-to-4th-aliware-performance-challenge.pdf">slides&lt;/a>&lt;/li>
&lt;li>Zhixuan Chen: Quickly building Microservice with Dubbo and Spring-boot (Chinese) &lt;a href="https://github.com/dubbo/awesome-dubbo/raw/master/slides/meetup/201805%40Beijing/quickly-building-microservice-with-dubbo-and-springboot.pdf">slides&lt;/a>&lt;/li>
&lt;li>Xin Wang: Dubbo and Weidian&amp;rsquo;s Practice on Microservice Architecture (Chinese) &lt;a href="https://github.com/dubbo/awesome-dubbo/raw/master/slides/meetup/201805%40Beijing/dubbo-and-weidian's-practice-on-microservice-architecture.pdf">slides&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Blog: The ApacheCon NA schedule has been announced</title><link>https://dubbo.apache.org/en/blog/2018/05/02/the-apachecon-na-schedule-has-been-announced/</link><pubDate>Wed, 02 May 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/05/02/the-apachecon-na-schedule-has-been-announced/</guid><description>
&lt;p>Ian Luo(PMC) and Jun Liu(PMC) will talk about &amp;ldquo;Introducing Apache Dubbo(Incubating): What is Dubbo and How it Works&amp;rdquo; at ApacheCon NA this year in Montréal! Please check out the schedule &lt;a href="https://apachecon.dukecon.org/acna/2018/#/scheduledEvent/b8db9dc580d85853f">here&lt;/a> and register &lt;a href="https://www.eventbrite.com/e/apachecon-north-america-2018-registration-43200327342">here&lt;/a>.&lt;/p></description></item><item><title>Blog: The GSoC(Google Summer of Code) 2018</title><link>https://dubbo.apache.org/en/blog/2018/04/25/the-gsocgoogle-summer-of-code-2018/</link><pubDate>Wed, 25 Apr 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/04/25/the-gsocgoogle-summer-of-code-2018/</guid><description>
&lt;p>The GSoC(Google Summer of Code) 2018 projects has been announced, Raghu Reddy&amp;rsquo;s project &amp;ldquo;Extending Serialization protocols support for Apache Dubbo&amp;rdquo; has been &lt;a href="https://summerofcode.withgoogle.com/projects/#4747840161579008">accepted&lt;/a>! Congratulations!&lt;/p></description></item><item><title>Blog: Dubbo roadmap is announced in QCon Beijing 2018</title><link>https://dubbo.apache.org/en/blog/2018/04/22/dubbo-roadmap-is-announced-in-qcon-beijing-2018/</link><pubDate>Sun, 22 Apr 2018 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/2018/04/22/dubbo-roadmap-is-announced-in-qcon-beijing-2018/</guid><description>
&lt;p>Ian Luo has delivered a great talk at QCon Beijing 2018, where the roadmap of Dubbo has also be announced. Please enjoy the &lt;a href="https://github.com/dubbo/awesome-dubbo/raw/master/slides/qcon2018/dubbo-present-and-future.pdf">slides&lt;/a>!&lt;/p></description></item><item><title>Blog: Application-Level Service Discovery</title><link>https://dubbo.apache.org/en/blog/1/01/01/application-level-service-discovery/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/en/blog/1/01/01/application-level-service-discovery/</guid><description/></item></channel></rss>