Dubbo addresses a series of challenges from development and deployment to governance and operations in enterprise microservices. Dubbo provides a full suite of services for developers, from project creation, development testing, to deployment, visual monitoring, traffic governance, and ecosystem integration.
The Dubbo Microservices Project Scaffold can be used to quickly create a microservices project. The scaffold can generate a microservice project with necessary dependencies based on the features or components you want.
1. Define the Service
public interface DemoService {
String hello(String arg);
}
2. Implement Business Logic
@DubboService
public class DemoServiceImpl implements DemoService {
public String hello(String arg) {
// your microservice logic here
}
}
1. Publish the Service Definition
The service provider needs to publish the service definition as a Jar package to the Maven central repository.
2. Expose the Service
Add Dubbo configuration and start the Dubbo server.
dubbo:
application:
name: dubbo-demo
protocol:
name: dubbo
port: -1
registry:
address: zookeeper://127.0.0.1:2181
First, consumers include the DemoService
service definition dependency via Maven/Gradle.
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-demo-interface</artifactId>
<version>3.2.0</version>
</dependency>
Then, programmatically inject the remote Dubbo service instance.
@Bean
public class Consumer {
@DubboReference
private DemoService demoService;
}
Dubbo native services can be packaged and deployed to cloud-native infrastructures like Docker containers, Kubernetes, and service meshes.
For service governance, most applications just need to add the following configuration. Dubbo will then have address discovery and load balancing capabilities.
dubbo:
registry:
address: zookeeper://127.0.0.1:2181
Deploy and open the Dubbo Admin Dashboard, and you will see the service deployment and invocation data.
Dubbo Admin can also improve development and testing efficiency through additional capabilities like:
For more complex microservices scenarios, Dubbo also provides more advanced governance features, including:
This guide provides an overview of the workflow for developing microservices with Dubbo. For detailed step-by-step instructions, please refer to:
Dubbo’s native services can be packaged and deployed in various cloud-native infrastructures and microservices architectures, including Docker containers, Kubernetes, and Service Mesh.
For examples of deployment in different environments, refer to:
For service governance, most applications only need to add the following configuration, and the Dubbo application will have address discovery and load balancing capabilities.
dubbo:
registry:
address: zookeeper://127.0.0.1:2181
Once deployed and the Dubbo Admin Console is opened, you can see the deployment and invocation data of services in the cluster.
In addition, Dubbo Admin can also enhance R&D and testing efficiency through the following capabilities:
For more complex microservices practice scenarios, Dubbo also offers many more advanced service governance features. For more details, please refer to the documentation, including: