Microservices Development

Microservices Development

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.

  • Development: Dubbo offers implementations in Java, Go, Rust, Node.js, and defines a microservices development paradigm. The accompanying scaffolding can be used to quickly create microservice project skeletons.
  • Deployment: Dubbo applications support deployment on virtual machines, Docker containers, Kubernetes, and service mesh architectures.
  • Service Governance: Dubbo provides governance capabilities such as address discovery, load balancing, and traffic control. The official Admin visual console and rich microservice ecosystem integration are also provided.

Development

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.

Create Project

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

Scaffolding Example

Develop Service

1. Define Service

  1. public interface DemoService {
  2. String hello(String arg);
  3. }

2. Provide Business Logic Implementation

  1. @DubboService
  2. public class DemoServiceImpl implements DemoService {
  3. public String hello(String arg) {
  4. // put your microservice logic here
  5. }
  6. }

Publish Service

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

  1. dubbo:
  2. application:
  3. name: dubbo-demo
  4. protocol:
  5. name: dubbo
  6. port: -1
  7. registry:
  8. address: zookeeper://127.0.0.1:2181

Call Service

First, the consumer introduces the DemoService service definition dependency through Maven/Gradle.

  1. <dependency>
  2. <groupId>org.apache.dubbo</groupId>
  3. <artifactId>dubbo-demo-interface</artifactId>
  4. <version>3.2.0</version>
  5. </dependency>

Programmatically inject the remote Dubbo service instance

  1. @Bean
  2. public class Consumer {
  3. @DubboReference
  4. private DemoService demoService;
  5. }

The above is a procedural explanation of Dubbo microservice development. For detailed guidance steps in actual development, please refer to:

Deployment

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:

Governance

For service governance, most applications only need to add the following configuration, and Dubbo applications will have address discovery and load balancing capabilities.

  1. dubbo:
  2. registry:
  3. 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.

Admin

In addition, Dubbo Admin can also improve R&D testing efficiency through the following capabilities:

  • Documentation management, providing ordinary service and IDL documentation management
  • Service testing & service mocking
  • Service status query

For more complex microservice practice scenarios, Dubbo also offers more advanced service governance features. Please refer to the documentation for more details, including:

  • Traffic governance
  • Dynamic configuration
  • Rate limiting and degradation
  • Data consistency
  • Observability
  • Multiple protocols
  • Multiple registries
  • Service mesh

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)