Dubbo template out of the box

preface

My recent project is a micro-service project using Dubbo architecture. Although I have learned Dubbo architecture before, I have never had the opportunity to build it alone, so I took this opportunity to build a complete spring-Dubbo demo out of the box with my shallow understanding.

The body of the

Dubbo template out of the box

Here is a brief overview of the structure of the project

spring-dubbo-demo

  • spring-dubbo-api: This module mainly stores externally provided filesdubboInterface.
  • Spring-dubo-common: Houses some common utility classes, custom tags, enumerated classes, and so on.
  • spring-dubbo-dao: provides data access modules, such asmysqlThe database.
  • Spring-dubo-middleware: Used to connect to message middleware, such as message queues.
  • Spring-dubo-gateway: gateway module of the project, used for load balancing and traffic limiting.
  • spring-dubbo-producer: simulationproducerBusiness module.
  • spring-dubbo-comsumer: simulationcomsumerBusiness module.

According to the relationship of each module in the project, the architecture diagram of the project is simply described:

Technology stack for the project

Nacos Service governance center and configuration center

Nacos provides four main features:

  • Service discovery and Service Health Check (Service Governance)NacosMake it easy for the service to register itself and passDNSorHTTPInterface to discover other services.NacosReal-time health checks of services are also provided to prevent requests from being sent to abnormal hosts or service instances.
  • Dynamic configuration Management: Dynamically configuring services enables you to manage the configuration of all services in a centralized and dynamic manner in all environments.NacosEliminating the need to redeploy applications and services when the configuration is updated makes configuration changes more efficient and agile.
  • dynamicDNSservice:NacosSupport for weighted routing makes it easier to implement mid-tier load balancing, flexible routing policies, flow control, and simple DNS resolution services in production environments within data centers. It can help you easily implement basedDNSAnd prevent applications from coupling to vendor-specific service discovery apis.
  • Service and metadata Management (distributed configuration)NacosProvides easy-to-use service dashboards that help you manage service metadata, configure,kubernetes DNS, service health and indicator statistics.

Nacos can serve as either a service governance center (an alternative to Spring Cloud Eureka) or a configuration center (an alternative to Spring Cloud Config).

Nacos is deployed as a separate service without requiring users to set up projects as service governance nodes.

See my blog: Nacos Service Governance Center and Configuration Center for details

Gateway Micro service Gateway

Gateway provides a library for building API gateways on top of Spring MVC. The Spring Cloud Gateway aims to provide a simple and efficient way to route apis and provide them with cross-domain concerns such as: security, monitoring/metrics, and resiliency.

The Spring Cloud Gateway implements the following functions:

  • Based on theSpring Framework 5.Project ReactorandSpring Boot 2.0On top of
  • Ability to match routes on any request attribute. Predicates and filters are specific to routes
  • HystrixCircuit breaker integration
  • Spring Cloud DiscoveryClientintegration
  • Easy to write predicates and filters
  • Request rate limiting, or traffic limiting
  • The path to rewrite

For details, please refer to my blog: Microservices Gateway -Gateway

ElasticJob Distributed timer

ElasticJob is a distributed scheduling solution consisting of two separate items elasticJob-Lite and ElasticJob-Cloud.

Through flexible scheduling, resource management and job management, it creates a distributed scheduling solution suitable for Internet scenarios, and provides a diversified job ecosystem through open architecture design. It uses a uniform job API for each project. Developers only need to write the code once and then deploy it at will.

For details on how to implement distributed scheduled tasks, see my blog “Elastic- Job”

RocketMQ message queue

Apache RockerMQ is a distributed messaging engine and lightweight data processing platform.

It has the following characteristics:

  • Low latency: response delay exceeds 99.6% within 1mm at high pressure.
  • Financial orientation: High availability with tracking and auditing capabilities.
  • Industry sustainability: Trillion-level message capacity.
  • Big data friendly: Batch transmission with general integration function enables large volume throughput.
  • Good compatibility: Provides standards for open distributed messaging and streaming.
  • Terabyte capacity: Given enough disk space, messages can be accumulated without sacrificing performance.

See my blog: SpringBoot integrates RocketMQ to implement message queues

Knife4j interface debugging

Knife4j is an enhanced solution to generate Api documentation for Java MVC framework integration with Swagger, formerly swagger-Bootstrap-UI, with the advantages of being small, lightweight, and powerful.

Knife4j provides two core functions: documentation and online debugging

  • documentation: according to theSwaggerSpecification description, detailed list interface document description, including interface address, type, request example, request parameters, response example, response parameters, response code and other information, usingswagger-bootstrap-uiAccording to this document, you can clearly understand the usage of the interface.
  • Online debugging: Provides the powerful function of online interface tuning, automatically parsing the current interface parameters, including form verification, calling parameters can return the interface response content,headers,CurlRequest command instance, response time, response status code and other information to help developers debug online, without other testing tools to test whether the interface is correct, simple and powerful.

See my blog: SpringBoot uses KNIfe4J for online interface debugging

The source code

The project source code is available from my Github: github source address