Route redirection method, storage medium, and computer program product

By parsing request messages and implementing route redirection mechanisms, the inefficiency of traditional routing gateways in database splitting and migration under microservice architecture is resolved, achieving smooth splitting and migration and ensuring service continuity and system stability.

CN119603217BActive Publication Date: 2025-12-19CHINA MERCHANTS BANK
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Traditional routing gateways cannot gradually switch to smaller traffic volumes when migrating databases in a microservice architecture, resulting in long migration times and service interruptions, and thus failing to achieve smooth splitting and migration.

Method used

By parsing the request messages entering the gateway layer, extracting the business code and obtaining the routing interface information, defining the redirection route configuration according to the customer code, matching the routing factor field, and performing route redirection based on the request message type, the database can be migrated smoothly in batches.

Benefits of technology

It enables smooth database splitting and migration without service interruption through business code parsing and route redirection mechanisms, supports customers to migrate in small batches, and improves migration efficiency and system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119603217B_ABST
    Figure CN119603217B_ABST
Patent Text Reader

Abstract

The application discloses a routing redirection method, a storage medium and a computer program product, relates to the technical field of micro-service architecture, and the method comprises the following steps: analyzing a request message entering a gateway layer to obtain a service code, and acquiring routing interface information according to the service code; determining a customer code according to the routing interface information; defining a redirection routing configuration according to the customer code, reading a matching routing factor field of the redirection routing configuration; and performing routing redirection based on the routing factor field and the type of the request message. The routing redirection based on the type of the request message and the routing factor field realizes smooth split migration of a 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 technical field of micro-service architecture, and particularly relates to a routing redirection method, a storage medium and a computer program product. BACKGROUND

[0002] With the increasing popularity of micro-service architecture, the communication between the front-end application and the back-end service becomes increasingly complex. And with the rapid development of business and the demand for system expansion and upgrade, the back-end business system needs to split and upgrade or refactor and migrate the database. When facing database split and migration, the traditional routing gateway usually performs one-size-fits-all routing according to the preset routing factor, cannot gradually switch according to a small amount of traffic, and needs to stop the service during the migration process.

[0003] Therefore, how to realize the smooth split and migration of the database under the micro-service architecture has become a problem to be solved by the present application.

[0004] The above content is only used to assist in understanding the technical solutions of the present application and does not represent the acknowledgement of the above content as prior art. SUMMARY

[0005] The main purpose of the present application is to provide a routing redirection method, a storage medium and a computer program product, which aims to solve the technical problem of how to realize the smooth split and migration of the database under the micro-service architecture.

[0006] To achieve the above purpose, the present application provides a routing redirection method, which comprises:

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

[0008] determining a customer code according to the routing interface information;

[0009] defining a redirection routing configuration according to the customer code, and reading a routing factor field matching the redirection routing configuration;

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

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

[0012] receiving a request message transmitted by a channel party to the gateway layer, and parsing the request message to obtain a service code;

[0013] reading a 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-value configuration based on the routing configuration information;

[0015] if there is the gateway routing key-value configuration, obtaining routing interface information corresponding to the service code according to the gateway routing key-value configuration.

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

[0017] if there is no gateway routing key-value configuration, distributing the request message to a sub-database of the destination cluster.

[0018] In an embodiment, the step of determining a customer 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] obtaining a customer code from the unified routing key-value.

[0021] In an embodiment, after the step of 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 method further includes:

[0022] performing routing distribution through the unified routing key-value.

[0023] In an embodiment, the step of defining a redirection routing configuration according to the customer code, and reading a routing factor field matched with the redirection routing configuration includes:

[0024] defining a redirection routing configuration according to the customer code;

[0025] periodically caching the redirection routing configuration to a local parameter configuration center;

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

[0027] matching the routing configuration information and the redirection routing configuration to obtain a routing factor field.

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

[0029] obtaining transplantation state 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 migration state information;

[0031] If the routing factor field does not configure a redirection policy, routing redirection is performed based on a pre-established tail number configuration policy and the migration state information.

[0032] In an embodiment, the type of the request message includes a transaction type request and a query type request, and the step of performing routing redirection based on the type of the request message and the migration state information includes:

[0033] If the migration state information is in migration and the type of the request message is a query type request, the request message is routed and redirected to multiple sub-databases for combined query, respectively;

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

[0035] If the migration state information is completed, the request message is directly routed and redirected to a single sub-database.

[0036] In addition, to achieve the above object, the present application further provides a storage medium, which is a computer readable storage medium, and a computer program is stored on the storage medium, and the computer program is executed by a processor to implement the steps of the routing redirection method as described above.

[0037] In addition, to achieve the above object, the present application further provides a computer program product, which includes a computer program, and the computer program is executed by a processor to implement the steps of the routing redirection method as described above.

[0038] The one or more technical solutions provided by the present application have at least the following technical effects:

[0039] The request message entering the gateway layer is parsed, so as to extract the service code. The service code is a key identification of different service types or request purposes. Through the service code, the corresponding routing interface information can be quickly located, so as to ensure that accurate operation can be performed for specific service requests, and to provide a prerequisite for smooth migration. According to the routing interface information, the customer code is determined, and then the redirection routing configuration can be defined according to the customer code. The routing factor field is matched. The routing factor field is provided with a secondary orientation target, and supports customer small batch gentle migration. Based on the routing factor field and the type of the request message, the routing redirection is performed, which means that the request message is redirected to a new target address or path, so that the database is migrated in batches in a smooth manner without interrupting the service. In summary, through the service code analysis, gateway layer routing configuration reading and matching, and routing redirection mechanism, the smooth split migration of the database under the micro-service architecture is realized. BRIEF DESCRIPTION OF DRAWINGS

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

[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained without creative labor based on these drawings.

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

[0043] Figure 2 The schematic diagram of routing base configuration provided by the routing redirection method of the present application;

[0044] Figure 3 The schematic diagram of gateway routing key value configuration provided by the routing redirection method of the present application;

[0045] Figure 4 The flowchart of the second embodiment provided by the routing redirection method of the present application;

[0046] Figure 5 The flowchart of the third embodiment provided by the routing redirection method of the present application;

[0047] Figure 6 The redirection routing configuration definition rule table;

[0048] Figure 7 The module structure schematic diagram of the routing redirection device of the embodiment of the present application;

[0049] Figure 8 A device structure schematic diagram of a hardware running environment involved in a route redirection method in an embodiment of the present application.

[0050] The object implementation, functional features and advantages of the present application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION

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

[0052] In order to better understand the technical solutions of the present application, the following will be described in detail in combination with the accompanying drawings and specific embodiments.

[0053] The main solution of the embodiment of the present application is that the gateway analyzes the request message entering the gateway layer, extracts the service code from it, and the service code is used to identify the service type or purpose of the request message. Then, the corresponding route interface information is obtained according to the service code, which indicates how to perform subsequent route processing according to the content of the request message. After obtaining the route interface information, the gateway determines the customer code according to the route interface information, configures the customer code, and obtains the redirection route configuration. The redirection route configuration is matched with the route factor field to determine whether the request message needs to be redirected, and the target address of the redirection. Finally, the route factor field and the type of the request message are used for route redirection.

[0054] In the present embodiment, for the sake of description, the following describes the identification gateway as the execution subject.

[0055] The embodiment of the present application considers that with the increasing popularity of micro-service architecture, the communication between the front-end application and the back-end service becomes increasingly complex. And with the rapid development of business and the demand for system expansion and upgrade, the back-end business system needs to split, upgrade or refactor the database. When facing database splitting and migration, the traditional routing gateway usually performs one-size-fits-all routing according to the preset routing factor, cannot switch gradually according to small amount of traffic, takes a long time and needs to stop service during the migration process.

[0056] Therefore, the application provides a solution to parse the request message entering the gateway layer to extract the service code, which is a key identifier to identify different service types or request purposes. The service code can be used to quickly locate the corresponding routing interface information to ensure accurate operation for specific service requests, providing a prerequisite for smooth migration. The customer code is determined according to the routing interface information, and the redirection routing configuration can be defined according to the customer code. The routing factor field is matched, and the secondary redirection target is set in the routing factor field to support customer small batch gentle migration. The request message is redirected to a new target address or path based on the routing factor field and the type of the request message, so that the database can be migrated in batches in a smooth manner without interrupting the service. In summary, through the service code analysis, gateway layer routing configuration reading and matching, and routing redirection mechanism, the smooth split and migration of the database under the micro-service architecture are realized.

[0057] It should be noted that the execution subject of the embodiment can 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, a gateway, etc. capable of realizing the above functions. The embodiment and the following embodiments will be described below taking the gateway as an example.

[0058] Based on this, the application embodiment provides a routing redirection method, which is described with reference to Figure 1 , Figure 1 The flowchart of the first embodiment of the routing redirection method of the application is shown in FIG. 1.

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

[0060] Step S10, the request message entering the gateway layer is parsed to obtain the service code, and the routing interface information is obtained according to the service code;

[0061] The request message refers to the data packet sent by the front-end application or other client to the gateway, which contains the operation and data required by the front-end application to be executed by the back-end service.

[0062] The service code refers to a key field in the request message for identifying 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] The routing interface information refers to the interface information obtained by the gateway according to the service code, which is used to guide how to forward the request message, mainly including the routing key value query field and the routing key value query method.

[0064] As the gateway is usually designed as a multi-layer structure in microservice architecture, the "gateway layer" is mainly responsible for receiving, preliminary processing and forwarding request messages. In the gateway layer, the gateway performs tasks such as authentication, request parsing, routing selection, etc. 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 according to the parsed business code, finds the corresponding routing interface information in the configuration.

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

[0066] The routing interface information provides detailed forwarding guidance for the gateway, ensuring that the request message can be correctly forwarded to the target location. It contains routing key value query fields and routing key value query methods, which enable the gateway to flexibly select routing key values according to the specific content of the request message and determine the customer code accordingly. The customer code is the main part of the routing factor field.

[0067] It can be understood that the accuracy and completeness of the routing interface information are crucial for the smooth migration of the database under the microservice architecture, as they are directly related to whether the request message can be correctly forwarded and processed. Therefore, attention should be paid to the completeness and accuracy of the routing interface information.

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

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

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

[0071] If the routing factor field in the request message matches a certain entry in the redirection routing configuration successfully, the gateway will perform redirection operations according to the configuration of that entry. This may mean forwarding the request to a new database, application instance or different service path.

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

[0073] Step S40, routing redirection is performed based on the routing factor field and the type of the request message.

[0074] The type of the request message is usually divided into two categories: transaction and query. For transaction type request, it is decided after redirection where to place the transaction to complete the transaction and land the data. For query type request, it is necessary to integrate the scattered customer data in multiple sub-databases through redirection, and then output after merging.

[0075] The embodiment provides a routing redirection method. The request message entering the gateway layer is parsed to extract the business code. The business code is a key identifier for identifying different business types or request purposes. Through the business code, the corresponding routing interface information can be quickly located to ensure that accurate operations can be performed for specific business requests, providing a prerequisite for smooth migration. According to the routing interface information, the customer code is determined, and then the redirection routing configuration can be defined according to the customer code, the routing factor field is matched, the routing factor field is set with a secondary redirection target, and the customer small batch gentle migration is supported. Routing redirection is performed based on the routing factor field and the type of the request message, which means that the request message is redirected to a new target address or path, so that the database is migrated in batches smoothly without interrupting the service. In summary, through the business code analysis, gateway layer routing configuration reading and matching, and routing redirection mechanism, the smooth split migration of the database under the micro-service architecture is realized.

[0076] In a feasible implementation, step S10 can include steps S11-S14:

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

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

[0079] The gateway uses appropriate parsers (such as 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 (such as the Content-Type field) of the request message or the protocol agreement between the gateway and the channel party.

[0080] Further, 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 the JSON parser; if the message is in XML format, the XML parser will be selected. 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 specification of the message format, and convert it into a data structure that the gateway can understand and process.

[0082] If the JSON parser is selected, for JSON format messages, the parser will read the key-value pairs in the message and convert them into a dictionary (in Python) or hash table (in other languages) data structure. Each key-value pair represents a field in the message and its value.

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

[0084] After parsing the message content, the gateway extracts key information such as service code, request parameters, etc. from it. These information is the basis for subsequent routing decisions and request processing, and the service code is usually used to identify the type of request or operation, which is 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, read the pre-cached gateway routing base configuration to obtain the routing configuration information corresponding to the service code;

[0086] The gateway periodically loads the gateway routing base configuration from the configuration center or parameter center and caches it locally or in memory. For example, Figure 2 Figure 2 The routing base configuration provided by the routing redirection method of the present application is a schematic diagram of the routing base configuration, which refers to the mapping relationship between the service code and the routing configuration information. The gateway uses the service code as the key to find the corresponding routing configuration information in the pre-cached routing base configuration. The routing configuration information includes routing factors, target clusters, target paths, etc.

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

[0088] ​The determining whether the gateway routing key-value configuration exists refers to determining whether the gateway routing key-value configuration exists according to the service code and the destination cluster in the routing configuration information, as shown in Figure 3 Figure 3 The gateway routing key-value configuration provided for the routing redirection method of the application includes the mapping of the service code and the routing rule. Each service code corresponds to a set of routing rules, which determine how the gateway should route when receiving a request with the service code.

[0089] In addition, the gateway routing key-value configuration also includes key information such as routing factors, routing key values, routing information storage interfaces, routing key value query methods, and query fields, which are used to further refine the routing decision.

[0090] Step S14: If the gateway routing key-value configuration exists, obtaining the routing interface information corresponding to the service code according to the gateway routing key-value configuration.

[0091] If the gateway routing key-value configuration exists, the gateway will check the routing interface information corresponding to the service code of the current request. The routing interface information usually includes the routing key value query method and the routing key value query field.

[0092] Therefore, the key value query method and the key value 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 in the subsequent process, 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 application, the second embodiment of the application is proposed. In the second embodiment of the application, the same or similar contents as the above-mentioned first embodiment can be referred to the above introduction, and will not be described in detail.

[0094] On this basis, please refer to Figure 4 Figure 4 The second embodiment flowchart provided for the routing redirection method of the application.

[0095] In this embodiment, after the step S14 of obtaining the routing interface information corresponding to the service code according to the gateway routing key-value configuration if the gateway routing key-value configuration exists, the step S15 further includes:

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

[0097] ​​In the case where the primary gateway routing key value configuration does not exist, the gateway will not continue to attempt to resolve or apply any routing key value related rules. This means that the gateway will not dynamically select a routing target based on specific fields or parameters in the request, but instead will employ a default forwarding policy. This policy is typically pre-defined in the gateway configuration and is used to guide how to handle requests that do not match routing rules.

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

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

[0100] In this embodiment, the request without the gateway routing key value configuration is routed and distributed, ensuring that the request can be correctly distributed to the first shard of the destination cluster without matching the gateway routing key value configuration, thereby preventing data from being transmitted to the incorrect shard and ensuring the stability and reliability of the system.

[0101] Based on the first and / or second embodiments 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 the above embodiments can be referred to the above introduction, and will not be repeated hereinafter.

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

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

[0104] Step S21, 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;

[0105] After obtaining the routing interface information, the gateway extracts the personalized routing key value from the request message according to the rules defined in the routing interface information (such as routing key value query method, routing key value query field, etc.). Due to different business scenarios and requests, different personalized routing key values may be required, so personalized routing key values are diverse. The gateway needs to flexibly handle these different personalized routing key values to meet various business needs.

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

[0107] Specifically, in one possible implementation, step S21 is followed by: performing routing distribution through the unified routing key value. The converted unified routing key value will serve as the basis for subsequent routing distribution. The gateway will determine which backend application instance or which database sub-database the request should be forwarded to according to the unified routing key value. Since the gateway can handle personalized routing key values and convert them into unified routing key values, it can flexibly perform routing distribution under different business scenarios and requests. This dynamic and flexible nature allows the gateway to adapt to changing business needs.

[0108] In this embodiment, the personalized routing key value is extracted from the request message according to the routing interface information, and the personalized routing key value is converted into a unified routing key value for unified routing distribution. Converting the personalized routing key value into a unified routing key value allows the business system to handle routing key values in different formats, thereby improving the flexibility of routing strategies.

[0109] Step S22: Obtain the customer code from the unified routing key value.

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

[0111] In this embodiment, the personalized routing key value is extracted from the request message according to the routing interface information, which flexibly adapts to different business scenarios and request requirements. This extraction method of personalized routing key value ensures that the system can process routing information in various formats, thereby enhancing the flexibility of routing strategies. Converting the personalized routing key value into a unified routing key value 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-mentioned embodiments of the present application, the fourth embodiment of the present application is proposed. In the fourth embodiment of the present application, the same or similar contents as the above-mentioned embodiments can be referred to the above introduction, and the following will not be described in detail.

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

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

[0115] Taking the customer code suffix as the routing factor, the redirection routing configuration is defined according to the redirection routing configuration definition rule table as shown in Figure 6 The redirection routing configuration includes business scenarios, i.e., two scenarios of query and transaction. In addition, the redirection routing configuration also includes target sub-library, source sub-library, transplantation state and other information for routing redirection.

[0116] Step S32, periodically cache the redirection routing configuration to the 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 state of the backend service.

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

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

[0120] The routing configuration information refers to key information including a service code, a request code, a request mode, a destination cluster, and a destination path, which is determined in advance according to the service code in a routing distribution process. Therefore, only the routing configuration information corresponding to the request message needs to be read in the routing redirection process, and the matching and determination of the routing configuration information and the request message do not need to be performed again.

[0121] The redirection routing configuration generally includes a routing factor field, a redirection target address, a redirection condition, a migration state, and other key information. The redirection routing configuration is loaded into the local cache of the gateway for quick access when needed. The redirection routing configuration defines how to perform routing redirection in different scenarios. For example, during the migration stage of a service system, the requests of some customers need to be redirected to new databases or application instances.

[0122] In step S34, the routing configuration information and the redirection routing configuration are matched to obtain a routing factor field.

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

[0124] In this embodiment, the corresponding redirection routing configuration is configured according to the customer code. New routing configurations and redirection rules can be dynamically added during the configuration process, which has good scalability. By regularly 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 services. The routing configuration information of the request message is read and cached to the local parameter configuration center. The routing configuration information and the redirection routing configuration are matched to obtain a routing factor field. Through the routing factor field obtained by the matching, the best routing path can be accurately selected, thereby improving the efficiency and accuracy of routing.

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

[0126] In this embodiment, the step S40 of performing routing redirection based on the routing factor field and the type of the request message can include steps S41-S43.

[0127] In step S41, migration state information is obtained, and it is determined whether the routing factor field is configured with a redirection strategy.

[0128] The route redirection is mainly proposed for the case of migration or upgrade of the backend service system. In order to ensure that the request of the client can continue to be processed correctly, the gateway will perform route redirection to redirect the request from the old service address to the new service address. During the system migration process, each customer or customer data set may be in different migration stages, such as un-migrated, migrating, migrated, etc. These migration state information is crucial for the route decision of the gateway. Therefore, the gateway needs to obtain these state information from a certain configuration or database, so as to execute the corresponding route strategy according to the actual migration state of the customer.

[0129] During the system migration, some route factors may need to be configured with redirection strategies. These strategies tell the gateway how to redirect the request when encountering a specific route factor. For example, if the data of a customer has been migrated to a new database, the gateway may need to redirect the request for the customer to the backend service where the new database is located. If the customer is un-migrated, no redirection is needed. The migrating and migrated states both need redirection.

[0130] In step S42, if the route factor field is configured with a redirection strategy, the route redirection is performed based on the type of the request message and the migration state information.

[0131] If the route factor field is configured with a redirection strategy, it means that the backend service system is in a migration state or a migrated state, and route redirection is needed to send the request corresponding to the route factor to the correct database.

[0132] The request message is usually divided into two categories: transaction and query. The transaction request needs to process data and update the database, while the query request needs to retrieve data from the database. Different strategies need to be taken for these two types of requests in route redirection.

[0133] Specifically, in one possible implementation, step S42 can include steps S421-S423:

[0134] In step S421, if the migration state information is migrating and the type of the request message is a query request, the request message is respectively redirected to multiple sub-databases for combined query.

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

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

[0137] Unlike query type requests, when the client's migration status information is "in migration" and the received request message type is "transaction type request", the gateway needs to route and redirect this transaction type request to a single sub-database. This is because when modifying (such as adding, deleting or updating) transaction data of the same client during data migration, it is necessary to ensure the consistency and integrity of the data.

[0138] Usually, this single sub-database will be the sub-database where the client's data is currently located (it may be the old database or the new database, depending on the progress of the migration). By routing and redirecting the transaction type request to this single sub-database, the gateway can ensure that the transaction data is not damaged or conflicted during the migration process.

[0139] Step S423, if the migration status information is migration completed, the request message is directly routed and redirected to a single sub-database.

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

[0141] Step S43, if the routing factor field is not configured with a redirection strategy, routing redirection is performed based on a pre-established suffix configuration strategy and the migration status information.

[0142] The pre-established suffix configuration strategy refers to judging the database in the migration state according to the suffix of the client code, judging whether there is corresponding client data in the old database, if there is corresponding client data, sending the request to the old database, if there is no corresponding client data, sending the request to the new database.

[0143] If the routing factor field is not configured with a redirection policy, a simple redirection operation is performed using the tail number configuration policy and the transplant state information, and the request message is directly sent to the corresponding database, instead of performing operations such as combined query and data landing according to the redirection policy.

[0144] Specifically, if there is customer data matching the tail number in the old database, it indicates that the data of the customer has not been completely migrated to the new database. Therefore, the gateway redirects the request routing to the old database to ensure that the request can be correctly processed.

[0145] If there is no customer data matching the tail number in the old database, it indicates that the data of the customer has been migrated to the new database (or the customer is a newly added customer, and the data of the customer has never been stored in the old database). Therefore, the gateway redirects the request routing to the new database.

[0146] In the embodiment, the transplant state information is obtained, and it is determined whether the routing factor field is configured with a redirection policy. According to the current migration state and business requirements, the routing policy is flexibly adjusted. When the routing factor field is configured with a redirection policy, the gateway can forward the request to the correct database or service according to the type of the request message and the transplant state information. This improves the flexibility of the routing policy, ensures the correct processing and response of the request during the migration process, and thus realizes smooth split migration under the microservice architecture. When the routing factor field is not configured with a redirection policy, the gateway routes according to the pre-established tail number configuration policy and transplant state information. This flexibility adapts to the changing business requirements and data migration scenarios under the microservice architecture, and finally improves the flexibility of the gateway routing policy, and improves the scalability and maintainability of the microservice architecture.

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

[0148] The business code analysis module 10 analyzes the request message entering the gateway layer to obtain a business code, and obtains routing interface information according to the business code;

[0149] The redirection routing configuration module 20 determines a customer code according to the routing interface information, defines a redirection routing configuration according to the customer code, and reads the redirection routing configuration matching the 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 in the present application adopts the routing redirection method in the above embodiments, and can solve the technical problem of routing redirection. Compared with the prior art, the routing redirection device provided in the present application has the same beneficial effects as the routing redirection method provided in the above embodiments, and other technical features in the routing redirection device are the same as the features disclosed in the above embodiments, which will not be repeated here.

[0152] The present application provides a routing redirection device, which comprises at least one processor and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the routing redirection method in the above embodiment one.

[0153] Reference will be made to the following description of the embodiments of the present application, taken in conjunction with the accompanying drawings, in which Figure 8 which shows a structural diagram of a routing redirection device suitable for implementing the embodiments of the present application. The routing redirection device in the embodiments of the present application can include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (Personal Digital Assistant), PADs (Portable Application Description), PMPs (Portable Media Player), vehicle terminals (such as vehicle navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. Figure 8 The routing redirection device shown is only an example, and should not bring any limitation to the functions and use range of the embodiments of the present application.

[0154] As Figure 8As shown, the route redirecting device can include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes according to programs stored in a read only memory (ROM) 1002 or loaded from a storage device 1003 into a random access memory (RAM) 1004. Various programs and data required for operation of the route redirecting device are also stored in the RAM 1004. The processing device 1001, the ROM 1002, and the RAM 1004 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: input devices 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; the 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 route redirecting device to communicate wirelessly or wired with other devices to exchange data. Although the route redirecting device with various systems is shown in the figure, it should be understood that all the shown systems are not required to be implemented or possessed. More or less systems can be alternatively implemented or possessed.

[0155] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network through the communication device, or installed from the storage device 1003, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the methods of embodiments of the present disclosure are performed.

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

[0157] It should be understood that various aspects of the disclosure can be implemented in 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 appropriate manner in any one or more embodiments or examples.

[0158] The above description is only specific embodiments of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present application, which should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

[0159] The present application provides a computer readable storage medium having stored thereon computer readable program instructions (i.e., computer programs) for performing the route redirection method in the above embodiments.

[0160] The computer readable storage medium provided by the present application may, for example, be a U disk, but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, system, or device, or any combination thereof. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more conductive 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 appropriate combination thereof. In the present embodiment, the computer readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer readable storage medium can be transmitted by any appropriate medium, including but not limited to electrical wires, optical cables, RF (Radio Frequency), etc., or any appropriate combination thereof.

[0161] The above computer readable storage medium can be contained in the route redirection device; or can exist separately without being assembled into the route redirection device.

[0162] The computer readable storage medium carries one or more programs, when the one or more programs are executed by the route redirection device, the route redirection device is caused to: parse a request message entering a gateway layer to obtain a service code, and acquire route interface information according to the service code; determine a customer code according to the route interface information; define a redirection route configuration according to the customer code, read a route factor field matched with the redirection route configuration; and perform route redirection based on the route factor field and a type of the request message.

[0163] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can 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 the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0164] The flow diagrams and the block diagrams in the drawings are illustrations of architectures, functionalities, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of present application. In this regard, each block in the flow diagrams or block diagrams can represent a module, a procedure, or a part of code, which comprises one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in a different order than that noted in the figures. For example, two blocks noted in succession can in fact be executed substantially concurrently or in the opposite order, depending on the functionality involved. It is also noted that each block in the block diagrams and / or flow diagrams, and combinations of blocks in the block diagrams and / or flow diagrams, can be implemented by dedicated hardware-based systems that perform the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0165] The modules involved in the embodiments of the present application can be implemented in software or in hardware. In some cases, the names of the modules do not constitute a limitation on the modules themselves.

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

[0167] The present application also provides a computer program product comprising a computer program, which, when executed by a processor, implements the steps of the route redirection method as described above.

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

[0169] The above-mentioned is only part of the embodiments of the present application, and does not limit the patent scope of the present application. Any equivalent structural transformation, direct / indirect application in other related technical fields based on the technical concept of the present application, and the contents of the specification and drawings are included in the patent protection scope of the present application.

Claims

1. A method of route redirection, characterized by, The method comprises: parsing the request message entering the gateway layer to obtain a service code, and acquiring routing interface information according to the service code; determining a customer code according to the routing interface information; defining a redirection routing configuration according to the customer code, and reading a routing factor field matched with the redirection routing configuration; this step comprises: defining a redirection routing configuration according to the customer code; periodically caching the redirection routing configuration to a local parameter configuration center; reading routing configuration information of the request message and the redirection routing configuration cached to the local parameter configuration center; and matching the routing configuration information and the redirection routing configuration to obtain a routing factor field; performing routing redirection based on the routing factor field and the type of the request message; this step comprises: acquiring migration state information and judging whether the routing factor field is configured with a redirection strategy; if the routing factor field is configured with a redirection strategy, performing routing redirection based on the type of the request message and the migration state information; if the routing factor field is not configured with a redirection strategy, performing routing redirection based on a tail number configuration strategy established in advance and the migration state information; wherein the type of the request message comprises transaction type and query type, and the step of performing routing redirection based on the type of the request message and the migration state information comprises: if the migration state information is in migration and the type of the request message is query type, routing the request message to multiple sub-databases for combined query; if the migration state information is in migration and the type of the request message is transaction type, routing the request message to a single sub-database; if the migration state information is completed, directly routing the request message to a single sub-database.

2. The method of claim 1, wherein, The step of parsing the request message entering the gateway layer to obtain a service code, and acquiring routing interface information according to the service code comprises: receiving a request message transmitted to the gateway layer by a channel party, and parsing the request message to obtain a service code; reading pre-cached gateway routing basic configuration to obtain routing configuration information corresponding to the service code; judging whether there is a gateway routing key-value configuration based on the routing configuration information; if there is the gateway routing key-value configuration, acquiring routing interface information corresponding to the service code according to the gateway routing key-value configuration.

3. The method of claim 2, wherein, The routing configuration information comprises a destination cluster, and after the step of judging whether there is a gateway routing key-value configuration based on the routing configuration information, the method further comprises: if there is no gateway routing key-value configuration, distributing the request message to a sub-database of the destination cluster.

4. The method of claim 1, wherein, The step of determining a customer 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; acquiring a customer code from the unified routing key-value.

5. The method of claim 4, wherein, After the step of 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 method further comprises: Distribute routing by the uniform routing key value.

6. A storage medium, characterized by The storage medium is a computer readable storage medium, and the storage medium stores a computer program. The computer program is executed by a processor to implement the steps of the route redirection method in any one of claims 1 to 5.

7. A computer program product, characterised in that, The computer program product comprises a computer program. The computer program is executed by a processor to implement the steps of the route redirection method in any one of claims 1 to 5.

Citation Information

Patent Citations

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

    CN113489650A

  • Redirection processing method and system

    CN114726917A