Dubbo addresses a series of challenges from development, deployment to governance and operation of enterprise microservices. Dubbo provides developers with a full set of services from project creation, development testing, to deployment, visual monitoring, traffic governance, and ecosystem integration.
Next, we will explain the basic steps of Dubbo application development using a Java-based Spring Boot project as an example. The entire process is very intuitive and simple, and the development process for other languages is similar.
Dubbo Microservice Project Scaffolding (supports browser pages, command line, and IDE) can be used to quickly create microservice projects. You only need to tell the scaffolding the desired features or components, and the scaffolding can help developers generate microservice projects with the necessary dependencies. For more explanations on how to use the scaffolding, please refer to the task module Generate Project Scaffolding through Templates
1. Define Service
public interface DemoService {
String hello(String arg);
}
2. Provide Business Logic Implementation
@DubboService
public class DemoServiceImpl implements DemoService {
public String hello(String arg) {
// put your microservice logic here
}
}
1. Publish Service Definition
To ensure that the consumer can successfully call the service, the service provider must first publish the service definition to the Maven central repository in the form of a Jar package.
2. Expose Service
Supplement Dubbo configuration and start Dubbo Server
dubbo:
application:
name: dubbo-demo
protocol:
name: dubbo
port: -1
registry:
address: zookeeper://127.0.0.1:2181
First, the consumer introduces the DemoService
service definition dependency through Maven/Gradle.
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-demo-interface</artifactId>
<version>3.2.0</version>
</dependency>
Programmatically inject the remote Dubbo service instance
@Bean
public class Consumer {
@DubboReference
private DemoService demoService;
}
The above is a procedural explanation of Dubbo microservice development. For detailed guidance steps in actual development, please refer to:
Dubbo native services can be packaged and deployed to cloud-native infrastructures and microservice architectures such as Docker containers, Kubernetes, and service meshes.
For deployment examples in different environments, refer to:
For service governance, most applications only need to add the following configuration, and Dubbo applications will have address discovery and load balancing capabilities.
dubbo:
registry:
address: zookeeper://127.0.0.1:2181
Deploy and open the Dubbo Admin Console, where you can see the service deployment and call data of the cluster.
In addition, Dubbo Admin can also improve R&D testing efficiency through the following capabilities:
For more complex microservice practice scenarios, Dubbo also offers more advanced service governance features. Please refer to the documentation for more details, including: