The service list of Dubbo displays the provided service information in the dimension of interface, and is distinguished by interface level or application level of the registration source.
The service details page displays information on providers and consumers and methods of interfaces.
Conditional routing can write some customized routing rules to meet some service governance requirements, such as black and white lists and read/write splitting. Conditional routing can create rules at the interface level and consumer application level.
To create a conditional routing rule, you need to fill in the information about interface, version, and group (but if there is no information on version and group, it is not necessary to fill in). The following figure shows a simple configuration of a blacklist. The left side of the =>
icon represents the consumer matching condition, and the right side represents the provider matching condition (no information means no matching). For details of the rule, refer to the official website (see the related link at the end of this article).
Therefore, the configuration means a consumer whose consumer IP is 192.168.1.3
does not receives services offered by a provider.
By dividing providers of one or more services into the same group, label-based routing limits traffic within the specified group to realize traffic isolation and provides basic capabilities for blue-green deployments and canary releases. To create a rule at the provider application level, the static tag is:
dubbo.provider.tag=tag1``````
@DubboService(tag = "tag2")
Mesh routing is a new traffic management policy introduced in Dubbo 3.0. It supports more matching conditions and combinations of conditions to easily implement various routing functions. It divides the entire traffic management into two parts, VirtualService and DestinationRule. VirtualService matches ingress traffic, and DestinationRule matches egress traffic. For more information, refer to the document (and see the link at the end of this article for details).
The number parameter of an interface org.test.apache.dubbo.interfaces.HelloService#hi(Integer number)
is of the integer type. The following rule indicates that when the number is an even number, it matches a provider with a label of v1 (that is, a service whose URL contains the test-version = v1 parameter). When the number is an odd number, it matches a provider with a label of v2 (that is, a service whose URL contains the test-version = v2 parameter). It can mark the service via dubbo.application.parameters.test-version = v1
to realize a simple canary function.
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
name: demo/oddEvenRouter
spec:
dubbo:
- routedetail:
- match:
- method:
argc: 1
args:
- index: 0
num_value:
oneof:
- exact: 0.0
mod: 2.0
type: int
name_match:
exact: hi
name: even-route
route:
- destination:
host: demo
subset: v1
- match:
- method:
argc: 1
args:
- index: 0
num_value:
oneof:
- exact: 1.0
mod: 2.0
type: int
name_match:
exact: hi
name: odd-route
route:
- destination:
host: demo2
subset: v2
services:
- exact: org.test.apache.dubbo.interfaces.HelloService
---
apiVersion: service.dubbo.apache.org/v1alpha1
kind: DestinationRule
metadata:
name: test-route
spec:
host: demo
subsets:
- name: v1
labels:
test-version: v1
- name: v2
labels:
test-version: v2
Dynamic configuration provides the ability to dynamically adjust RPC call behavior without restarting, including modifying the timeout period, weight, and policy adjustment of load balancing. It operates at the interface level and the application level. The following figure shows that the timeout period is adjusted to 6000 ms, which is applied to all nodes on the consumer side.
The Dubbo service can be tested in the Admin background. Parameters automatically generate a JSON template based on the metadata content.
Rules can be configured in the Admin background based on the service name and method name.
You can use Dubbo references to introduce Mock dependencies and startup parameter -Denable.dubbo.admin.mock=true
by adding Java virtual machine (JVM). Thus, you can realize the simulated call of a consumer to a provider when the provider is unavailable, and return the simulated data configured in the Admin.
<denpendency>
<groupId>org.apache.dubbo.extensions</groupId>
<artifactId>dubbo-mock-admin</artifactId>
<version>last</version>
</denpendency>
1) Official Website:
https://dubbo.apache.org/en/docs/v2.7/user/examples/routing-rule/
2) Document:
https://dubbo.apache.org/zh/docs/concepts/traffic-management/ (This document is currently available in Chinese only)
Privatized Business Delivery Practice Based on Sealer from Government Procurement Cloud
Dubbo3 and the Triple Protocol: Why It Is the Logical Choice
506 posts | 48 followers
FollowAlibaba Container Service - September 13, 2024
Alibaba Developer - June 25, 2021
Aliware - October 20, 2020
Alibaba Clouder - August 10, 2020
Alibaba Clouder - August 21, 2020
Alibaba Developer - February 1, 2021
506 posts | 48 followers
FollowAlibaba Cloud Function Compute is a fully-managed event-driven compute service. It allows you to focus on writing and uploading code without the need to manage infrastructure such as servers.
Learn MoreHigh Performance Computing (HPC) and AI technology helps scientific research institutions to perform viral gene sequencing, conduct new drug research and development, and shorten the research and development cycle.
Learn MoreDeploy custom Alibaba Cloud solutions for business-critical scenarios with Quick Start templates.
Learn MoreElastic and secure virtual cloud servers to cater all your cloud hosting needs.
Learn MoreMore Posts by Alibaba Cloud Native Community