Business data processing method, device, equipment, storage medium and program

By dynamically switching the transaction manager in the business system to connect to the target database, the problem of multi-database configuration complexity and data source switching function coupling with business logic is solved, and multi-database shared transaction managers and flexible data source switching are realized, supporting Various sub-library scenarios.

CN113127102BActive Publication Date: 2024-10-01AGRICULTURAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110542242.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-18
Publication Date
2024-10-01
Estimated Expiration
2041-05-18

AI Technical Summary

Technical Problem

When the existing technology deploys multiple databases in a business system, multiple transaction managers and SqlSessionFactory need to be configured for each database, resulting in high configuration complexity and inability to effectively support horizontal sub-database scenarios, and the data source switching function and business processing logic Coupled and highly intrusive.

Method used

By obtaining the business request, determining the target routing identifier, and obtaining the connection information of the target database based on the target routing identifier, the transaction manager dynamically switches to connect to the target database, realizing multiple databases sharing a transaction manager, reducing configuration complexity, and decoupling data. Source switching function.

Benefits of technology

It enables flexible switching of transaction managers in multiple database scenarios, reduces configuration complexity and intrusiveness of business code, supports vertical sub-database, horizontal sub-database and hybrid scenarios, and improves application flexibility and data isolation capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113127102B_ABST
    Figure CN113127102B_ABST
Patent Text Reader

Abstract

The present application provides a method, apparatus, device, storage medium and program for processing business data. When a business request is received, a target routing identifier can be determined according to the business request, and the connection information of the target database can be determined according to the target routing identifier. The transaction manager can switch to connect to the target database according to the connection information of the target database, and process the target business data in the target database. It can be seen that in a scenario where a business system is deployed with multiple databases, the transaction manager can be switched to connect to different databases according to different business requests received, so that multiple databases share one transaction manager without having to configure a transaction manager for each database separately, thereby reducing configuration complexity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method, device, equipment, storage medium and program for processing business data. Background Art

[0002] A database is a warehouse that organizes, stores, and manages data according to data structures. A data source is the source of data. One data source corresponds to one database, and the data source records the information required to connect to the database. By configuring a data source for a business system, the business system can know which database to connect to and how to connect. Currently, many business systems support the deployment of multiple databases.

[0003] In the related art, when a business system is deployed with multiple databases, a transaction manager needs to be configured for each database. The data source is explicitly specified for each transaction manager by adding annotations in the code. For example, taking the deployment of two databases as an example, transaction manager 1 is assigned to database 1, and transaction manager 1 specifies data source 1. Transaction manager 2 is assigned to database 2, and transaction manager 2 specifies data source 2. When a business request of business type 1 is received, transaction manager 1 is used to connect to the database corresponding to data source 1 (i.e., database 1), and business operations within the transaction are performed in database 1. When a business request of business type 2 is received, transaction manager 2 is used to connect to the database corresponding to data source 2 (i.e., database 2), and business operations within the transaction are performed in database 2. In other words, by assigning different transaction managers to different databases, different transaction managers are used to implement transaction operations on different databases.

[0004] However, the above method requires configuring multiple transaction managers, which has high configuration complexity. Summary of the invention

[0005] The present application provides a business data processing method, apparatus, device, storage medium and program to reduce the configuration complexity of a business system.

[0006] In a first aspect, the present application provides a method for processing business data, which is applied to a business system, wherein the business system is deployed with multiple databases and a transaction manager for performing transaction operations on the multiple databases, and the method comprises:

[0007] Obtaining a business request, wherein the business request is used to request processing of target business data;

[0008] Determine a target routing identifier according to the service request, where the route corresponding to the target routing identifier is used to route to a target database, where the target database is a database in the multiple databases corresponding to the target service data;

[0009] Determining connection information of the target database according to the target routing identifier;

[0010] The transaction manager connects to the target database according to the connection information of the target database, and processes the target business data in the target database.

[0011] In a possible implementation, determining a target routing identifier according to the service request includes:

[0012] Obtaining a data source switching strategy corresponding to the business system;

[0013] According to the data source switching strategy, the service request is parsed and processed to obtain routing indication information;

[0014] The target route identifier is determined according to the route indication information.

[0015] In a possible implementation manner, determining the target route identifier according to the route indication information includes:

[0016] Acquire the mapping relationship between different routing indication information and different routing identifiers;

[0017] The routing indication information is mapped according to the mapping relationship to obtain the target routing identifier.

[0018] In a possible implementation, the business system corresponds to a plurality of data source switching strategies; according to the data source switching strategy, the business request is parsed and processed to obtain routing indication information, including:

[0019] For each data source switching strategy, a parsing method corresponding to the data source switching strategy is obtained, and the service request is parsed and processed using the parsing method to obtain routing indication information corresponding to the data source switching strategy;

[0020] Determining the target route identifier according to the route indication information includes:

[0021] The target routing identifier is determined according to the routing indication information corresponding to each of the plurality of data source switching strategies.

[0022] In a possible implementation, determining the connection information of the target database according to the target routing identifier includes:

[0023] Acquire a data source routing information set, wherein the data source routing information set includes a plurality of routing identifiers and connection information of a database corresponding to each routing identifier;

[0024] The connection information of the database corresponding to the target routing identifier in the data source routing information set is determined as the connection information of the target database.

[0025] In a possible implementation, before obtaining the data source routing information set, the method further includes:

[0026] Upon receiving a startup instruction of the business system, obtaining a first configuration file, wherein the first configuration file includes configuration information of multiple routes;

[0027] According to the first configuration file, obtaining a route identifier of each route and connection information of a database corresponding to each route;

[0028] The data source routing information set is generated according to the routing identifiers of the multiple routes and the connection information of the databases corresponding to the multiple routes.

[0029] In a possible implementation, obtaining, according to the first configuration file, a route identifier of each route and connection information of a database corresponding to each route includes:

[0030] Determine whether the connection mode of the database corresponding to the route is the first connection mode or the second connection mode;

[0031] If the connection mode of the database corresponding to the route is the first connection mode, obtaining the route identifier of the route and the reference name of the database corresponding to the route from the first configuration file, and obtaining the connection information of the database corresponding to the route from the second configuration file according to the reference name; or,

[0032] If the connection mode of the database corresponding to the route is the second connection mode, the route identifier of the route and the connection information of the database corresponding to the route are obtained from the first configuration file.

[0033] In a second aspect, the present application provides a business data processing device, which is applied to a business system, wherein the business system is deployed with multiple databases and a transaction manager for performing transaction operations on the multiple databases, and the device includes:

[0034] An acquisition module, used to acquire a service request, wherein the service request is used to request processing of target service data;

[0035] A first determining module is used to determine a target routing identifier according to the service request, wherein the route corresponding to the target routing identifier is used to route to a target database, and the target database is a database in the multiple databases corresponding to the target service data;

[0036] A second determining module, configured to determine connection information of the target database according to the target routing identifier;

[0037] The processing module is used to connect to the target database through the transaction manager according to the connection information of the target database, and process the target business data in the target database.

[0038] In a possible implementation manner, the first determining module is specifically configured to:

[0039] Obtaining a data source switching strategy corresponding to the business system;

[0040] According to the data source switching strategy, the service request is parsed and processed to obtain routing indication information;

[0041] The target route identifier is determined according to the route indication information.

[0042] In a possible implementation manner, the first determining module is specifically configured to:

[0043] Acquire the mapping relationship between different routing indication information and different routing identifiers;

[0044] The routing indication information is mapped according to the mapping relationship to obtain the target routing identifier.

[0045] In a possible implementation, the business system corresponds to a plurality of data source switching strategies; and the first determining module is specifically configured to:

[0046] For each data source switching strategy, a parsing method corresponding to the data source switching strategy is obtained, and the service request is parsed and processed using the parsing method to obtain routing indication information corresponding to the data source switching strategy;

[0047] The target routing identifier is determined according to the routing indication information corresponding to each of the plurality of data source switching strategies.

[0048] In a possible implementation manner, the second determining module is specifically configured to:

[0049] Acquire a data source routing information set, wherein the data source routing information set includes a plurality of routing identifiers and connection information of a database corresponding to each routing identifier;

[0050] The connection information of the database corresponding to the target routing identifier in the data source routing information set is determined as the connection information of the target database.

[0051] In a possible implementation manner, the device further includes a generating module, and the generating module is configured to:

[0052] Upon receiving a startup instruction of the business system, obtaining a first configuration file, wherein the first configuration file includes configuration information of multiple routes;

[0053] According to the first configuration file, obtaining a route identifier of each route and connection information of a database corresponding to each route;

[0054] The data source routing information set is generated according to the routing identifiers of the multiple routes and the connection information of the databases corresponding to the multiple routes.

[0055] In a possible implementation, the generating module is specifically used for:

[0056] Determine whether the connection mode of the database corresponding to the route is the first connection mode or the second connection mode;

[0057] If the connection mode of the database corresponding to the route is the first connection mode, obtaining the route identifier of the route and the reference name of the database corresponding to the route from the first configuration file, and obtaining the connection information of the database corresponding to the route from the second configuration file according to the reference name; or,

[0058] If the connection mode of the database corresponding to the route is the second connection mode, the route identifier of the route and the connection information of the database corresponding to the route are obtained from the first configuration file.

[0059] In a third aspect, the present application provides an electronic device, comprising: a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to implement the method as described in any one of the first aspects.

[0060] In a fourth aspect, the present application provides a computer-readable storage medium, comprising: a computer program, wherein when the computer program is executed by a processor, the method as described in any one of the first aspects is implemented.

[0061] In a fifth aspect, the present application provides a computer program product, comprising: a computer program, wherein when the computer program is executed by a processor, the method as described in any one of the first aspects is implemented.

[0062] The business data processing method, device, equipment, storage medium and program provided by the present application can determine the target routing identifier according to the business request when receiving a business request, and determine the connection information of the target database according to the target routing identifier. The transaction manager can switch to connect to the target database according to the connection information of the target database, and process the target business data in the target database. It can be seen that in the scenario where the business system is deployed with multiple databases, the transaction manager can be switched to connect to different databases according to different business requests received, so that multiple databases share one transaction manager without having to configure a transaction manager for each database separately, thereby reducing the configuration complexity. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] 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, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0064] Figure 1 A schematic diagram of the system architecture of the business system involved in the embodiment of the present application;

[0065] Figure 2 A schematic diagram of a business system based on multiple data sources in the related art;

[0066] Figure 3 Based on Figure 2 Schematic diagram of data processing process of the business system shown;

[0067] Figure 4 A schematic diagram of a business system based on multiple data sources provided in an embodiment of the present application;

[0068] Figure 5 A flowchart of a method for processing business data provided in an embodiment of the present application;

[0069] Figure 6 A schematic diagram of a flow chart of a method for generating a data source routing information set provided in an embodiment of the present application;

[0070] Figure 7 A schematic diagram of a business data processing process provided in an embodiment of the present application;

[0071] Figure 8 A schematic diagram of another business data processing process provided in an embodiment of the present application;

[0072] Fig. 9A schematic diagram of another business data processing process provided in an embodiment of the present application;

[0073] Fig.10 A schematic diagram of another business data processing process provided in an embodiment of the present application;

[0074] Fig.11 A schematic diagram of the structure of a device for processing business data provided in an embodiment of the present application;

[0075] Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0076] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0077] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0078] First, the professional terms or concepts involved in the embodiments of the present application are explained.

[0079] Data source: refers to the database used by the database application.

[0080] Multiple data sources: multiple databases. An application can be configured with multiple databases. For example, database A is the online database of the application, and database B is the batch database of the application.

[0081] Dynamic data source: A collection of multiple data sources, which appears to be an independent data source to the outside world. You can dynamically switch to one of the data source collections, but only one data source is effective at the same time, that is, only one transaction can be effective.

[0082] MyBatis: MyBatis is an excellent persistence framework that supports custom SQL, stored procedures, and advanced mapping. MyBatis eliminates almost all JDBC code and the work of setting parameters and obtaining result sets. MyBatis can be configured and mapped to records in the database using simple XML or annotations for primitive types, interfaces, and Java POJOs (Plain Old JavaObjects).

[0083] MyBatis-Plus: MP for short, is an enhancement tool for MyBatis. It only enhances MyBatis without making any changes. It is designed to simplify development and improve efficiency.

[0084] SqlSessionFactory: It is the key object of MyBatis. It is a compiled memory image of a single database mapping relationship. An instance of the SqlSessionFactory object can be obtained through the SqlSessionFactoryBuilder object class, and SqlSessionFactoryBuilder can build an instance of the SqlSessionFactory from an XML configuration file or a pre-customized Configuration instance. Every MyBatis application is centered on an instance of the SqlSessionFactory object. At the same time, the SqlSessionFactory is also thread-safe. Once the SqlSessionFactory is created, it should exist during the execution of the application. Do not create it multiple times during the operation of the application. It is recommended to use the singleton mode. The SqlSessionFactory is a factory that creates the SqlSession.

[0085] Spring: Spring is a lightweight alternative to Java Enterprise Edition (JEE, also known as J2EE). Spring provides a relatively simple method for enterprise-level Java development, without the need to develop heavyweight Enterprise Java Beans (EJBs). It implements EJB functions with plain old Java objects (POJOs) through dependency injection (IOC) and aspect-oriented programming (AOP).

[0086] Aspect Oriented Programming (AOP) can be said to be a supplement and improvement to Object Oriented Programming (OOP). It uses a technique called "crosscutting" to dissect the internals of encapsulated objects and encapsulate those common behaviors that affect multiple classes into a reusable module, which is named "Aspect". The so-called "aspect" is simply to encapsulate the logic or responsibility that is irrelevant to the business but is commonly called by the business modules, so as to reduce the duplication of system code, reduce the coupling between modules, and facilitate future operability and maintainability.

[0087] SpringBoot: SpringBoot is a complete solution for Spring to achieve automatic configuration and reduce the complexity of project construction. SpringBoot itself does not provide the core features and extended functions of the Spring framework, but is only used to quickly and agilely develop a new generation of applications based on the Spring framework. In other words, it is not a solution to replace Spring, but a tool that is closely integrated with the Spring framework to improve the Spring developer experience. SpringBoot is based on the idea that convention is better than configuration, which allows developers to avoid switching between configuration and logical business thinking and devote themselves to writing logical business code, thereby greatly improving development efficiency and shortening the project cycle to a certain extent.

[0088] For ease of understanding, the following Figure 1 The system architecture of the business system involved in the embodiments of the present application is introduced.

[0089] Figure 1 Schematic diagram of the system architecture of the business system involved in the embodiment of this application. Figure 1 As shown, in the business system provided by this embodiment, a server / server cluster and multiple databases are deployed. The server / server cluster can process the business data in the above multiple databases. For example, the server / server cluster can add business data to each database, modify business data, delete business data, etc.

[0090] It should be noted that the business system of this embodiment can be applied to a variety of application scenarios, including but not limited to: banking business scenarios, financial business scenarios, e-commerce business scenarios, social business scenarios, etc. For ease of understanding, the following examples will be described using the banking business scenario as an example.

[0091] In some exemplary scenarios, the above-mentioned multiple databases can be divided into vertical databases. Vertical database division means that the data tables in one database are divided into multiple databases based on the tables and according to different business attributes. The structure of each database after the division is different, and the data in different databases is also different. For example, assume that the business system generates the following data tables: user data table, loan business data table, financial business data table, etc. In the vertical database division method, the user data table can be stored in database 1, the loan business data table can be stored in database 2, and the financial business data table can be stored in database 3.

[0092] In other exemplary scenarios, the above-mentioned multiple databases can be divided into horizontal databases. The horizontal database division method refers to dividing the data in one database into multiple databases based on fields and according to a certain strategy. The structure of each database after division is the same, but the data in different databases is different.

[0093] For example, a bank usually has branches in various regions around the world. Regulatory authorities in different regions have different regulatory requirements for data independence. For example, some regions clearly state that business data generated in this region and business data generated in other regions are not allowed to be deployed in the same database. Therefore, when deploying a database, it is necessary to consider the data isolation requirements of different regions. Therefore, according to the different regions where the business data is generated, the business data generated in region 1 can be stored in database 1, the business data generated in region 2 can be stored in database 2, and the business data generated in region 3 can be stored in database 3.

[0094] In some other exemplary scenarios, the above-mentioned multiple databases can be mixed with vertical sub-library and horizontal sub-library methods. For example, database 1 can store user data tables generated by region 1, database 2 can store loan business data tables generated by region 1, database 3 can store financial management business data tables generated by region 1, database 4 can generate user data tables generated by region 2, database 5 can store loan business data tables generated by region 2, database 6 can store financial management business data tables generated by region 2, database 7 can generate user data tables generated by region 3, database 8 can store loan business data tables generated by region 3, and database 9 can store financial management business data tables generated by region 3.

[0095] Data source refers to the source of data. A data source corresponds to a database, and the data source records the information required to connect to the database. By configuring a data source for a business system, the business system can know which database to connect to and how to connect. Currently, many business systems can support the configuration of multiple data sources.

[0096] In the related art, when a business system supports the deployment of multiple databases, a transaction manager needs to be configured for each database. Figure 2 It is a schematic diagram of a business system based on multiple data sources in the related art. Figure 2 The MyBatis-Plus framework based on SpringBoot is used as an example. Figure 2 As shown, a transaction manager and SqlSessionFactory are configured for each database.

[0097] Furthermore, in the business processing code of each transaction manager, it supports configuring the default data source, and can also specify a specific data source through the @DS annotation. Exemplarily, the @DS annotation is added to the service implementation, that is, Mybatis-Plus only supports operating the database corresponding to a data source within a single Service method. For example, if a business processing method does not add the @DS annotation, the database corresponding to the default data source is operated when the business processing method is executed. If a business processing method adds the annotation: @DS("dsName"), where dsName can be a data source, the database corresponding to dsName is operated when the business processing method is executed.

[0098] When a business request of a certain business type is received, the transaction manager corresponding to the business type can be used to connect to the corresponding database according to the data source specified by the code annotation. Figure 3 Based on Figure 2 The data processing process diagram of the business system is shown in Figure 1. Figure 3 As shown in the figure, if the annotation in the business processing code is @DS("data source 1"), then the database corresponding to data source 1 is selected for connection. If the annotation in the business processing code is @DS("data source 2"), then the database corresponding to data source 2 is selected for connection, and so on. Then, the business operation within the transaction is performed in the corresponding database. In other words, by assigning different transaction managers to different databases, different transaction managers are used to implement transaction operations on different databases.

[0099] However, in the process of implementing this application, the inventors found that the above-mentioned related technologies have at least the following technical problems:

[0100] (1) The above method requires configuring a transaction manager and SqlSessionFactory for each database. When a business system is deployed with multiple databases, multiple transaction managers and multiple SqlSessionFactory need to be configured, making the configuration more complex.

[0101] (2) The above method limits the binding relationship between the transaction manager and the database at the code level, so that one business processing method only supports the operation of one database. Therefore, the above related technologies can usually only be used in the scenario of vertical database partitioning, but not in the scenario of horizontal database partitioning. Because in the scenario of horizontal database partitioning, the data table structure in different databases is the same, and the business processing logic of different databases is also the same. It is hoped that a set of codes will be used to implement the business processing process of multiple databases. However, one business processing method in the above related technologies only supports the operation of a specified database. Therefore, it cannot meet the data processing requirements of horizontal database partitioning.

[0102] (3) The above method requires adding annotations to the business processing code to specify the data source, which is highly invasive to the business code. When implementing the business processing logic, business developers also need to consider the data source switching function, which results in a high degree of coupling between the data source switching function and the business processing logic.

[0103] In order to solve at least one of the above technical problems, the present application embodiment provides a method for processing business data. Figure 4 The inventive concept of this application is introduced.

[0104] Figure 4 Schematic diagram of a business system based on multiple data sources provided in an embodiment of the present application. Figure 4 As shown, multiple databases are deployed in the business system, and multiple databases share a transaction manager and a SqlSessionFactory. When a business request is received, the target routing identifier can be determined according to the business request, and the connection information of the target database can be determined according to the target routing identifier. The transaction manager connects to the target database according to the connection information of the target database and processes the target business data in the target database.

[0105] It can be seen that in the present application, the transaction manager can dynamically switch connections to different databases according to the current business request, so that only one transaction manager needs to be configured for the business system, reducing the configuration complexity. Accordingly, there is no need to add annotations to the business processing code to specify the data source, reducing the intrusiveness to the business code, so that business developers do not need to consider the data source switching function when implementing the business processing logic, so that the data source switching function is decoupled from the business processing logic. Furthermore, the present application solution can be applied to vertical sub-library scenarios, horizontal sub-library scenarios, and scenarios where vertical sub-library and horizontal sub-library are mixed, which improves the flexibility of the application scenarios.

[0106] The technical solution of the present application is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0107] Figure 5 A flowchart of a method for processing business data provided in an embodiment of the present application. Figure 4 Execution on a server / server cluster in .

[0108] like Figure 5 As shown, the method of this embodiment includes:

[0109] S501: Obtain a service request, where the service request is used to request processing of target service data.

[0110] Specifically, when the terminal device needs to process the target service data, it sends a service request to the server / server cluster to request the server / server cluster to process the target service data.

[0111] The target business data may be data in any database in the business system. In other words, the business request may be a request to process the target business data in any database in the business system.

[0112] Exemplarily, the service request may be used to request to add target service data, delete target service data, or modify target service data.

[0113] S502: Determine a target routing identifier according to the service request, where the route corresponding to the target routing identifier is used to route to a target database, where the target database is a database corresponding to the target service data among the multiple databases.

[0114] In this embodiment, the target service data in which database needs to be processed can be determined according to the service request. In this embodiment, the database that needs to process the target service data is called the target database. The target database can be any one of multiple databases.

[0115] Optionally, the service request may include a target routing identifier. Exemplarily, the service request may include a first field, and the value of the first field is the target routing identifier. In this way, the target routing identifier can be determined according to the value of the first field in the service request. For example, in a banking service scenario, the first field may be a branch identification field, a service type field, a channel type field, a region identification field, etc.

[0116] Optionally, the service request may include routing indication information. There is a certain mapping relationship between different routing indication information and different routing identifiers. In this way, by mapping the routing indication information in the service request, the target routing identifier can be determined.

[0117] In the business system of this embodiment, multiple data sources are deployed, and different data sources can be switched according to different business requests received. In practical applications, one or more data source switching strategies can be adopted according to the needs of the actual application scenario. Taking the banking business scenario as an example, the data source switching strategies that can be adopted include but are not limited to: switching data sources according to branch identification, switching data sources according to regional identification, switching data sources according to business type, and switching data sources according to channel type.

[0118] In one possible implementation, the target routing identifier can be determined based on the business request in the following feasible manner: obtain the data source switching strategy corresponding to the business system, parse and process the business request according to the data source switching strategy, obtain routing indication information, and determine the target routing identifier based on the routing indication information.

[0119] Optionally, a mapping relationship between different routing indication information and different routing identifiers may be obtained, and the routing indication information may be mapped according to the mapping relationship to determine a target routing identifier.

[0120] When different data source switching strategies are adopted, the routing indication information carried in the service request may be different, and accordingly, the parsing method of the service request may also be different. The following is an illustration with reference to several specific examples.

[0121] In one example, assume that the adopted data source switching strategy is to switch the data source according to the branch ID, that is, the business data of different branches are stored in different databases. In this example, the branch ID can be carried in the business request, and the branch ID is used as the routing indication information. Then, the branch ID can be parsed from the business request, and then, according to the mapping relationship between the branch and the database, the branch ID is mapped and processed to obtain the target routing ID.

[0122] In another example, assume that the adopted data source switching strategy is to switch the data source according to the region identifier, that is, the business data of different regions are stored in different databases. In this example, the business request can carry the region identifier, and the region identifier is used as routing indication information. Then, the region identifier can be parsed from the business request, and then, according to the mapping relationship between the region and the database, the region identifier is mapped to obtain the target routing identifier.

[0123] In another example, it is assumed that the adopted data source switching strategy is to switch the data source according to the business type, that is, the business data of different business types are stored in different databases. In this example, the business type can be carried in the business request, and the business type is used as the routing indication information. Then, the business type can be parsed from the business request, and then the business type is mapped according to the mapping relationship between the business type and the database, and the target routing identifier can be obtained.

[0124] In another example, assume that the adopted data source switching strategy is to switch the data source according to the channel type, that is, the business data of different channel types are stored in different databases. In this example, the business request can carry the channel type, and the channel type serves as the routing indication information. Then, the channel type can be parsed from the business request, and then the channel type can be mapped according to the mapping relationship between the channel type and the database to obtain the target routing identifier.

[0125] In some possible scenarios, the business system may have multiple data source switching strategies. For example, the business system uses a data source switching strategy that switches the data source based on the branch ID + business type. In this case, the business request can carry both the branch ID and the business type.

[0126] Optionally, when there are multiple data source switching strategies corresponding to the business system, the parsing method corresponding to each data source switching strategy can be obtained, and the business request can be parsed and processed using the parsing method to obtain the routing indication information corresponding to the data source switching strategy. Further, the target routing identifier is determined based on the routing indication information corresponding to each of the multiple data source switching strategies.

[0127] Optionally, the routing indication information corresponding to each of the multiple data source switching strategies may be concatenated to obtain a target routing identifier.

[0128] For example, assume that the data source switching strategy adopted by the business system is to switch the data source according to the branch identifier + business type. A routing indication information (branch identifier) ​​parsed from the business request is "HK", and another routing indication information (business type) parsed from the business request is business type A, then the target routing identifier can be determined to be "HK_A". The splicing method of multiple routing indication information is only for illustration. In actual applications, multiple routing indication information can be spliced ​​according to the naming rules of the routing identifiers.

[0129] S503: Determine the connection information of the target database according to the target routing identifier.

[0130] The connection information of a database refers to the information required by the transaction manager to connect to the database. For example, the connection information of a database may include the Internet Protocol Address (IP) address, port number, connection account number, connection password, and other information corresponding to the database.

[0131] There is a corresponding relationship between the routing identifier and the connection information of the database. Therefore, the connection information of the target database can be determined according to the target routing identifier.

[0132] In a possible implementation, the connection information of the target database can be determined in the following manner: a data source routing information set is obtained, wherein the data source routing information set includes multiple routing identifiers and connection information of a database corresponding to each routing identifier; and the connection information of the database corresponding to the target routing identifier in the data source routing information set is determined as the connection information of the target database.

[0133] S504: Connecting to the target database according to the connection information of the target database through the transaction manager, and processing the target business data in the target database.

[0134] In this embodiment, after the connection information of the target database is determined, the target database can be connected to by the transaction manager according to the connection information of the target database, and the target business data can be processed in the target database.

[0135] For example, taking a banking business system as an example, assuming that the bank includes three branches, the business data of branch 1 is stored in database 1, the business data of branch 2 is stored in database 2, and the business data of branch 3 is stored in database 3.

[0136] In one example, it is assumed that the business system receives business request 1, and adopts the solution of this embodiment to parse business request 1 to obtain branch identifier 1, thereby determining that the target route is route 1. Then, by querying the data source route information set, the connection information of database 1 corresponding to route 1 can be obtained. Then, the transaction manager connects to database 1 according to the connection information of database 1, and processes the target business data in database 1.

[0137] In another example, assuming that the business system receives business request 2, the solution of this embodiment is adopted to parse business request 2 to obtain branch identifier 2, thereby determining that the target route is route 2. Then, by querying the data source route information set, the connection information of database 2 corresponding to route 2 can be obtained. Then, the transaction manager connects to database 2 according to the connection information of database 2, and processes the target business data in database 2.

[0138] In another example, it is assumed that the business system receives business request 3, and adopts the solution of this embodiment to parse business request 3 to obtain branch identifier 3, thereby determining that the target route is route 3. Then, by querying the data source route information set, the connection information of database 3 corresponding to route 3 can be obtained. Then, the transaction manager connects to database 3 according to the connection information of database 3, and processes the target business data in database 3.

[0139] In the method for processing business data provided in this embodiment, when a business request is received, a target routing identifier can be determined according to the business request, and the connection information of the target database can be determined according to the target routing identifier. The transaction manager can switch to connect to the target database according to the connection information of the target database, and process the target business data in the target database. It can be seen that in a scenario where a business system is deployed with multiple databases, the transaction manager can be switched to connect to different databases according to different business requests received, thereby realizing that multiple databases share one transaction manager, without the need to configure a transaction manager for each database separately, thereby reducing configuration complexity.

[0140] Furthermore, since multiple databases can share a transaction manager, it is not necessary to add annotations to the business processing code to specify the data source, reducing the intrusion into the business code. As a result, business developers do not need to consider the data source switching function when implementing the business processing logic, thus decoupling the data source switching function from the business processing logic.

[0141] Furthermore, since this embodiment can switch the transaction manager to connect to different databases according to different business requests received, it realizes flexible switching of the transaction manager between multiple databases and avoids specifying the data source in the business processing code. Therefore, this embodiment can be applied to both vertical and horizontal database scenarios, and can also be applied to scenarios where vertical and horizontal databases are mixed, thereby improving application flexibility.

[0142] In the above embodiment, when the target routing identifier is determined, the connection information of the target database can be determined according to the data source routing information set. The generation process of the data source routing information set is described below in conjunction with a specific embodiment.

[0143] Figure 6 The present invention provides a flow chart of a method for generating a data source routing information set according to an embodiment of the present invention. Figure 6 As shown, the method of this embodiment includes:

[0144] S601: When receiving a startup instruction of the business system, obtain a first configuration file, wherein the first configuration file includes configuration information of multiple routes.

[0145] S602: According to the first configuration file, obtain a route identifier of each route and connection information of a database corresponding to each route.

[0146] S603: Generate the data source routing information set according to the routing identifiers of the multiple routes and the connection information of the databases corresponding to the multiple routes.

[0147] In this embodiment, the first configuration file is used to record the configuration information of each route. One route corresponds to a connection path of a database. When the first configuration file changes, for example, when a data source is added, modified, or deleted, the data source routing information set needs to be updated, so the business system can be restarted. During the initialization process of starting the business system, the routing identifier of each route and the connection information of the database corresponding to each route are obtained according to the first data configuration file. Then, the data source routing information set is generated according to the routing identifiers of the multiple routes and the connection information of the databases corresponding to the multiple routes.

[0148] In a possible implementation, for each route configured in the first configuration file, it can be determined first whether the connection mode of the database corresponding to the route is the first connection mode or the second connection mode. Exemplarily, taking Java as an example, the first connection mode can be the Java Naming and Directory Interface (JNDI) connection mode, and the second connection mode can be the Druid connection mode. When a database adopts the JNDI connection mode, it is only necessary to record the reference name of the database in the first configuration file, and record the connection information of the database in the second configuration file. When it is necessary to obtain the connection information of the database, the second configuration file can be accessed according to the reference name in the first configuration file. When a database adopts the Druid connection mode, the connection information of the database can be recorded in the first configuration file.

[0149] Therefore, the following feasible method can be adopted to obtain the route identifier of each route and the connection information of the database corresponding to the route.

[0150] Optionally, if the connection method of the database corresponding to the route is the JNDI connection method, the route identifier of the route and the reference name of the database corresponding to the route are obtained from the first configuration file, and the connection information of the database corresponding to the route is obtained from the second configuration file based on the reference name.

[0151] Optionally, if the connection mode of the database corresponding to the route is the Druid connection mode, the route identifier of the route and the connection information of the database corresponding to the route are obtained from the first configuration file.

[0152] In this embodiment, multiple databases deployed in the business system can be of the same type or different types, such as mysql, oracle, sybase, etc. Because Druid supports mysql, oracle, sybase, etc., JNDI also supports mysql, oracle, sybase, etc.

[0153] Based on the above embodiments, Spring is taken as an example to illustrate the implementation process of the technical solution of the present application.

[0154] Figure 7 A schematic diagram of a business data processing process provided by an embodiment of the present application. Figure 7 As shown, the business system is deployed with a data source routing information set generator, a routing identifier parser, a routing identifier holder, a transaction manager and a data source routing information set.

[0155] The data source routing information set generator can obtain the first configuration file during the startup of the business system, and generate the data source routing information set according to the first configuration file. The data source routing information set includes multiple routing identifiers and connection information of the database corresponding to each routing identifier.

[0156] The first configuration file records configuration information of multiple routes. Each route is used to route to a database in the business system. The configuration information of each route includes a route identifier corresponding to the route and relevant information of the database corresponding to the route.

[0157] When generating a data source routing information set, the data source routing information set generator determines for each route whether the connection mode of the database corresponding to the route is a JNDI connection mode or a Druid connection mode according to whether there is a jndi field in the configuration item of the route in the first configuration file.

[0158] If the jndi field exists in the configuration item of the route, it means that the database corresponding to the route is in JNDI connection mode, and the value of the jndi field is the reference name of the database corresponding to the route. In this case, the data source route information set generator can obtain the route identifier of the route from the first configuration file, and search for the connection information of the corresponding database from the second configuration file according to the value of the jndi field (that is, the reference name of the database corresponding to the route). In this way, a data source is generated according to the route identifier corresponding to the route and the connection information of the database corresponding to the route.

[0159] If the jndi field does not exist in the configuration item of the route, it means that the database corresponding to the route is in Druid connection mode. In this case, the data source route information set generator can obtain the route identifier of the route and the connection information of the database corresponding to the route from the first configuration file. In this way, a data source is generated according to the route identifier corresponding to the route and the connection information of the database corresponding to the route.

[0160] In an example, when the database corresponding to a route adopts the Druid connection mode, the configuration items of the route in the first configuration file are as follows:

[0161] spring.datasource.odf.multidatasource.default.url=xxx

[0162] spring.datasource.odf.multidatasource.default.aliases=xxx

[0163] spring.datasource.odf.multidatasource.default.username=xxx

[0164] spring.datasource.odf.multidatasource.default.password=xxx

[0165] When the database corresponding to a route adopts the JNDI connection mode, the configuration items of the route in the first configuration file are as follows:

[0166] spring.datasource.odf.multidatasource.default.jndi=xxx

[0167] Among them, default is the route identifier.

[0168] When a route is configured with both the JNDI connection mode and the Druid connection mode, the data source route information collection generator can give priority to the JNDI connection mode.

[0169] Through the above design, the solution of this application supports both the Druid connection mode and the JNDI connection mode, and also supports a mixed configuration of the Druid connection mode and the JNDI connection mode.

[0170] Optionally, the configuration item of each route in the first configuration file may include an aliases field. For example, taking the banking business scenario as an example, assume that the business system is deployed according to regions, and different regions use different databases. Assume that region A includes three branches, namely Branch 1, Branch 2 and Branch 3, and the three branches in region A use the same database. In this case, only the route corresponding to Branch 1 in region A can be configured in the first configuration file, and the identifiers of Branch 2 and Branch 3 can be configured in the alias field of the route. In this way, when generating a data source routing information set, the data source routing information set generator can generate the data source corresponding to Branch 1 based on the configuration item of Branch 1, and can also generate the data sources corresponding to Branch 2 and Branch 3 based on the alias field of Branch 1.

[0171] In this way, by setting the alias field in the first configuration file, the amount of configuration information in the first configuration file is reduced, making the configuration process of the first configuration file more elegant and simple, and also realizing data source group management well.

[0172] Continue to see Figure 7 When receiving a service request, the routing identifier resolver can resolve the service request, obtain routing indication information, and determine the target routing identifier according to the routing indication information. The routing identifier resolver can set the target routing identifier into the routing identifier holder.

[0173] Continue to see Figure 7 The routing identifier holder is used to store the routing identifier k. The routing identifier holder can be said to be the global controller and manager of data source switching. By setting different routing identifiers, dynamic data source switching can be achieved.

[0174] Continue to see Figure 7 , the transaction manager will trigger the dynamic data source before opening the transaction. The customized dynamic data source in this embodiment inherits Spring's AbstractRoutingDataSource and overrides the determineCurrentLookupKey method, which obtains the target routing identifier from the routing identifier holder and returns it. During the business operation of the system, each time getConnection is used, the connection information of the database corresponding to the target routing identifier will be queried from the data source routing information set according to the target routing identifier, and the connection to the corresponding database will be made according to the connection information. Then, the transaction manager opens the transaction and performs business operations within the transaction.

[0175] pass Figure 7 The business data processing process shown realizes the dynamic switching of data sources.

[0176] Based on any of the above embodiments, the technical solution of the present application is illustrated below by taking a banking business scenario as an example and combining several specific examples.

[0177] Figure 8 A schematic diagram of another business data processing process provided by an embodiment of the present application. This embodiment is illustrated by taking a transaction business system as an example. In this embodiment, business data of different branches are stored in different databases, and a branch identifier can be used as a routing identifier.

[0178] The transaction business system adopts the client-server (C / S) architecture. Figure 8 As shown, the server receives the business request sent by the client, and parses the business request to obtain the branch ID (i.e., routing ID). The following takes branch ID 1 as an example for explanation. Assuming that the branch ID is 1, the branch ID 1 is stored in the target routing ID holder, and the connection information of the database corresponding to the branch ID 1 is obtained, and then the connection is switched to the database corresponding to the branch ID according to the connection information, and the transaction is started. Then, the responsibility chain nodes continue to be executed until all nodes are executed. According to the success or failure of the business logic layer execution, the data source transaction is committed or rolled back, and the current data source is cleared, and finally a dynamic data source routing switching cycle is formed, which is repeated, independent of each other, and does not interfere with each other.

[0179] In this embodiment, during the entire business logic processing process, developers only need to focus on the specific business processing logic and do not need to focus on the data source switching, that is, the data source switching is transparent to the business. However, it should be noted that the business logic processing layer cannot switch the data source again during the specific business processing, or in a database transaction. Even if it switches, it will have no effect because the database connection obtained at the beginning will be used in the transaction.

[0180] Fig. 9 A schematic diagram of another business data processing process provided by an embodiment of the present application. This embodiment is illustrated by taking a management business system as an example. In this embodiment, business data of different branches are stored in different databases, and a branch identifier can be used as a routing identifier.

[0181] Management business systems use the browser / server (B / S) architecture. Fig. 9As shown in the figure, the user sends a business request through the terminal browser. The server receives the business request through the Spring AOP surround aspect (which intercepts all RequestMapping requests), and parses the business request through the routing identifier resolver to obtain the branch identifier (i.e. routing identifier). The resolved branch identifier (i.e. routing identifier) ​​is stored in the routing identifier holder. When Spring obtains the database connection, it queries the data source routing information set according to the branch identifier (i.e. routing identifier) ​​in the routing identifier holder, obtains the connection information of the corresponding database, and then connects to the corresponding database according to the connection information to start the database transaction. Continue to execute the specific control layer (controller), business logic layer (service) and object persistence layer (mapper) steps. After the above steps are completed, the Spring AOP surround aspect will clear the current data source, and finally form a dynamic data source routing switching cycle, which is repeated, independent of each other, and does not interfere with each other.

[0182] Figure 8 and Fig. 9 The illustrated embodiment is mainly described for the scenario of horizontal database partitioning. The business data processing method provided in this application can be applied to the scenario of vertical database partitioning in addition to the scenario of horizontal database partitioning. For example, the database is partitioned according to the transaction type, and is divided into online database and batch database, or the database is partitioned according to the business type, and is divided into business type A database, business type B database, and business type C database. Fig.10 Give an example.

[0183] Fig.10 A schematic diagram of another business data processing process provided by an embodiment of the present application. Fig.10 As shown, the business system receives the business request, parses and processes the business request through the routing identifier resolver, and obtains the business type identifier (i.e., routing identifier). The business type identifier (i.e., routing identifier) ​​is set in the routing identifier holder. When Spring obtains the database connection, it queries the data source routing information set according to the business type identifier (i.e., routing identifier) ​​in the routing identifier holder to obtain the connection information of the corresponding database, connects to the corresponding database according to the connection information, and starts the database transaction. Then, continue to execute the business logic operations within the transaction. After the above steps are completed, the current data source is cleared, and finally a dynamic data source routing switching cycle is formed, which is repeated, independent of each other, and does not interfere with each other.

[0184] The embodiments of the present application have the following technical effects:

[0185] (1) The single-instance multi-tenant database connection pool technology is used to meet the data isolation requirements of different business scenarios. Based on a set of table structure design, a set of application code, a SqlSessionFactory, a transaction manager, and a dynamic data source, dynamic data source switching can be achieved according to different tenants (such as different branch IDs). Only one data source is effective at the same time, and business data of different tenants are stored in different databases, thus meeting data isolation requirements.

[0186] 2) The data source switching function is decoupled from the business processing logic. Business developers do not need to pay attention to the data source switching function, but only need to focus on the specific business processing logic. It is transparent to the business and imperceptible to users.

[0187] 3) The configuration item of the route in the first configuration file supports an alias field, and the configuration information of the route can be reused through the alias field to simplify the configuration process of the first configuration file. In addition, the data source routing information can also be grouped and managed according to the alias field.

[0188] 4) It supports both multiple data sources of the same type and mixed use of different types of data sources, such as MySQL, Oracle, Sybase, etc., because Druid supports MySQL, Oracle, Sybase, etc., and JNDI also supports MySQL, Oracle, Sybase, etc.

[0189] 5) It supports both Druid data source connection configuration and JNDI data source connection configuration, as well as mixed configuration of Druid and JNDI data source connections.

[0190] 6) It supports both horizontal and vertical database partitioning, and also supports the mixed use of horizontal and vertical database partitioning.

[0191] 7) The business system can define its own data source switching strategy according to actual needs. For example, it can switch according to branch ID, business type, channel type, regional ID, etc. It can also use a combination of multiple data source switching strategies, such as switching according to branch ID + business type, etc.

[0192] Fig.11 A schematic diagram of the structure of a business data processing device provided in an embodiment of the present application. The device can be in the form of software and / or hardware. The device can be applied to a business system, wherein the business system is deployed with multiple databases and a transaction manager for performing transaction operations on the multiple databases.

[0193] like Fig.11As shown, the service data processing device 1100 provided in this embodiment may include: an acquisition module 1101 , a first determination module 1102 , a second determination module 1103 and a processing module 1104 .

[0194] The acquisition module 1101 is used to acquire a service request, where the service request is used to request processing of target service data;

[0195] A first determining module 1102 is used to determine a target routing identifier according to the service request, where the route corresponding to the target routing identifier is used to route to a target database, where the target database is a database in the multiple databases corresponding to the target service data;

[0196] A second determining module 1103 is used to determine the connection information of the target database according to the target routing identifier;

[0197] The processing module 1104 is used to connect to the target database through the transaction manager according to the connection information of the target database, and process the target business data in the target database.

[0198] In a possible implementation, the first determining module 1102 is specifically configured to:

[0199] Obtaining a data source switching strategy corresponding to the business system;

[0200] According to the data source switching strategy, the service request is parsed and processed to obtain routing indication information;

[0201] The target route identifier is determined according to the route indication information.

[0202] In a possible implementation, the first determining module 1102 is specifically configured to:

[0203] Acquire the mapping relationship between different routing indication information and different routing identifiers;

[0204] The routing indication information is mapped according to the mapping relationship to obtain the target routing identifier.

[0205] In a possible implementation, the business system corresponds to multiple data source switching strategies; the first determining module 1102 is specifically configured to:

[0206] For each data source switching strategy, a parsing method corresponding to the data source switching strategy is obtained, and the service request is parsed and processed using the parsing method to obtain routing indication information corresponding to the data source switching strategy;

[0207] The target routing identifier is determined according to the routing indication information corresponding to each of the plurality of data source switching strategies.

[0208] In a possible implementation, the second determining module 1103 is specifically configured to:

[0209] Acquire a data source routing information set, wherein the data source routing information set includes a plurality of routing identifiers and connection information of a database corresponding to each routing identifier;

[0210] The connection information of the database corresponding to the target routing identifier in the data source routing information set is determined as the connection information of the target database.

[0211] In a possible implementation, the device further includes a generating module (not shown), wherein the generating module is configured to:

[0212] Upon receiving a startup instruction of the business system, obtaining a first configuration file, wherein the first configuration file includes configuration information of multiple routes;

[0213] According to the first configuration file, obtaining a route identifier of each route and connection information of a database corresponding to each route;

[0214] The data source routing information set is generated according to the routing identifiers of the multiple routes and the connection information of the databases corresponding to the multiple routes.

[0215] In a possible implementation, the generating module is specifically used for:

[0216] Determine whether the connection mode of the database corresponding to the route is the first connection mode or the second connection mode;

[0217] If the connection mode of the database corresponding to the route is the first connection mode, obtaining the route identifier of the route and the reference name of the database corresponding to the route from the first configuration file, and obtaining the connection information of the database corresponding to the route from the second configuration file according to the reference name; or,

[0218] If the connection mode of the database corresponding to the route is the second connection mode, the route identifier of the route and the connection information of the database corresponding to the route are obtained from the first configuration file.

[0219] The business data processing device provided in this embodiment can be used to execute the business data processing method in any of the above method embodiments. Its implementation principle and technical effects are similar and will not be described in detail here.

[0220] Fig.12This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may be an electronic device with a business system deployed. Fig.12 As shown, the electronic device 1200 provided in this embodiment includes: a processor 1201 and a memory 1202 .

[0221] The memory 1202 is used to store computer programs; the processor 1201 is used to execute the computer programs stored in the memory to implement one or more steps of the method for processing business data in the above embodiment. For details, please refer to the relevant description in the above method embodiment, the implementation principle and technical effect are similar, and this embodiment will not be repeated here.

[0222] Optionally, the memory 1202 may be independent or integrated with the processor 1201 .

[0223] When the memory 1202 is a device independent of the processor 1201 , the electronic device 1200 may further include: a bus 1203 for connecting the memory 1202 and the processor 1201 .

[0224] An embodiment of the present application also provides a computer-readable storage medium, which includes a computer program. The computer program is used to implement one or more steps in the method for processing business data in any of the above method embodiments. The implementation principle and technical effects are similar and will not be repeated here.

[0225] An embodiment of the present application also provides a chip, including: a memory and a processor, wherein the memory stores a computer program, and the processor runs the computer program to execute one or more steps of the method for processing business data in any of the above method embodiments. The implementation principles and technical effects are similar and will not be repeated here.

[0226] An embodiment of the present application also provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements one or more steps in the processing of business data in any of the above method embodiments. Its implementation principles and technical effects are similar and will not be repeated here.

[0227] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.

[0228] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0229] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The above-mentioned module-composed unit can be implemented in the form of hardware or in the form of hardware plus software functional units.

[0230] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the method described in each embodiment of the present application.

[0231] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the application may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.

[0232] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.

[0233] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0234] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.

[0235] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic device or a main control device.

[0236] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0237] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for processing business data, characterized in that: Applied to a business system, the business system is deployed with multiple databases and a transaction manager for performing transaction operations on the multiple databases, the method includes: Obtaining a business request, wherein the business request is used to request processing of target business data; Obtaining a data source switching strategy corresponding to the business system; the data source switching strategy includes one or more of the following: switching the data source according to the branch identifier, switching the data source according to the region identifier, switching the data source according to the business type, and switching the data source according to the channel type; According to the data source switching strategy, the service request is parsed and processed to obtain routing indication information; Determine a target routing identifier according to the routing indication information; wherein, under different data source switching strategies, the routing indication information carried in the service request is different, and the parsing method of the service request is different; the route corresponding to the target routing identifier is used to route to a target database, and the target database is a database corresponding to the target service data in the multiple databases; Acquire a data source routing information set, wherein the data source routing information set includes a plurality of routing identifiers and connection information of a database corresponding to each routing identifier; Determine the connection information of the database corresponding to the target routing identifier in the data source routing information set as the connection information of the target database; Connecting to the target database according to the connection information of the target database through the transaction manager, and processing the target business data in the target database; Before obtaining the data source routing information set, the method further includes: Upon receiving a startup instruction of the business system, obtaining a first configuration file, wherein the first configuration file includes configuration information of a plurality of routes, and each configuration item of the route includes an alias field; According to the first configuration file, obtaining a route identifier of each route and connection information of a database corresponding to each route; Generate the data source routing information set according to the routing identifiers of the multiple routes and the connection information of the databases corresponding to the multiple routes respectively; According to the first configuration file, obtaining a route identifier of each route and connection information of a database corresponding to each route includes: Determine whether the connection mode of the database corresponding to the route is the first connection mode or the second connection mode; If the connection mode of the database corresponding to the route is the first connection mode, obtaining the route identifier of the route and the reference name of the database corresponding to the route from the first configuration file, and obtaining the connection information of the database corresponding to the route from the second configuration file according to the reference name; or, If the connection mode of the database corresponding to the route is the second connection mode, the route identifier of the route and the connection information of the database corresponding to the route are obtained from the first configuration file.

2. The method according to claim 1, characterized in that Determining the target route identifier according to the route indication information includes: Acquire the mapping relationship between different routing indication information and different routing identifiers; The routing indication information is mapped according to the mapping relationship to obtain the target routing identifier.

3. The method according to claim 1, characterized in that There are multiple data source switching strategies corresponding to the business system; according to the data source switching strategy, the business request is parsed and processed to obtain routing indication information, including: For each data source switching strategy, a parsing method corresponding to the data source switching strategy is obtained, and the service request is parsed and processed using the parsing method to obtain routing indication information corresponding to the data source switching strategy; Determining the target route identifier according to the route indication information includes: The target routing identifier is determined according to the routing indication information corresponding to each of the plurality of data source switching strategies.

4. A device for processing business data, characterized in that: Applied to a business system, the business system is deployed with multiple databases and a transaction manager for performing transaction operations on the multiple databases, the device comprises: An acquisition module, used to acquire a service request, wherein the service request is used to request processing of target service data; The first determination module is used to obtain the data source switching strategy corresponding to the business system; the data source switching strategy includes one or more of the following: switching the data source according to the branch identification, switching the data source according to the regional identification, switching the data source according to the business type, and switching the data source according to the channel type; According to the data source switching strategy, the service request is parsed and processed to obtain routing indication information; Determine a target routing identifier according to the routing indication information; wherein, under different data source switching strategies, the routing indication information carried in the service request is different, and the parsing method of the service request is different; the route corresponding to the target routing identifier is used to route to a target database, and the target database is a database corresponding to the target service data in the multiple databases; A second determination module is used to obtain a data source routing information set, wherein the data source routing information set includes multiple routing identifiers and connection information of a database corresponding to each routing identifier; and determine the connection information of the database corresponding to the target routing identifier in the data source routing information set as the connection information of the target database; A processing module, configured to connect to the target database through the transaction manager according to the connection information of the target database, and process the target business data in the target database; A generating module, configured to obtain a first configuration file upon receiving a startup instruction of the business system, wherein the first configuration file includes configuration information of a plurality of routes, and each configuration item of the route includes an alias field; According to the first configuration file, obtaining a route identifier of each route and connection information of a database corresponding to each route; Generate the data source routing information set according to the routing identifiers of the multiple routes and the connection information of the databases corresponding to the multiple routes respectively; The generating module is specifically used to determine whether the connection mode of the database corresponding to the route is the first connection mode or the second connection mode; If the connection mode of the database corresponding to the route is the first connection mode, obtaining the route identifier of the route and the reference name of the database corresponding to the route from the first configuration file, and obtaining the connection information of the database corresponding to the route from the second configuration file according to the reference name; or, If the connection mode of the database corresponding to the route is the second connection mode, the route identifier of the route and the connection information of the database corresponding to the route are obtained from the first configuration file.

5. An electronic device, characterized in that: include: A memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to implement the method according to any one of claims 1 to 3.

6. A computer-readable storage medium, characterized in that: include: A computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.

7. A computer program product, characterized in that include: A computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.