A dynamic routing system based on bytecode enhancement technology

Through the dynamic routing system of bytecode enhancement technology, the problem of repeated construction of multiple environments of information system and low resource utilization is solved, and the unconscious Dubbo routing and flexible RocketMQ messaging are realized, which improves server resource utilization and reduces costs.

CN115098274BActive Publication Date: 2025-08-26HUNAN XINGSHENG YOUYOU NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210486331.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-06
Publication Date
2025-08-26
Estimated Expiration
2042-05-06

AI Technical Summary

Technical Problem

In the prior art, there are problems with low resource utilization and unnecessary component replication due to repeated construction of multiple sets of environments during the research and development of information systems. The routing rules of Dubbo and RocketMQ are complex and difficult for users to master, resulting in inflexible traffic routing and message delivery.

Method used

The dynamic routing system based on bytecode enhancement technology, including the Agent module, the Server module and the Console module, realizes the dynamic routing of Dubbo and RocketMQ through bytecode modification and tag routing, and provides tag transmission and downgrading functions to reduce invasiveness to user code.

Benefits of technology

It realizes the use of unconscious Dubbo routing function, improves server resource utilization, reduces learning and development costs, supports the operation of multi-version environments, reduces the number of RocketMQ servers deployments, and improves resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115098274B_ABST
    Figure CN115098274B_ABST
Patent Text Reader

Abstract

The present invention discloses a dynamic routing based on bytecode enhancement technology, comprising RocketMQ middleware, an Agent module, a Server module and a Console module; the Agent module checks startup parameters and module integrity, monitors specific code through bytecode enhancement technology after startup, and changes the operating logic of the original code by implanting code; the Server module is responsible for Agent module health checks, instruction issuance, reported information processing, service registration and discovery service monitoring, and writing / modifying / deleting conditional routing rules; the Console module is responsible for instruction reception and front-end UI interaction; the present invention makes it possible to run multiple versions in the same environment, improves server resource utilization, and provides a solution based on Topic routing, eliminating the need to deploy multiple RocketMQs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of distributed service technology, and in particular relates to a dynamic routing system based on bytecode enhancement technology. Background Art

[0002] As the business continues to expand, the number of information systems also grows. To ensure the reliability and stability of information systems, multiple environments are created during the development process to verify various system functions and indicators. According to research, the current business system development process simultaneously utilizes one or more of the following environments: DEV (development environment), TEST (test environment), UAT (unit automation testing), SIT (system integration testing), Daily, QA1 (Quality Assurance 1), QA2 (Quality Assurance 2), and PROD (production environment). Within these environments, each business line independently builds independent middleware. This results in unnecessary duplication of common components and low resource utilization across environments. To reduce the duplication of reusable middleware and improve resource utilization across environments, there is an urgent need to address the pain points and issues inherent in these development processes through software systems.

[0003] Dubbo is a high-performance, lightweight, open-source Java RPC framework that provides three core capabilities: interface-based remote method invocation, intelligent fault tolerance and load balancing, and automatic service registration and discovery. Dubbo routing rules allow users to route service call traffic to specific service instances using specific routing rules, thereby achieving traffic routing. Dubbo routing rules support both tag routing and conditional routing. Tag routing adds the dubbo.tag parameter to the invoker (invoker is a service provider instance). Conditional routing, on the other hand, writes corresponding routing rules to specific service registration and discovery paths (e.g., / dubbo / config in Zookeeper). Dubbo's routing principle is that when a program consumes a downstream service, it first checks whether the rules are enabled. If not, it returns the request directly. If enabled, it prioritizes the routing order based on the weights of different routing rules. It then iterates through the invoker list, finds all invokers that meet the rules, and returns them to the service consumer.

[0004] Dubbo's label routing is written into the URL as a parameter during service registration, and the label information is generally not manually modified. Dubbo's rule routing requires users to be familiar with text formats and common parameters, and there are no error prompts during use. Users are unclear about the configuration error that caused the routing rule failure.

[0005] RocketMQ is a messaging middleware. Message producers send messages bound to a topic (the endpoint of RocketMQ is a topic, as topics contain queues) to the RocketMQ broker. Message consumers then consume messages from this topic by binding to it. During program execution, unless the user configures topic rebinding logic (such as rebinding logic for scheduled tasks), the topics for both producers and consumers remain unchanged. When testing multiple versions of the same application, it's common to configure RocketMQ server addresses with different IP addresses rather than modifying topics. This can result in idle server resources. Summary of the Invention

[0006] After investigation, we found that existing technologies have not yet adopted dynamic routing technology to solve the above problems. Therefore, we developed a dynamic routing system to achieve the ability to quickly deploy new functional testing environments and dynamically orchestrate traffic.

[0007] The dynamic routing system based on bytecode enhancement technology disclosed in the present invention includes RocketMQ middleware, Agent module, Server module and Console module;

[0008] Before starting, the Agent module checks the startup parameters and module integrity. If it finds that the parameters are missing or the module is incomplete, the Agent module fails to start. After starting, the Agent module loads the event monitor and monitors the specific code in the business program through bytecode enhancement technology, including modifying the program bytecode, performing component inspection, label acquisition, label routing, and Topic rebinding logic. It establishes a WebSocket communication connection with the Server module, reports the program's IP address, port, and service name, establishes a heartbeat connection, and receives instructions from the Server module.

[0009] The Server module is based on the Apache Spring framework and is responsible for Agent module health checks, command issuance, and reported information processing; Console module command reception; service registration and discovery service monitoring, and writing / modifying / deleting conditional routing rules; and provides tag-carrying interface calls and message sending interfaces for Dubbo Admin interface calls and RocketMQ Console message sending.

[0010] The Console module is based on Apache's Spring framework and is responsible for interacting with the front-end UI and communicating with the Server module's Websocket. When the user operates on the front-end UI, the information is transmitted to the Console module through the Http interface. After receiving the request, the Console module queries or requests the Server module based on the request information, and finally returns the operation result to the front-end UI.

[0011] Furthermore, the Console module also synchronizes information of the Server module through a scheduled task for data display on the front-end UI.

[0012] Furthermore, the bytecode enhancement technology includes:

[0013] Use the dubbo multi-registration center to register the business party's dubbo interface to the dynamic routing zookeeper;

[0014] When registering the Agent module service, a static label is added to the Dubbo interface. The static label is the Dubbo label routing parameter.

[0015] The Agent module implants the dubbo routing filter interface SPI into the business program;

[0016] The Agent module implements label transparent transmission, that is, it monitors the servlet interface and the dubbo service call interface, and is used to obtain label information when calling Http and dubbo services and pass labels when calling backwards;

[0017] The Agent module implements label degradation: When the Dubbo service is called later, it obtains the context label information and checks whether the downstream service has the label identifier. If the downstream service does not have the label identifier, it calls the baseline service. If the downstream label contains the label identifier, it prioritizes calling the service interface identified by the label identifier.

[0018] Furthermore, the RocketMQ middleware performs label routing. The specific steps are as follows:

[0019] S1: When the business program starts, the Agent module strengthens the bytecode of the business program;

[0020] S2: The Producer modifies the message topic when sending the message;

[0021] S3: Modify the bound topic when the consumer is bound to the topic;

[0022] S4: When consuming a message, the consumer obtains the transparent tag information from the message;

[0023] S5: If the tag downgrade switch is enabled on the Producer side, a new thread will be started to periodically obtain the Topic list on the RocketMQBroker side. If the Topic of the current service does not exist, the message will be sent to the Topic list of the baseline environment to achieve the downgrade of the Topic list;

[0024] S6: If the tag pass-through function is enabled on the Producer side, the context tag will be obtained and placed in the message; the Consumer side obtains the tag when consuming the message and continues to call it.

[0025] Furthermore, the RocketMQ middleware performs label downgrade. The specific steps are as follows:

[0026] RocketMQ Producer generates an MQ message and sends it to the Agent module. The Agent module obtains the context tag in the MQ message and uses it if it obtains the context tag.

[0027] If no context label exists, check if a dynamic label is set, if so, use the dynamic label, if not use the static label;

[0028] If dynamic tags are used, determine whether the tag degradation switch is turned on. If so, get the Topic list through RocketMQBroker. If not, use the tag as the suffix of the message Topic to send the message.

[0029] After obtaining the topic list, compare whether the topic with the tag suffix exists. If so, use the tag as the suffix of the message topic and send the message. If not, downgrade the tag to a baseline tag and use the tag as the suffix of the message topic and send the message.

[0030] The beneficial effects of the present invention are as follows:

[0031] The use of bytecode enhancement technology allows users to use the Dubbo routing function without any perception and low intrusion. Users do not need to modify any business code during use to use all the functions provided by the present invention, which reduces the learning, development, and trial and error costs required for users to use the Dubbo routing function.

[0032] Based on Dubbo's routing function, this system provides a label degradation function, which makes it possible to run multiple versions in the same environment, greatly improving the resource utilization of the server.

[0033] This invention provides a solution based on topic routing for RocketMQ. This allows the same application to be deployed in multiple versions and environments using only one RocketMQ server, ensuring isolation between message sending and consumption. This eliminates the need to deploy multiple RocketMQ servers for multi-environment and multi-version development and testing, reduces server costs, and improves resource utilization.

[0034] For the Dubbo Admin console, a generalized call that can pass tags is provided.

[0035] For the RocketMQ Console, a message sending interface that can carry tag information is provided. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 System communication connection diagram of the present invention;

[0037] Figure 2 HTTP tag calling flow chart of the present invention;

[0038] Figure 3 The label routing sub-flowchart of the present invention;

[0039] Figure 4 Dynamic routing workflow diagram of the present invention;

[0040] Figure 5 RocketMQ Producer-side tag degradation flow chart of the present invention. DETAILED DESCRIPTION

[0041] The present invention will be further described below with reference to the accompanying drawings, but the present invention is not limited in any way. Any changes or substitutions made based on the teachings of the present invention fall within the scope of protection of the present invention.

[0042] refer to Figure 1 The communication connection diagram of this system, the system of the present invention is divided into three modules: Agent module, Server module and Console module.

[0043] The Agent module is based on Alibaba's JVM-Sandbox framework and uses JVMTI bytecode enhancement technology. This technology allows you to modify program bytecode and embed specific code into the program, thus implementing the code logic implantation function. This module starts with the program using Java startup parameters. Before the program starts, the following operations are performed:

[0044] Parameter check before module startup, mainly checks startup parameters and module integrity. If parameters are missing or the module is incomplete, the Agent module startup fails, which does not affect the normal startup of the business program.

[0045] Load event monitors and monitor specific code in business programs through bytecode enhancement technology. Modify program bytecode and implant specific code logic. This includes but is not limited to component inspection, label acquisition, label routing, topic rebinding logic, etc.

[0046] Establish a WebSocket communication connection with the server, report basic program information (IP, port, service name, etc.), establish a heartbeat connection, and receive instructions from the server.

[0047] The Server module is based on Apache's Spring framework and is responsible for Agent module health checks, command issuance, and reported information processing; receiving commands from the Console module; service registration and discovery service monitoring, writing / modifying / deleting conditional routing rules; and providing interface calls and message sending interfaces that can carry tags for Dubbo Admin interface calls and RocketMQ Console (different from the above-mentioned Console module).

[0048] The Console module, based on the Apache Spring framework, is responsible for interacting with the front-end UI and communicating with the Server module via WebSockets. When a user performs an operation on the front-end UI, information is transmitted to the Console module via the HTTP interface. Upon receiving the request, the Console module queries or requests the Server module based on the request information. The result of the operation is ultimately returned to the front-end UI. Information from the Server module is synchronized via scheduled tasks for display in the front-end UI.

[0049] The technical solution for Dubbo routing is as follows:

[0050] refer to Figure 2 and Figure 3 When the business program starts, the Agent module strengthens the bytecode of the business program

[0051] Use the dubbo multi-registration center to register the business party's dubbo interface to the dynamic routing zk (zookeeper);

[0052] Add static labels to dubbo interfaces during service registration (Dubbo label routing parameters);

[0053] Implant the dubbo routing filter interface SPI into the business program;

[0054] Tag pass-through implementation: monitor the servlet interface and dubbo service call interface, mainly used to obtain tag information when calling Http and dubbo services and pass tags when calling backward.

[0055] Tag degradation implementation: When the Dubbo service is called later, it obtains the context tag information and checks whether the downstream service has the tag identifier. If the downstream service does not have the tag identifier, it calls the baseline service. If the downstream tag contains the tag identifier, it will give priority to calling the service interface identified by the tag. For details, see Figure 4 .

[0056] Users can add dynamic tags (Dubbo conditional routing) to the program through the console. Compared with DubboAdmin, which requires users to configure routing rules themselves, the console only requires users to set dynamic tags like setting static tags. The console will automatically set routing rules for users, saving users extra learning costs.

[0057] The technical solution for RocketMQ label routing is as follows:

[0058] S1: When the business program starts, the Agent module strengthens the bytecode of the business program;

[0059] S2: The Producer modifies the message topic when sending the message (by adding a label suffix)

[0060] S3: Modify the bound topic when binding it to the consumer (by adding a tag suffix)

[0061] S4: When consuming messages, the Consumer obtains the transparent tag information from the message

[0062] S5: If the tag downgrade switch is enabled on the Producer side, another thread will be started to periodically obtain the Topic list on the RocketMQBroker side. If the Topic of the current service does not exist, the message will be sent to the Topic of the baseline environment to achieve Topic downgrade.

[0063] S6: If the tag pass-through function is enabled on the producer side, the context tag is obtained and placed in the message. The consumer side obtains the tag when consuming the message and continues to call it.

[0064] Users can dynamically modify the service's topic through the console configuration. After the topic is modified, it will take effect without restarting the service.

[0065] refer to Figure 5The RocketMQ Producer-side tag downgrade process is as follows:

[0066] RocketMQ Producer generates MQ messages and sends them to the Agent module. The Agent module obtains the context tag in the MQ message. If the context tag is obtained, it uses the context tag. If the context tag does not exist, it checks whether a dynamic tag is set. If so, it uses the dynamic tag. Otherwise, it uses the static tag. If the dynamic tag is used, it determines whether the tag degradation switch is turned on. If so, it obtains the Topic list through RocketMQ Broker. If not, it uses the tag as the suffix of the message Topic and sends the message.

[0067] For the topic list, obtain the topic list and compare whether the topic with the tag suffix exists. If so, use the tag as the suffix of the message topic and send the message. If not, downgrade the tag to a baseline tag and then use the tag as the suffix of the message topic and send the message.

[0068] The present invention is applicable to Java programs developed based on the Spring framework and using Dubbo as RPC communication.

[0069] The beneficial effects of the present invention are as follows:

[0070] The use of bytecode enhancement technology allows users to use the Dubbo routing function without any perception and low intrusion. Users do not need to modify any business code during use to use all the functions provided by the present invention, which reduces the learning, development, and trial and error costs required for users to use the Dubbo routing function.

[0071] Based on Dubbo's routing function, this system provides a label degradation function, which makes it possible to run multiple versions in the same environment, greatly improving the resource utilization of the server.

[0072] This invention provides a solution based on topic routing for RocketMQ. This allows the same application to be deployed in multiple versions and environments using only one RocketMQ server, ensuring isolation between message sending and consumption. This eliminates the need to deploy multiple RocketMQ servers for multi-environment and multi-version development and testing, reduces server costs, and improves resource utilization.

[0073] For the Dubbo Admin console, a generalized call that can pass tags is provided.

[0074] For the RocketMQ Console, a message sending interface that can carry tag information is provided.

[0075] As used herein, the word "preferred" is intended to serve as an example, instance, or illustration. Any aspect or design described herein as "preferred" is not necessarily to be construed as advantageous over other aspects or designs. Rather, the use of the word "preferred" is intended to present concepts in a concrete manner. As used in this application, the term "or" is intended to mean an inclusive "or" rather than an exclusive "or." That is, unless otherwise specified or clear from the context, "X employs A or B" is intended to mean any of the naturally inclusive permutations. That is, if X employs A; X employs B; or X employs both A and B, then "X employs A or B" is satisfied in any of the foregoing examples.

[0076] Moreover, although the present disclosure has been shown and described with respect to one or implementation, those skilled in the art will think of equivalent variations and modifications based on reading and understanding of this specification and the accompanying drawings. The present disclosure includes all such modifications and variations and is limited only by the scope of the appended claims. In particular, with respect to the various functions performed by the above-mentioned components (such as elements, etc.), the terms used to describe such components are intended to correspond to any component (unless otherwise indicated) that performs the specified function of the component (such as it is functionally equivalent), even if structurally different from the disclosed structure that performs the function in the exemplary implementation of the present disclosure shown herein. In addition, although the specific features of the present disclosure have been disclosed with respect to only one of several implementations, such features can be combined with one or other features of other implementations that can be desired and advantageous for a given or specific application. Moreover, insofar as the terms "including", "having", "containing" or their variations are used in specific embodiments or claims, such terms are intended to be included in a manner similar to the term "comprising".

[0077] The functional units in the embodiments of the present invention may be integrated into a single processing module, or each unit may exist physically separately, or multiple or more units may be integrated into a single module. The aforementioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium. The aforementioned storage medium may be a read-only memory, a magnetic disk, or an optical disk, etc. The aforementioned devices or systems may execute the storage method in the corresponding method embodiment.

[0078] In summary, the above embodiment is one implementation method of the present invention, but the implementation method of the present invention is not limited to the described embodiment. Any other changes, modifications, substitutions, combinations, and simplifications that deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the scope of protection of the present invention.

Claims

1. A dynamic routing system based on bytecode enhancement technology, including RocketMQ middleware, characterized in that: It also includes Agent module, Server module and Console module; Before starting the Agent module, it checks the startup parameters and module integrity. If it finds that the parameters are missing or the module is incomplete, the Agent module fails to start. After starting the Agent module, it loads the event monitor and monitors the code in the business program through bytecode enhancement technology, including modifying the program bytecode, performing component inspection, label acquisition, label routing, and topic rebinding logic. Establish a WebSocket communication connection with the Server module, report the program's IP address, port, and service name, establish a heartbeat connection, and receive instructions from the Server module; The Server module is based on the Apache Spring framework and is responsible for the health check of the Agent module, issuing instructions, and reporting information processing; Console module command reception; service registration and discovery service monitoring, write / modify / delete conditional routing rules; for Dubbo Admin interface calls and RocketMQ Console message sending, provide tag-carrying interface calls and message sending interfaces; The Console module is based on the Apache Spring framework and is responsible for interacting with the front-end UI and communicating with the Server module via Websocket. When a user operates on the front-end UI, the information is transmitted to the Console module via the HTTP interface. After receiving the request, the Console module requests the Server module based on the request information and finally returns the operation result to the front-end UI. The bytecode enhancement technology includes: Use the dubbo multi-registration center to register the business party's dubbo interface to the dynamic routing zookeeper; When registering the Agent module service, a static label is added to the Dubbo interface. The static label is the Dubbo label routing parameter. The Agent module implants the dubbo routing filter interface SPI into the business program; The Agent module implements label transparent transmission, that is, it monitors the servlet interface and the dubbo service call interface, and is used to obtain label information when calling Http and dubbo services and pass labels when calling backwards; The Agent module implements label degradation: When the Dubbo service is called later, it obtains the context label information and checks whether the downstream service has the label identifier. If the downstream service does not have the label identifier, the baseline service is called. If the downstream label contains the label identifier, the service interface with the label identifier is called first.

2. The dynamic routing system based on bytecode enhancement technology according to claim 1, characterized in that: The Console module also synchronizes information from the Server module through scheduled tasks for data display on the front-end UI.

3. The dynamic routing system based on bytecode enhancement technology according to claim 1, characterized in that: The RocketMQ middleware performs label routing. The specific steps are as follows: S1: When the business program starts, the Agent module strengthens the bytecode of the business program; S2: RocketMQ Producer modifies the message topic when sending the message; S3: Modify the bound topic when the RocketMQ Consumer is bound to it; S4: RocketMQ Consumer obtains transparent tag information from the message when consuming the message; S5: If the tag downgrade switch is enabled on the RocketMQ Producer, a new thread will be started to periodically obtain the Topic list on the RocketMQ Broker. If the Topic for the current service does not exist, the message will be sent to the Topic list of the baseline environment to achieve the downgrade of the Topic list. S6: If the tag transparent transmission function is enabled on the RocketMQ Producer side, it will obtain the context tag and put it into the message; the RocketMQ Consumer side obtains the tag when consuming the message and continues to call it.

4. The dynamic routing system based on bytecode enhancement technology according to claim 1, characterized in that: The RocketMQ middleware performs label downgrade. The specific steps are as follows: RocketMQ Producer generates an MQ message and sends it to the Agent module. The Agent module obtains the context tag in the MQ message and uses it if it can. If no context label exists, check if a dynamic label is set, if so, use the dynamic label, if not use the static label; If dynamic tags are used, determine whether the tag downgrade switch is turned on. If so, get the Topic list through RocketMQ Broker. If not, use the tag as the suffix of the message Topic to send the message. After obtaining the topic list, compare whether the topic with the tag suffix exists. If yes, use the tag as the suffix of the message topic and send the message. If not, downgrade the tag to a baseline tag and use the tag as the suffix of the message topic and send the message.

Citation Information

Patent Citations

  • Application program access method and device

    CN114416567A