Route redirection method, storage medium and computer program product

By analyzing request packets and matching routing configurations in the microservice architecture, smooth split migration of the database is achieved, solving the problem of service interruption of traditional routing gateways during the migration process.

CN119603217AActive Publication Date: 2025-03-11CHINA MERCHANTS BANK
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411637066.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-15
Publication Date
2025-03-11
Estimated Expiration
2044-11-15

AI Technical Summary

Technical Problem

Under the microservice architecture, when traditional routing gateways face database split migration, they cannot switch gradually according to a small amount of traffic, resulting in the migration taking a long time and the service needs to be stopped.

Method used

By analyzing the request packets entering the gateway layer, extracting service codes and obtaining routing interface information, determining customer codes, defining redirection routing configurations, matching routing factor fields, and routing redirecting based on routing factor fields and request packet types.

Benefits of technology

It realizes smooth split migration of databases under the microservice architecture, avoids service interruption, and supports smooth migration of small batches of customers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119603217A_ABST
    Figure CN119603217A_ABST
Patent Text Reader

Abstract

The invention discloses a route redirection method, a storage medium and a computer program product, and relates to the technical field of micro-service architecture.The method comprises the steps that a request message entering a gateway layer is analyzed to obtain a service code, and route interface information is obtained according to the service code; determining a client code according to the routing interface information; defining redirection routing configuration according to the client code, and reading a routing factor field matched with the redirection routing configuration; and performing routing redirection based on the routing factor field and the type of the request message. And performing routing redirection based on the request message type and the routing factor field to realize smooth splitting migration of the database under the micro-service architecture.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of microservice architecture technology, and in particular to a routing redirection method, a storage medium, and a computer program product. Background Art

[0002] As microservice architecture becomes more and more popular, the communication between front-end applications and back-end services becomes more and more complex. And with the rapid development of business and the need for system expansion and upgrade, the back-end business system needs to split and upgrade the database or reconstruct and migrate it. When facing database split migration, traditional routing gateways usually make one-size-fits-all routing selections according to preset routing factors. They cannot switch gradually according to a small amount of traffic, which takes a long time and requires stopping services during the migration process.

[0003] Therefore, how to achieve smooth splitting and migration of the database under the microservice architecture has become an urgent problem to be solved in this application.

[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0005] The main purpose of this application is to provide a routing redirection method, a storage medium and a computer program product, aiming to solve the technical problem of how to achieve smooth split migration of a database under a microservice architecture.

[0006] To achieve the above object, the present application proposes a routing redirection method, the method comprising:

[0007] Parse the request message entering the gateway layer to obtain the service code, and obtain the routing interface information according to the service code;

[0008] Determine the client code according to the routing interface information;

[0009] Define a redirection routing configuration according to the customer code, and read a matching routing factor field of the redirection routing configuration;

[0010] Routing redirection is performed based on the routing factor field and the type of the request message.

[0011] In one embodiment, the step of parsing the request message entering the gateway layer to obtain a service code, and obtaining routing interface information according to the service code includes:

[0012] Receive the request message transmitted by the channel party to the gateway layer, and parse the request message to obtain the business code;

[0013] Reading the pre-cached gateway routing basic configuration to obtain routing configuration information corresponding to the service code;

[0014] Determining whether there is a gateway routing key configuration based on the routing configuration information;

[0015] If the gateway routing key configuration exists, the routing interface information corresponding to the service code is obtained according to the gateway routing key configuration.

[0016] In one embodiment, the routing configuration information includes a destination cluster, and the step of determining whether there is a gateway routing key configuration based on the routing configuration information further includes:

[0017] If the gateway routing key configuration does not exist, the request message is distributed to the sub-database of the destination cluster.

[0018] In one embodiment, the step of determining the client code according to the routing interface information includes:

[0019] Extracting a personalized routing key value from the request message according to the routing interface information, and converting the personalized routing key value into a unified routing key value;

[0020] The customer code is obtained from the unified routing key value.

[0021] In one embodiment, after the step of extracting a personalized routing key from the request message according to the routing interface information and converting the personalized routing key into a unified routing key, the step further includes:

[0022] Routing distribution is performed through the unified routing key value.

[0023] In one embodiment, the step of defining a redirection routing configuration according to the client code and reading a matching routing factor field of the redirection routing configuration comprises:

[0024] Define redirection routing configuration according to the client code;

[0025] Periodically cache the redirection routing configuration to a local parameter configuration center;

[0026] Read the routing configuration information of the request message and the redirection routing configuration cached in the local parameter configuration center;

[0027] The routing configuration information is matched with the redirection routing configuration to obtain a routing factor field.

[0028] In one embodiment, the step of performing routing redirection based on the routing factor field and the type of the request message includes:

[0029] Obtaining transplantation status information and determining whether the routing factor field is configured with a redirection strategy;

[0030] If the routing factor field configures a redirection policy, routing redirection is performed based on the type of the request message and the transplantation status information;

[0031] If the routing factor field is not configured with a redirection policy, routing redirection is performed based on a pre-established tail number configuration policy and the transplantation status information.

[0032] In one embodiment, the types of the request message include transaction requests and query requests, and the step of performing routing redirection based on the type of the request message and the transplantation status information includes:

[0033] If the transplantation status information is transplanting and the type of the request message is a query request, the request message is routed and redirected to multiple sub-databases for combined query;

[0034] If the migration status information is in the process of migration and the type of the request message is a transaction request, the request message is routed and redirected to a single sub-database;

[0035] If the transplantation status information indicates that the transplantation is completed, the request message is directly routed and redirected to a single sub-database.

[0036] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the routing redirection method described above are implemented.

[0037] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the routing redirection method described above are implemented.

[0038] One or more technical solutions proposed in this application have at least the following technical effects:

[0039] Parse the request message entering the gateway layer to extract the business code. The business code is the key identifier for identifying different business types or request purposes. The business code can quickly locate the corresponding routing interface information to ensure accurate operations for specific business requests, providing the premise for smooth migration; determine the customer code based on the routing interface information, and then define the redirection routing configuration based on the customer code, match the routing factor field, and set the secondary directional target in the routing factor field to support the smooth migration of customers in small batches; perform routing redirection based on the routing factor field and the type of request message, which means redirecting the request message to the new target address or path, so as to perform smooth batch migration of the database without interrupting the service. In summary, through the mechanism of business code parsing, gateway layer routing configuration reading and matching, and routing redirection, the smooth split migration of the database under the microservice architecture is realized. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0041] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0042] Figure 1 A flowchart of the first embodiment of the routing redirection method of the present application is provided;

[0043] Figure 2 A schematic diagram of the basic routing configuration provided for the routing redirection method of this application;

[0044] Figure 3 A schematic diagram of the gateway routing key value configuration provided for the routing redirection method of this application;

[0045] Figure 4 A schematic diagram of a second embodiment of the process flow of the routing redirection method of the present application;

[0046] Figure 5 A schematic diagram of a third embodiment of the process flow of the routing redirection method provided in the present application;

[0047] Figure 6 Define the rule table for redirect routing configuration;

[0048] Figure 7 This is a schematic diagram of the module structure of the routing redirection device according to an embodiment of the present application;

[0049] Figure 8 A schematic diagram of the device structure of the hardware operating environment involved in the routing redirection method in the embodiment of the present application.

[0050] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0051] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0052] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0053] The main solution of the embodiment of the present application is: the gateway parses the request message entering the gateway layer and extracts the business code therefrom, which is used to identify the business type or purpose of the request message. Then, the corresponding routing interface information is obtained according to the business code, and the routing interface information indicates how to perform subsequent routing processing according to the content of the request message. After obtaining the routing interface information, the gateway determines the customer code according to the routing interface information, configures the customer code, and obtains the redirection routing configuration. Read the redirection route matching routing factor field for matching, so as to determine whether the request message needs to be routed redirected, and the target address of the redirection. Finally, route redirection is performed according to the routing factor field and the type of the request message.

[0054] In this embodiment, for the convenience of description, the identification gateway is used as the execution subject for explanation below.

[0055] The embodiments of the present application take into account that: as microservice architecture becomes increasingly popular, the communication between front-end applications and back-end services becomes increasingly complex. And with the rapid development of business and the need for system expansion and upgrading, the back-end business system needs to split and upgrade the database or reconstruct and migrate it. When facing database split migration, traditional routing gateways usually perform one-size-fits-all routing selection according to preset routing factors, and cannot gradually switch according to a small amount of traffic. It takes a long time and needs to stop the service during the migration process.

[0056] Therefore, the present application provides a solution to parse the request message entering the gateway layer, so as to extract the business code. The business code is a key identifier for identifying different business types or request purposes. The corresponding routing interface information can be quickly located through the business code to ensure that accurate operations can be performed on specific business requests, providing a prerequisite for smooth migration; the customer code is determined according to the routing interface information, and then the redirection routing configuration can be defined according to the customer code, and the routing factor field is matched. The routing factor field is set with a secondary directional target to support the smooth migration of customers in small batches; routing redirection is performed based on the routing factor field and the type of the request message, which means redirecting the request message to a new target address or path, so as to perform smooth batch migration of the database without interrupting the service. In summary, through the mechanism of business code parsing, gateway layer routing configuration reading and matching, and routing redirection, the smooth split migration of the database under the microservice architecture is realized.

[0057] It should be noted that the execution subject of this embodiment may be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a gateway, etc. The following takes the gateway as an example to illustrate this embodiment and the following embodiments.

[0058] Based on this, the present application embodiment provides a routing redirection method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the routing redirection method of the present application.

[0059] In this embodiment, the routing redirection method includes steps S10 to S40:

[0060] Step S10, parsing the request message entering the gateway layer to obtain a service code, and obtaining routing interface information according to the service code;

[0061] A request message is a data packet sent by a front-end application or other client to the gateway. The data packet contains the operations that the front-end application wants the back-end service to perform and the required data.

[0062] The service code is a key field in the request message that identifies the service type or processing logic of the request. In the configuration of the gateway, different service codes correspond to different routing strategies and processing procedures. By parsing the service code in the request message, the gateway can determine which routing strategy should be used to forward the request.

[0063] Routing interface information refers to the interface information obtained by the gateway according to the business code, which is used to guide how to forward the request message, and mainly includes the routing key value query field and the routing key value query method.

[0064] Since the gateway is usually designed as a multi-layer structure in the microservice architecture, the "gateway layer" is mainly responsible for receiving, preliminarily processing and forwarding request messages. At the gateway layer, the gateway performs tasks such as identity authentication, request parsing, and routing selection. Therefore, when the request message is sent to the gateway layer, the gateway parses the received request message, extracts the business code in the request message, and searches for the corresponding routing interface information in the configuration based on the parsed business code.

[0065] Step S20, determining the client code according to the routing interface information;

[0066] The routing interface information provides detailed forwarding guidance for the gateway to ensure that the request message can be correctly forwarded to the target location. It contains the routing key query field and the routing key query method. This information enables the gateway to flexibly select the routing key according to the specific content in the request message and determine the customer code accordingly. The customer code is the main part of the routing factor field.

[0067] It is understandable that the accuracy and completeness of routing interface information is crucial to achieving smooth database migration under the microservice architecture, because it is directly related to whether the request message can be correctly forwarded and processed. Therefore, it is necessary to pay attention to the completeness and accuracy of routing interface information.

[0068] Step S30, defining a redirection routing configuration according to the customer code, and reading a matching routing factor field of the redirection routing configuration;

[0069] Redirection routing configuration usually includes key information such as routing factor field (customer code suffix), redirection target address, redirection condition, migration status, etc. Redirection routing configuration is loaded into the local cache of the gateway for quick access when needed. Redirection routing configuration defines how to redirect routing in different scenarios. For example, during the business system migration phase, some customer requests need to be redirected to a new database or application instance.

[0070] The gateway reads the redirection routing configuration cached locally for matching. The key to matching is the routing factor field, which is an identifier that can uniquely identify a request or client.

[0071] If the routing factor field in the request message matches an entry in the redirection routing configuration, the gateway will perform a redirection operation based on the configuration of the entry. This may mean forwarding the request to a new database, application instance, or a different service path.

[0072] If the routing factor field in the request message does not match any redirection routing configuration entry, the gateway will perform routing distribution according to the default routing policy. This usually means forwarding the request to a pre-configured default target address or cluster.

[0073] Step S40: performing routing redirection based on the routing factor field and the type of the request message.

[0074] The types of request messages are usually divided into two categories: transactions and queries. For transaction requests, after redirection, it is decided in which sub-database to place the transaction to complete the transaction and land the data. For query requests, it is necessary to integrate the scattered customer data in multiple sub-databases through redirection, merge them and output them.

[0075] This embodiment provides a routing redirection method, which parses the request message entering the gateway layer to extract the business code. The business code is a key identifier for identifying different business types or request purposes. The business code can quickly locate the corresponding routing interface information to ensure that accurate operations can be performed on specific business requests, providing a prerequisite for smooth migration; the customer code is determined according to the routing interface information, and then the redirection routing configuration can be defined according to the customer code to match the routing factor field. The routing factor field is set with a secondary directional target to support the smooth migration of customers in small batches; routing redirection is performed based on the routing factor field and the type of the request message, which means redirecting the request message to a new target address or path, so that the database can be smoothly migrated in batches without interrupting the service. In summary, through the mechanism of business code parsing, gateway layer routing configuration reading and matching, and routing redirection, the smooth split migration of the database under the microservice architecture is realized.

[0076] In a feasible implementation, step S10 may include steps S11 to S14:

[0077] Step S11, receiving a request message transmitted from the channel party to the gateway layer, and parsing the request message to obtain a service code;

[0078] The channel side refers to the external system or application that sends the request message, such as the front-end application, mobile application, third-party service, etc. The gateway, as a middleware, is responsible for receiving the request message from the channel side. The request message is transmitted to the gateway through protocols such as HTTP and HTTPS.

[0079] The gateway uses an appropriate parser (such as a JSON parser, XML parser, etc.) to parse the request message. Specifically, the gateway needs to determine the format of the received request message. Common message formats include JSON, XML, form data, etc. This step is usually based on the header information of the request message (such as the Content-Type field) or the agreement between the gateway and the channel party.

[0080] Furthermore, once the message format is determined, the gateway needs to select the corresponding parser. For example, if the message is in JSON format, the gateway will select a JSON parser; if the message is in XML format, it will select an XML parser. These parsers are usually pre-integrated in the gateway or can be dynamically loaded through plug-ins.

[0081] The gateway uses the selected parser to parse the message. The parser will extract the information in the message according to the message format specification and convert it into a data structure that can be understood and processed by the gateway.

[0082] If you use a JSON parser, for a JSON formatted message, the parser will read the key-value pairs in the message and convert them into data structures such as dictionaries (in Python) or hash tables (in other languages). Each key-value pair represents a field in the message and its value.

[0083] If you use an XML parser, for an XML-formatted message, the parser will read the tags and attributes in the message and convert them into a tree data structure (such as a DOM tree). Each tag and attribute represents an element and its attributes in the message.

[0084] After parsing the message content, the gateway extracts key information from it, such as business code, request parameters, etc. This information is the basis for subsequent routing decisions and request processing. Business codes are usually used to identify the business type or operation of the request and are an important basis for routing decisions. Request parameters contain various information required to execute the request, such as user ID, operation type, data content, etc.

[0085] Step S12, reading the pre-cached gateway routing basic configuration to obtain routing configuration information corresponding to the service code;

[0086] The gateway periodically loads the basic gateway routing configuration from the configuration center or parameter center and caches it locally or in memory. Figure 2 As shown, Figure 2 A schematic diagram of the basic routing configuration provided for the routing redirection method of this application. The basic routing configuration refers to the mapping relationship between the business code and the routing configuration information. The gateway uses the business code as a key to search for the corresponding routing configuration information in the pre-cached basic routing configuration. The routing configuration information includes routing factors, target clusters, target paths, etc.

[0087] Step S13, judging whether there is a gateway routing key configuration based on the routing configuration information;

[0088] Judging whether there is a gateway routing key configuration is to judge whether there is a gateway routing key configuration based on the business code, destination cluster and other information in the routing configuration information, such as Figure 3 As shown, Figure 3 A schematic diagram of the gateway routing key value configuration provided for the routing redirection method of this application. The gateway routing key value configuration includes a mapping of business codes and routing rules. Each business code corresponds to a set of routing rules, which determine how the gateway should route when it receives a request with the business code.

[0089] In addition, the gateway routing key configuration also includes key information such as routing factors, routing keys, routing information storage interface, routing key query method and query fields, which are used to further refine routing decisions.

[0090] Step S14: If the gateway routing key configuration exists, then the routing interface information corresponding to the service code is obtained according to the gateway routing key configuration.

[0091] If there is a gateway routing key configuration, the gateway will check the routing interface information corresponding to the business code of the current request. The routing interface information usually includes the routing key query method and the routing key query field.

[0092] Therefore, the key query method and key query field of the current request can be determined through the routing interface information, so that the personalized routing key value can be extracted from the request message according to the routing interface information, and the personalized routing key value can be converted into a unified routing key value for routing distribution.

[0093] Based on the first embodiment of the present application, the second embodiment of the present application is proposed. In the second embodiment of the present application, the same or similar contents as those of the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following.

[0094] On this basis, please refer to Figure 4 , Figure 4 A flowchart of a second embodiment of the routing redirection method provided in the present application.

[0095] In this embodiment, if the gateway routing key configuration exists, then after step S14 of acquiring routing interface information corresponding to the service code according to the gateway routing key configuration, step S15 is also included:

[0096] Step S15: If the gateway routing key configuration does not exist, the request message is distributed to the sub-database of the destination cluster.

[0097] If the primary gateway routing key configuration does not exist, the gateway will not continue to try to parse or apply any routing key-related rules. This means that the gateway will not dynamically select the routing target based on specific fields or parameters in the request, but will use a default forwarding strategy. This strategy is usually pre-defined in the gateway configuration to guide how to handle requests that do not match the routing rules.

[0098] According to the default forwarding strategy, the gateway distributes the request message to the first sub-database of the destination cluster. The "destination cluster" here refers to the backend service cluster, which can be determined by the routing configuration information. The "sub-database" refers to one or more database instances or partitions in the cluster. The first sub-database is selected as the default target based on multiple considerations such as load balancing, data consistency, or simplification of system architecture.

[0099] Directly skip parsing the routing key value and forward to the first shard of the destination cluster by default. By distributing requests that do not match the routing key configuration to the first shard of the destination cluster, the gateway can prevent these requests from being mistakenly transmitted to the incorrect shard. This helps ensure data integrity and consistency while reducing the risk of system failure or data loss due to routing errors.

[0100] In this embodiment, routing distribution is performed on requests without gateway routing key configuration to ensure that when no gateway routing key configuration is matched, the request can be correctly distributed to the first sub-database of the destination cluster, thereby preventing data from being transmitted to an incorrect sub-database and ensuring the stability and reliability of the system.

[0101] Based on the first embodiment and / or the second embodiment of the present application, the third embodiment of the present application is proposed. In the third embodiment of the present application, the same or similar contents as those of the above embodiments can be referred to the above introduction, and will not be repeated in the following.

[0102] On this basis, please refer to Figure 5 , Figure 5 A flowchart of the third embodiment of the routing redirection method provided in the present application.

[0103] In this embodiment, the step S20 of determining the client code according to the routing interface information may include steps S21-S22:

[0104] Step S21, extracting a personalized routing key from the request message according to the routing interface information, and converting the personalized routing key into a unified routing key;

[0105] After obtaining the routing interface information, the gateway will extract the personalized routing key from the request message according to the rules defined in the routing interface information (such as routing key query method, routing key query field, etc.). Because different business scenarios and requests may require different personalized routing keys, personalized routing keys are diverse. The gateway needs to flexibly handle these different personalized routing keys to meet various business needs.

[0106] Although personalized routing keys can meet the needs of specific business scenarios, in order to facilitate subsequent routing distribution and unified management, the gateway needs to convert these personalized routing keys into unified routing keys. The gateway converts the extracted personalized routing keys according to the configuration information or preset rules.

[0107] Specifically, in a feasible implementation, step S21 further includes: performing route distribution through the unified routing key value. The converted unified routing key value will serve as the basis for subsequent route distribution. The gateway will decide to which backend application instance or database sub-library the request should be forwarded based on the unified routing key value. Since the gateway can process personalized routing key values ​​and convert them into unified routing key values, it can flexibly perform route distribution under different business scenarios and requests. This dynamism and flexibility enable the gateway to adapt to changing business needs.

[0108] In this embodiment, a personalized routing key is extracted from the request message according to the routing interface information, and the personalized routing key is converted into a unified routing key for unified routing distribution. Converting the personalized routing key into a unified routing key enables the business system to process routing keys of different formats, thereby improving the flexibility of the routing strategy.

[0109] Step S22, obtaining the customer code from the unified routing key value.

[0110] The unified routing key is the converted routing information, which converts the diverse personalized routing key values ​​into a unified format so that the gateway can recognize and process it. The unified routing key is essential for determining the location of customer data and correctly routing requests to backend services. The customer code is an identifier used to uniquely identify the customer. It is mainly obtained by parsing the unified routing key and is usually associated with the customer's actual routing target. From the parsed unified routing key, the gateway can extract the corresponding customer code.

[0111] In this embodiment, by extracting a personalized routing key from a request message according to routing interface information, the requirements of different business scenarios and requests can be flexibly adapted. This method of extracting personalized routing keys ensures that the system can process routing information in various formats, thereby enhancing the flexibility of routing policies. Converting personalized routing keys into unified routing keys makes subsequent routing distribution and unified management simpler and more efficient. This conversion mechanism ensures that routing information in different business scenarios can be processed in a standardized manner, thereby simplifying the complexity of routing management.

[0112] Based on the above embodiments of the present application, a fourth embodiment of the present application is proposed. In the fourth embodiment of the present application, the same or similar contents as those of the above embodiments can be referred to the above introduction, and will not be described in detail later.

[0113] In this embodiment, the step S30 of defining the redirection routing configuration according to the customer code and reading the redirection routing configuration matching routing factor field may include steps S31 to S34:

[0114] Step S31, defining a redirection routing configuration according to the client code;

[0115] Use the customer code suffix as the routing factor, according to Figure 6 The redirection routing configuration shown defines a rule table for redirection routing configuration. The redirection routing configuration includes business scenarios, namely query or transaction scenarios. In addition, the redirection routing configuration also includes information for routing redirection, such as the target sub-database, source sub-database, and migration status.

[0116] Step S32: Periodically cache the redirection routing configuration to a local parameter configuration center.

[0117] The gateway will periodically (such as every 5 minutes) load the latest redirection routing configuration from the remote database or configuration center. This ensures that the configuration information in the gateway is up to date and can reflect the actual status of the backend service.

[0118] After loading the latest redirect route configuration, the gateway will cache the redirect route configuration to the local parameter configuration center. The gateway can read the configuration information directly from the local cache without querying the remote database or configuration center every time, thus improving the efficiency of processing requests.

[0119] Step S33, reading the routing configuration information of the request message and the redirection routing configuration cached in the local parameter configuration center;

[0120] The routing configuration information refers to the key information that has been pre-determined according to the business code during the routing distribution process, including the business code, request code, request method, destination cluster and destination path. Therefore, during the routing redirection process, you only need to read the routing configuration information corresponding to the request message, and there is no need to re-match and determine the routing configuration information with the request message.

[0121] Redirection routing configuration usually includes key information such as routing factor field, redirection target address, redirection condition, migration status, etc. Redirection routing configuration is loaded into the local cache of the gateway for quick access when needed. Redirection routing configuration defines how to redirect routing in different scenarios. For example, during the business system migration phase, some customer requests need to be redirected to a new database or application instance.

[0122] Step S34, matching the routing configuration information with the redirection routing configuration to obtain a routing factor field.

[0123] After reading the routing configuration information of the request message, the gateway will match the routing configuration information with the redirection routing configuration cached locally. The key to the match lies in the routing factor field, which is an identifier that can uniquely identify a request or client.

[0124] In this embodiment, the corresponding redirection routing configuration is configured according to the customer code, and new routing configurations and redirection rules can be dynamically added during the configuration process, which has good scalability. By periodically caching the redirection routing configuration to the local parameter configuration center, the gateway can efficiently process requests and ensure that the requests are correctly routed to the backend service. Read the routing configuration information of the request message and the redirection routing configuration cached to the local parameter configuration center; match the routing configuration information and the redirection routing configuration to obtain the routing factor field. By matching the obtained routing factor field, the best routing path can be accurately selected, thereby improving the efficiency and accuracy of routing.

[0125] Based on the above embodiments of the present application, a fifth embodiment of the present application is proposed. In the fifth embodiment of the present application, the same or similar contents as those of the above embodiments can be referred to the above introduction, and will not be described in detail later.

[0126] In this embodiment, the step S40 of performing route redirection based on the routing factor field and the type of the request message may include steps S41 to S43:

[0127] Step S41, obtaining the transplantation status information and determining whether the routing factor field is configured with a redirection strategy;

[0128] Route redirection is mainly proposed for the migration or upgrade of the backend business system. In order to ensure that the client's request can continue to be processed correctly, the gateway will perform route redirection and redirect the request from the old service address to the new service address. During the system migration process, each customer or customer's data set may be in different migration stages, such as not migrated, migrating, and completed. This migration status information is crucial for the gateway's routing decision. Therefore, the gateway needs to obtain this status information from a certain configuration or database in order to execute the corresponding routing strategy according to the customer's actual migration status.

[0129] During system migration, some routing factors may need to be configured with redirection policies. These policies tell the gateway how to redirect requests when encountering a specific routing factor. For example, if a customer's data has been migrated to a new database, then the gateway may need to redirect requests for that customer to the backend service where the new database is located. If the customer has not been migrated, no redirection is required. Redirection is required for both the migration in progress and migration completed states.

[0130] Step S42: if the routing factor field configures a redirection policy, routing redirection is performed based on the type of the request message and the transplantation status information;

[0131] If the routing factor field is configured with a redirection strategy, it means that the backend business system is in a transplantation state, or a transplantation completion state, and routing redirection is required to send the request corresponding to the routing factor to the correct database.

[0132] Request messages are usually divided into two categories: transaction and query. Transaction requests need to process data and update the database, while query requests need to retrieve data from the database. These two types of requests require different strategies when routing and redirecting.

[0133] Specifically, in a feasible implementation manner, step S42 may include steps S421 to S423:

[0134] Step S421: If the transplantation status information is transplanting and the type of the request message is a query request, the request message is routed and redirected to multiple sub-databases for combined query;

[0135] When the migration status information of the customer is "migration in progress" and the type of request message received is "query request", the gateway needs to adopt a special routing redirection strategy. Since data migration is usually a gradual process, the data involved may be scattered in multiple sub-databases (for example, the old database and the new database, or multiple databases in intermediate states). Therefore, in order to provide complete query results, the gateway needs to route and redirect this query request to multiple sub-databases for parallel query, and finally merge these query results.

[0136] Step S422: if the migration status information is in migration and the type of the request message is a transaction request, the request message is routed and redirected to a single sub-database;

[0137] Different from query requests, when the migration status information of a customer is "migration in progress" and the type of the received request message is "transaction request", the gateway needs to redirect the transaction request to a single sub-database. This is because during the data migration process, when modifying the transaction data of the same customer (such as adding, deleting or updating), the consistency and integrity of the data needs to be ensured.

[0138] Typically, this single shard will be the shard where the customer data currently resides (it could be the old database or the new database, depending on the progress of the migration). By routing transaction requests to this single shard, the gateway can ensure that transaction data is not corrupted or conflicted during the migration process.

[0139] Step S423: If the transplantation status information indicates that the transplantation is completed, the request message is directly routed and redirected to a single sub-database.

[0140] When the migration status information of the customer is "migration completed", it means that the customer's data has been completely migrated to the new database or sub-database. At this time, no matter whether the request message received is a query request or a transaction request, the gateway can directly redirect the request route to a single sub-database (that is, the target sub-database after the customer data is migrated), thereby simplifying the routing logic, improving routing efficiency, and ensuring that after the data migration is completed, all requests for the customer can be processed correctly.

[0141] Step S43: If the routing factor field is not configured with a redirection policy, routing redirection is performed based on a pre-established tail number configuration policy and the transplantation status information.

[0142] The pre-established suffix configuration strategy refers to judging the database in the migration state based on the suffix of the customer code to determine whether there is corresponding customer data in the old database. If there is corresponding customer data, the request is sent to the old database. If there is no corresponding customer data, the request is sent to the new database.

[0143] If the routing factor field does not configure a redirection policy, it is necessary to use the tail number configuration policy and the migration status information to perform a simple redirection operation, and directly send the request message to the corresponding database, rather than performing merge queries, data landing, and other operations based on the redirection policy.

[0144] Specifically, if there is customer data matching the suffix in the old database, it means that the customer data has not been completely migrated to the new database. Therefore, the gateway will redirect the request route to the old database to ensure that the request can be processed correctly.

[0145] If there is no customer data matching the suffix in the old database, it means that the customer's data has been migrated to the new database (or the customer itself is a new customer and its data has never been stored in the old database). Therefore, the gateway will redirect the request route to the new database.

[0146] In this embodiment, the transplantation status information is obtained and it is determined whether the routing factor field is configured with a redirection policy, and the routing policy is flexibly adjusted according to the current migration status and business needs. When the routing factor field is configured with a redirection policy, the gateway can forward the request to the correct database or service based on the type of request message and the transplantation status information. This improves the flexibility of the routing policy and ensures the correct processing and response of requests during the migration process, thereby achieving smooth split migration under the microservice architecture. When the routing factor field is not configured with a redirection policy, the gateway will route according to the pre-established tail number configuration policy and transplantation status information. This flexibility adapts to the ever-changing business needs and data migration scenarios under the microservice architecture, and ultimately makes the flexibility of the gateway routing policy continue to improve, and the scalability and maintainability of the microservice architecture are also improved.

[0147] This application also provides a routing redirection device, please refer to Figure 7 , the routing redirection device comprises:

[0148] The service code parsing module 10 parses the request message entering the gateway layer to obtain the service code, and obtains the routing interface information according to the service code;

[0149] The redirection routing configuration module 20 determines the customer code according to the routing interface information, defines the redirection routing configuration according to the customer code, and reads the redirection routing configuration matching routing factor field;

[0150] The routing redirection module 30 performs routing redirection based on the routing factor field and the type of the request message.

[0151] The routing redirection device provided by the present application adopts the routing redirection method in the above embodiment, which can solve the technical problem of routing redirection. Compared with the prior art, the beneficial effects of the routing redirection device provided by the present application are the same as the beneficial effects of the routing redirection method provided by the above embodiment, and other technical features in the routing redirection device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0152] The present application provides a routing redirection device, which includes: at least one processor; and a memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the routing redirection method in the above-mentioned embodiment 1.

[0153] Reference below Figure 8 , which shows a schematic diagram of the structure of a routing redirection device suitable for implementing the embodiment of the present application. The routing redirection device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The routing redirection device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0154] like Figure 8As shown, the routing redirection device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the routing redirection device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the routing redirection device to communicate wirelessly or wired with other devices to exchange data. Although the figure shows a routing redirection device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0155] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0156] The routing redirection device provided by the present application adopts the routing redirection method in the above embodiment to solve the technical problem of routing redirection. Compared with the prior art, the beneficial effects of the routing redirection device provided by the present application are the same as the beneficial effects of the routing redirection method provided by the above embodiment, and other technical features in the routing redirection device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0157] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0158] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0159] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the routing redirection method in the above-mentioned embodiment.

[0160] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0161] The computer-readable storage medium may be included in the routing redirection device; or may exist independently without being assembled into the routing redirection device.

[0162] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the routing redirection device, the routing redirection device: parses the request message entering the gateway layer to obtain the business code, and obtains the routing interface information according to the business code; determines the customer code according to the routing interface information; defines the redirection routing configuration according to the customer code, reads the redirection routing configuration to match the routing factor field; and performs routing redirection based on the routing factor field and the type of the request message.

[0163] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0164] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0165] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0166] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned routing redirection method, and can solve the technical problem of routing redirection. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the routing redirection method provided in the above-mentioned embodiment, and will not be repeated here.

[0167] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned routing redirection method when executed by a processor.

[0168] The computer program product provided by the present application can solve the technical problem of route redirection. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the route redirection method provided by the above embodiment, which will not be repeated here.

[0169] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A routing redirection method, characterized in that: The method comprises: Parse the request message entering the gateway layer to obtain the service code, and obtain the routing interface information according to the service code; Determine the client code according to the routing interface information; Define a redirection routing configuration according to the client code, and read a matching routing factor field of the redirection routing configuration; Routing redirection is performed based on the routing factor field and the type of the request message.

2. The method according to claim 1, characterized in that The step of parsing the request message entering the gateway layer to obtain a service code, and obtaining routing interface information according to the service code includes: Receive the request message transmitted by the channel party to the gateway layer, and parse the request message to obtain the business code; Reading the pre-cached gateway routing basic configuration to obtain routing configuration information corresponding to the service code; Determining whether there is a gateway routing key configuration based on the routing configuration information; If the gateway routing key configuration exists, the routing interface information corresponding to the service code is obtained according to the gateway routing key configuration.

3. The method according to claim 2, characterized in that The routing configuration information includes a destination cluster, and the step of determining whether there is a gateway routing key configuration based on the routing configuration information further includes: If the gateway routing key configuration does not exist, the request message is distributed to the sub-database of the destination cluster.

4. The method according to claim 1, characterized in that The step of determining the client code according to the routing interface information comprises: Extracting a personalized routing key value from the request message according to the routing interface information, and converting the personalized routing key value into a unified routing key value; The customer code is obtained from the unified routing key value.

5. The method according to claim 4, characterized in that After the step of extracting a personalized routing key from the request message according to the routing interface information and converting the personalized routing key into a unified routing key, the following step further comprises: Routing distribution is performed through the unified routing key value.

6. The method according to claim 1, characterized in that The step of defining a redirection routing configuration according to the client code and reading the redirection routing configuration matching routing factor field comprises: Define redirection routing configuration according to the client code; Periodically cache the redirection routing configuration to a local parameter configuration center; Read the routing configuration information of the request message and the redirection routing configuration cached in the local parameter configuration center; The routing configuration information is matched with the redirection routing configuration to obtain a routing factor field.

7. The method according to claim 1, characterized in that The step of performing routing redirection based on the routing factor field and the type of the request message comprises: Obtaining transplantation status information and determining whether the routing factor field is configured with a redirection strategy; If the routing factor field configures a redirection policy, routing redirection is performed based on the type of the request message and the transplantation status information; If the routing factor field is not configured with a redirection policy, routing redirection is performed based on a pre-established tail number configuration policy and the transplantation status information.

8. The method according to claim 7, characterized in that The types of the request message include transaction requests and query requests, and the step of performing routing redirection based on the type of the request message and the transplantation status information includes: If the transplantation status information is transplanting and the type of the request message is a query request, the request message is routed and redirected to multiple sub-databases for combined query; If the migration status information is in the process of migration and the type of the request message is a transaction request, the request message is routed and redirected to a single sub-database; If the transplantation status information indicates that the transplantation is completed, the request message is directly routed and redirected to a single sub-database.

9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the routing redirection method according to any one of claims 1 to 8 are implemented.

10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the routing redirection method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Transaction route determination method, device, equipment and system for transaction data

    CN111767144A

  • Routing method and device of client, equipment of client and storage medium

    CN113489650A

  • Redirection processing method and system

    CN114726917A

  • Data interoperability between open standard directory service and proprietary database

    US20040167866A1

  • Methods and systems for routing messages in a communications network

    WO2001048981A1