Service information processing method and device, electronic equipment and storage medium
By storing business data in an independent database in a distributed information system and using data source identification and database replication mechanisms, the problem of data isolation and integration in traditional systems is solved, safe and efficient multi-level data management is achieved, and transformation costs and response delays are reduced.
Patent Information
- Application Number
- CN202510998071.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-21
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2045-07-21
AI Technical Summary
Traditional distributed information systems are difficult to meet the physical isolation of data in sub-level organizations and data integration requirements of cross-level organizations at the same time, resulting in high system complexity, increased response delays, and high transformation costs.
The service data of each subsystem is stored in an independent database, dynamic data source identification is defined, data source identification is passed through HTTP request headers, and combined with thread local variables and interceptor mechanisms to achieve accurate matching and operation across system data sources, and data summary is performed using database replication mechanism.
It realizes safe isolation and efficient summary of data in multi-level systems, reduces transformation costs, improves system response speed and management efficiency, and supports dynamic expansion and load balancing.
Smart Images

Figure CN120492460A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to a physical isolation technology for business data in a distributed information system, and in particular to a business information processing method, device, electronic device and storage medium. Background Art
[0002] Business data management refers to a series of management activities that involve the collection, storage, processing, analysis, and application of data related to business activities during the operation of a multi-tiered system or organization. The purpose is to ensure the accuracy, integrity, consistency, and availability of data to support core business objectives such as decision-making, process optimization, resource allocation, and planning. At the same time, relevant laws, regulations, and industry standards must be followed to ensure data security and privacy. Currently, in the field of business data management, existing technical solutions include data partitioning, data federation, data virtualization, cross-domain data synchronization, multi-tenant architecture, distributed database clustering, data middle-end integration, and middleware-based data routing. In the organizational structure of a large-scale hierarchically organized multi-tiered system, the multi-tiered system achieves a diversified business layout by establishing multiple independently operated sub-tiered organizations. Each sub-tiered organization needs to maintain operational autonomy while being subject to the management and control of the multi-tiered system. To address this characteristic, information systems in hierarchical organizations must simultaneously meet two core requirements: first, physical isolation of business data within sub-organizations at the storage level to ensure the independence of operational data and meet compliance requirements such as industry regulations and the protection of trade secrets; and second, the ability to integrate data across sub-organizations to support analysis, risk monitoring, and resource allocation across hierarchical levels. However, traditional distributed information systems often utilize a single database storage model, making it difficult to simultaneously meet these two requirements. With the exponential growth in the volume of business data such as payment data, user accounts, and logistics information, revamping existing systems requires large-scale adjustments to data processing logic and a deep restructuring of the technical architecture, which is not only costly but also carries the risk of business interruption. For example, data storage requires precise identification of the hierarchical organization to which the data belongs and targeted writing to the corresponding database. Data retrieval requires complex aggregation across multiple databases, significantly increasing system complexity and response latency. Therefore, a technical solution is urgently needed that can ensure the physical isolation of data within sub-organizations while enabling efficient and accurate cross-organizational data aggregation. Summary of the Invention
[0003] The present application provides a business information processing method, device, electronic device and storage medium, which can at least solve the aforementioned technical problems.
[0004] According to a first aspect of an embodiment of the present application, a business information processing method is provided, wherein the business data of each subsystem is stored in an independent database, each module in the subsystem is connected to all databases simultaneously to form a data source, and a dynamic data source identifier is defined; multiple databases storing the business data of each subsystem are used as master databases, and a newly created database is used as a slave database; the method includes: The gateway module receives the HTTP request from the client, obtains the database name corresponding to the access object based on the ID information of the access object in the HTTP request, puts the database identifier into the HTTP request, and forwards the HTTP request to the business module; Among them, the business module is based on the abstract routing data source of the Spring framework, forming a key-value pair locally with the database name as the key and the database connection pool as the value; The business module obtains the database identifier based on the HTTP request and stores it in the thread-local variable of the current thread; obtains the database name from the thread-local variable and selects the corresponding database connection pool based on the key-value pair; When calling other business modules, the corresponding database identifier is obtained from the thread local variable through the interceptor, and the database name is written into the new HTTP request header and passed to the other called business modules.
[0005] As an implementation mode, the method further includes: Configuration items are set for the gateway module. The corresponding relationship between the subsystem and the database is configured in the configuration items. The configuration items use the subsystem identification number as the index to establish a mapping relationship with the database name.
[0006] As an implementation mode, the method further includes: Create an independent connection pool for each database and load the connection parameters of each database; initialize multiple database connections and form key-value pairs for multiple database connections, and store the database name and the corresponding connection pool in a key-value pair data structure in memory; where the database name is the key and the database connection pool is the key value; When executing business logic to perform database operations, the database name is obtained from the thread identifier, and the corresponding database connection pool is obtained from the key-value pair through the database name.
[0007] As an implementation mode, the method further includes: Add a new configuration table for each master database, configure a serial number prefix, and set different configuration values for each master database. If the database table structure changes, add a new table for each master database and synchronize it with the slave database. Optimize the parameters of the slave database configuration file, obtain the error code for the configuration file ignoring the characteristics, and adjust the slave database configuration file and its parameters based on the error code. Create thread local variables through ThreadLocal technology and store the created thread local variables.
[0008] As an implementation mode, the method further includes: When calling other business modules, a new interceptor is added to trigger the interceptor to obtain the current database identifier from the thread local variable based on the thread identifier; the database key value is found according to the database identifier, and the corresponding database connection pool is found according to the key value; The interceptor is executed before the HTTP request is sent, adds the database identifier in the thread local variable to the request header, and passes it to other business modules.
[0009] According to a second aspect of an embodiment of the present application, a service information processing device is provided, including: Create a module to store the business data of each subsystem in an independent database, so that each module in the subsystem can connect to all databases at the same time to form a data source, and define a dynamic data source identifier; use multiple databases storing the business data of each subsystem as the master database, and the newly created database as the slave database; The gateway module receives the HTTP request from the client, obtains the database name corresponding to the access object based on the ID information of the access object in the HTTP request, puts the database identifier into the HTTP request, and forwards the HTTP request to the business module; The business module is used for the abstract routing data source based on the Spring framework. It forms a key-value pair locally with the database name as the key and the database connection pool as the value. It obtains the database identifier based on the HTTP request and stores the database identifier in the thread-local variable of the current thread. It obtains the database name from the thread-local variable and selects the corresponding database connection pool based on the key-value pair. The interceptor module is used to obtain the corresponding database identifier from the thread local variable when calling other business modules, and write the database name into the new HTTP request header to pass it to other called business modules.
[0010] As an implementation method, the device further includes: The first configuration unit is used to set configuration items for the gateway module, wherein the configuration items are configured with the corresponding relationship between the subsystem and the database; the configuration items use the subsystem identification number as an index to establish a mapping relationship between the configuration items and the database name.
[0011] As an implementation method, the creation module is further used to: Create an independent connection pool for each database and load the connection parameters of each database; initialize multiple database connections and form key-value pairs for multiple database connections, and store the database name and the corresponding connection pool in a key-value pair data structure in memory; where the database name is the key and the database connection pool is the key value; The gateway module is also used to obtain the database name from the thread identifier when executing business logic to perform database operations, and obtain the corresponding database connection pool from the key-value pair through the database name.
[0012] As an implementation method, the device further includes: The second configuration unit is used to add a new configuration table to each master database and configure a serial number prefix. The configuration values of the configuration table in each master database are different. If the database table structure changes, a new table is added to each master database, and a new table is added to the slave database in synchronization. The parameters of the slave database configuration file are optimized, and the error code of the configuration file ignoring the characteristics is obtained. The slave database configuration file and its parameters are adjusted based on the error code. The creation module is further used to create thread local variables through ThreadLocal technology and store the created thread local variables.
[0013] As an implementation method, the interceptor module is further used to: When calling other business modules, the current database ID is obtained from the thread local variable based on the thread ID; the database key value is found according to the database ID, and the corresponding database connection pool is found according to the key value; Executed before an HTTP request is sent, the database identifier in the thread-local variable is added to the request header and passed to other business modules.
[0014] According to a third aspect of an embodiment of the present application, a non-temporary computer-readable storage medium is provided, which enables the electronic device to perform the steps of the business information processing method when the instructions in the storage medium are executed by a processor of an electronic device.
[0015] The technical solutions provided by the embodiments of the present application may have the following beneficial effects: The technical solution of the embodiment of the present application is lightweight, reducing the workload of business logic modification. At the same time, it shields the physical dispersion of business data storage from the information system and supports the dynamic expansion of subsystems. Systems suitable for storing data logically separated in a single database need to be transformed into systems with multiple databases physically separated. By decoupling business logic and data storage, it is particularly suitable for information technology upgrade scenarios of multi-level organizations with diversified business segments and emphasis on data sovereignty. By storing the business data of each subsystem in an independent database and assigning a unique identifier to each data source, combined with the HTTP request header to transmit the data source identifier and thread marking mechanism, it ensures that the system can accurately match the corresponding data source when processing data, effectively avoiding data confusion and unauthorized access problems, and meeting compliance requirements and business secret protection needs. It can obtain the business data of all sub-level organizations in real time, forming a unified data query and analysis portal, facilitating global analysis, risk monitoring and resource allocation, and improving the overall management efficiency of the system. There is no need to carry out large-scale reconstruction of the existing information system. It only needs to introduce a data source identification mechanism in the data transmission layer and configure a master-slave replication mechanism in the data aggregation layer to achieve the dual goals of physical isolation and centralized management, reducing the risk of business interruption and development costs caused by system transformation. A thread tagging mechanism enables intelligent matching of data sources, eliminating the complex routing logic required for traditional cross-database queries and significantly improving system response speed. Furthermore, the combination of database replication and caching technology further optimizes high-frequency query performance and enhances the system's concurrent processing capabilities. The system architecture supports the dynamic addition of new subsystem database instances and can flexibly respond to business growth and complex scenarios through load balancing, distributed transactions, and other mechanisms.
[0016] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] Figure 1 A flowchart of a method for processing business information shown in an embodiment of the present application; Figure 2 This is a schematic diagram of the process flow of business data processing in a distributed system shown in an embodiment of the present application; Figure 3 This is a schematic diagram of the data processing flow of an interceptor in a distributed system shown in an embodiment of the present application; Figure 4 A schematic diagram of the structure of a business information processing device according to an embodiment of the present application; Figure 5It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0019] Exemplary embodiments are described in detail herein, with examples illustrated in the accompanying drawings. When the following description refers to the drawings, identical numerals in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatuses and methods consistent with certain aspects of the present application.
[0020] The present embodiment of the application is based on an information system architecture with multiple data source management and database replication mechanisms, aiming to achieve physical isolation and centralized aggregation of business data of sub-level organizations to improve data security and management efficiency. This technical solution is mainly applicable to information systems at the multi-level system level, and is particularly suitable for data management scenarios with multiple independent operating units such as subsidiaries or business-level organizations. At the data storage level, the present embodiment of the application stores the business data of each sub-level organization in an independent database, forming multiple logically separate data sources. Each data source is assigned a unique identification name and managed according to a unified naming rule. Each functional module in the information system is connected to multiple databases simultaneously to ensure that it can access all relevant data sources. During the data transmission process, the HTTP request header is used as the transmission medium for the data source identification, and the data source name is embedded in the request header to achieve cross-system data source identification. Each module adds a unique tag to the processing thread based on the received data source identification, so that subsequent operations can automatically match the corresponding data source based on the tag, thereby achieving precise access and operation of data from different sub-level organizations, effectively avoiding data confusion and unauthorized access problems. In terms of data aggregation, the independent database of each sub-level organization in the present embodiment of the application serves as the master database, and a new unified slave database is created to centrally store the data of all master databases. By configuring an efficient data replication mechanism, such as log-based incremental synchronization or real-time replication technology, it is ensured that the slave database can synchronize the data changes of each master database in real time and completely. This design not only realizes the centralized aggregation of business data, but also provides a unified data query and analysis portal for multi-level organizations, which facilitates global data governance and decision support. In summary, the technical solution of the embodiment of the present application, through the dynamic transmission of data source identifiers and the intelligent matching of thread tags, combined with an efficient database replication mechanism, constructs a safe, efficient, and scalable multi-level system-level data management system, which effectively solves the technical problems of data isolation and centralized management of multi-sub-level organizations.
[0021] The essence of the technical solution of the embodiment of the present application is further explained below through specific examples.
[0022] Figure 1This is a flow chart of a method for processing business information shown in an embodiment of the present application, as shown in FIG. Figure 1 As shown, the service information processing method of the embodiment of the present application may include the following processing steps: Step 101: The gateway module receives an HTTP request from a client, obtains the database name corresponding to the access object according to the ID information of the access object in the HTTP request, places the database identifier into the HTTP request, and forwards the HTTP request to the business module.
[0023] In an embodiment of the present application, the access object can be a sub-level organization in a multi-level system, and the business data of each sub-level organization is stored in an independent database. Each module of the information system is connected to multiple databases at the same time to form multiple data sources, and a unique name is uniformly assigned to each data source. The business data of each subsystem is stored in an independent database, and each module in the subsystem is connected to all databases at the same time to form a data source, and a dynamic data source identifier is defined; the multiple databases storing the business data of each subsystem are used as the master database, and the newly created database is used as the slave database.
[0024] Add a new configuration table for each master database and configure a serial number prefix. The configuration values of the configuration table in each master database are different. If the database table structure changes, add a new table for each master database and synchronize it with the slave database. Optimize the parameters of the slave database configuration file, obtain the error code of the configuration file that ignores the characteristics, and adjust the slave database configuration file and its parameters based on the error code.
[0025] In the embodiment of the present application, the business module is based on the abstract routing data source of the Spring framework, and locally forms a key-value pair with the database name as the key and the database connection pool as the value.
[0026] Set configuration items for the gateway module, which configure the correspondence between subsystems and databases. Use the subsystem ID as an index to establish a mapping relationship between the configuration items and the database name. Create a separate connection pool for each database and load the connection parameters for each database. Initialize multiple database connections and form key-value pairs for these connections. Store the database name and the corresponding connection pool in a key-value data structure in memory, using the database name as the key and the database connection pool as the key value. When executing business logic to perform database operations, obtain the database name from the thread ID and use the database name to retrieve the corresponding database connection pool from the key-value pair.
[0027] In step 102, the business module obtains a database identifier based on the HTTP request and stores the database identifier in a thread-local variable of the current thread; obtains a database name from the thread-local variable and selects a corresponding database connection pool based on a key-value pair.
[0028] In the embodiment of the present application, there is a configuration item inside the gateway module, which configures the correspondence between the hierarchical organization number and the database. The gateway module obtains the database name from the configuration item based on the hierarchical organization number of the currently logged-in user; when the gateway forwards the request to the business module, it puts the database name in the http request header; correspondingly, the business module inherits the abstract routing data source of the spring framework and initializes connections to multiple databases at startup. Once the business module receives the request, it obtains the database name from the http request header; marks the thread that currently receives / processes the request; and executes the business logic. That is, no matter how many database table operations this thread performs in the business logic, the corresponding database will be selected based on the database name.
[0029] Step 103: When calling other business modules, the corresponding database identifier is obtained from the thread local variable through the interceptor, and the database name is written into a new HTTP request header and passed to the other called business modules.
[0030] In an embodiment of the present application, when calling other business modules, a new interceptor is called, which triggers the interceptor to obtain the current database identifier from the thread local variable based on the thread identifier; searches for the database key value based on the database identifier, and searches for the corresponding database connection pool based on the key value; the interceptor is executed before the HTTP request is sent, and the database identifier in the thread local variable is added to the request header and passed to other business modules.
[0031] In the embodiments of this application, data processing primarily involves the storage, identification, transmission, and synchronization mechanisms of business data. The business data of each sub-organization originates from its internal operational systems, including but not limited to financial systems, customer relationship management systems (CRMs), and supply chain management systems (SCMs). Data from these systems is typically stored in a structured format, such as a table structure in a relational database, containing fields of types such as integers, floating-point numbers, strings, and dates and times. To achieve physical isolation and centralized management of data across multiple sub-organizations, unified naming and identification of the data sources of each sub-organization is required. Each sub-organization's database instance is assigned a unique identifier, such as "SG001" or "SG002." This identifier adheres to a unified naming convention to ensure uniqueness and identifiability across the entire information system. This naming convention can be defined as: SG + a three-digit number + a suffix identifier (such as _DB), resulting in a standard format such as "SG001_DB" or "SG002_DB." During data transmission, the HTTP request header is used as the medium for transmitting the data source identifier. Specifically, when a client initiates a request, the target data source's identifier is passed to the server via an HTTP request header field (such as X-Data-Source-ID). Upon receiving the request, the server parses the X-Data-Source-ID field in the request header and uses it as a unique identifier for the current thread, automatically matching the corresponding data source in subsequent operations. This identifier can be stored in a thread-local variable (ThreadLocal) to prevent data confusion between different threads in a multi-threaded environment. Furthermore, to ensure data consistency and integrity, necessary preprocessing operations are required during the data collection phase, including data cleansing, deduplication, and format standardization. For example, for the same business entity (such as customer information) from different sub-level organizations, field names and data types must be unified to avoid data parsing errors caused by field inconsistencies. Data cleansing can be achieved through methods such as regular expression matching for illegal characters, null padding, and outlier filtering. The core system architecture of this embodiment of the present application consists of multiple independent databases, a unified data source identification management module, business function modules, and a master-slave database replication mechanism. At the data storage layer, the business data of each sub-level organization is stored in an independent database instance. These database instances are deployed on different servers or virtual machines, logically isolated from each other and further physically isolated via network firewalls to enhance data security. Each database instance is configured with an independent access control policy, restricting access to authorized users or system modules only. At the application layer, each functional module in the information system (such as order management, inventory management, and report analysis) is connected to the database instances of all sub-level organizations, providing access to multiple data sources.When each module receives a request, it dynamically switches the database connection pool based on the data source identifier in the HTTP request header to ensure that operations are always executed against the correct data source. At the data aggregation layer, a "multi-master and one-slave" database replication strategy is adopted. The master database is an independent database instance for each sub-level organization, and the slave database is a unified centralized database instance. The slave database synchronizes incremental data by reading the master database's log files (such as MySQL's binlog and PostgreSQL's WAL log) to ensure real-time data updates. The synchronization mechanism supports both asynchronous and synchronous modes. The asynchronous mode is suitable for scenarios with lower real-time requirements, while the synchronous mode is suitable for business scenarios that require strong consistency guarantees. Figure 2 This is a schematic diagram of the processing flow of business data in a distributed system shown in an embodiment of the present application, such as Figure 2 As shown, during the data source identifier transmission and matching process, an identifier transmission algorithm based on the HTTP request header is adopted. Its core steps are as follows: 1. The client constructs an HTTP request and writes the target data source identifier into the request header; 2. The server receives the request and parses the data source identifier in the request header; 3. The data source identifier is stored in a thread-local variable; 4. All subsequent database operations select the corresponding database connection pool based on this identifier; 5. After the operation is completed, the thread-local variable is cleared to prevent memory leaks. Because this algorithm only involves simple string parsing and variable assignment operations, it does not affect overall system performance.
[0032] like Figure 2 As shown, the web page / mobile phone initiates an http request for login or transaction.
[0033] The gateway module has a configuration item inside that configures the correspondence between the hierarchical organization number and the database. The gateway module obtains the database name from the configuration item based on the hierarchical organization number of the currently logged-in user.
[0034] When the gateway module forwards the http request to the business module, it puts the database name in the http request header; The business module inherits the abstract routing data source of the spring framework and will initialize connections to multiple databases when it starts.
[0035] Once the business module receives the request, it obtains the database name from the http request header.
[0036] Mark the thread that currently receives / processes the http request.
[0037] Execute business logic, that is, no matter how many database table operations this thread performs in the business logic, it will select the corresponding database based on the database name.
[0038] If business module 2 needs to be called, the database name will be placed in the request header.
[0039] After receiving the http request, business module 2 obtains the database name from the http request header and selects the corresponding database based on the database name. The embodiment of the present application completes the transmission and closed loop of the database name based on different business modules and for different databases, thereby realizing the physical isolation of hierarchically organized business data.
[0040] For database replication, a log-based incremental synchronization algorithm is used. The basic process is as follows: 1. The master database records all write operations in the transaction log; 2. The slave database continuously monitors the master database's transaction log; 3. When a new log entry is detected, the slave database parses the log content and generates the corresponding SQL statement; 4. The SQL statement is executed, synchronizing the changes to the local database; 5. The synchronization status is recorded for subsequent latency calculation and fault recovery. The key to this algorithm lies in log parsing efficiency and conflict resolution mechanisms. To improve parsing efficiency, a binary log parser can be used to directly read the binary data in the log file rather than the text format, thereby reducing I / O overhead.
[0041] Figure 3 This is a schematic diagram of the data processing flow of the interceptor in the distributed system shown in the embodiment of the present application, such as Figure 3 As shown, the data processing flow of the interceptor in the distributed system shown in the embodiment of the present application includes: Initialize multiple database connections and form key-value pairs for multiple database connections. The key is the database name and the value is the database connection pool.
[0042] Based on the http request header of the previous gateway module, the database name is obtained and written into the current thread space storage. This step completes the thread identification.
[0043] When executing business logic to perform database operations, the database name is obtained from the thread identifier.
[0044] Get the actual database connection pool from the key-value pair by database name.
[0045] When calling other business modules, a new call interceptor is added to obtain the database name from the thread identifier.
[0046] The database name is sent to the http request header and passed to other business modules to implement database related processing.
[0047] Suppose a multi-tiered system has three sub-organizations: A, B, and C, corresponding to database instances SG001DB001, SG002DB002, and SG003DB003, respectively. The order management module in the information system must access all three databases simultaneously to process order data from each sub-organization. When a user accesses the order query interface, the front-end system inserts the target sub-organization's identifier (e.g., SG001DB001) into the HTTP request header and sends it to the back-end service. Upon receiving the request, the back-end service parses the identifier in the request header and stores it in a ThreadLocal variable in the current thread. The order management module then calls the database access layer, selects the appropriate database connection pool based on the thread identifier, and executes a SQL query to retrieve the order data for the corresponding sub-organization. This entire process requires no manual intervention; the system automatically matches data sources and executes operations. For data aggregation, the system creates a unified slave database, CentralDB, which serves as a replica of all master databases. The slave databases synchronize data changes in real time by monitoring the master database's transaction logs. For example, when sub-level organization A adds a new order record, the master database SG001DB001 writes the change record to the binlog, and the slave database CentralDB reads the log entry, generates the corresponding INSERT statement, and executes the insertion operation to ensure data consistency. In addition, the system also supports a variety of expansion methods. For example, a load balancing mechanism can be introduced to distribute requests to multiple slave database instances to improve query performance; or a distributed transaction management mechanism can be used to ensure the consistency of cross-database operations; and caching technologies such as Redis can be combined to cache high-frequency query data to further optimize response speed.
[0048] The embodiment of the present application constructs a secure, efficient, and scalable multi-level system-level data management system through unified data source identification management, intelligent thread tag matching, and an efficient database replication mechanism, effectively solving the technical difficulties of data isolation and centralized management of multi-sub-level organizations.
[0049] Figure 4 This is a schematic diagram of the structure of the business information processing device shown in the embodiment of the present application. Figure 4 As shown, the service information processing device of the embodiment of the present application includes: A creation module 40 is used to store the business data of each subsystem in an independent database, so that each module in the subsystem can connect to all databases at the same time to form a data source, and define a dynamic data source identifier; multiple databases storing the business data of each subsystem are used as the master database, and the newly created database is used as the slave database; The gateway module 41 receives an HTTP request from a client, obtains the database name corresponding to the access object according to the ID information of the access object in the HTTP request, places the database identifier into the HTTP request, and forwards the HTTP request to the business module; Business module 42 is used to generate a key-value pair locally with the database name as the key and the database connection pool as the value based on the abstract routing data source of the Spring framework; obtain the database identifier based on the HTTP request and store the database identifier in a thread-local variable of the current thread; obtain the database name from the thread-local variable and select the corresponding database connection pool based on the key-value pair; The interceptor module 43 is used to obtain the corresponding database identifier from the thread local variable when calling other business modules, and write the database name into a new HTTP request header to pass it to the other called business modules.
[0050] exist Figure 4 Based on the service information processing device shown, the service information processing device of the embodiment of the present application further includes: The first configuration unit ( Figure 4 (not shown) is used to set configuration items for the gateway module, in which the corresponding relationship between the subsystem and the database is configured; the configuration item uses the subsystem identification number as the index to establish a mapping relationship with the database name.
[0051] As an implementation manner, the creation module 40 is further configured to: Create an independent connection pool for each database and load the connection parameters of each database; initialize multiple database connections and form key-value pairs for multiple database connections, and store the database name and the corresponding connection pool in a key-value pair data structure in memory; where the database name is the key and the database connection pool is the key value; The gateway module 41 is further configured to obtain a database name from a thread identifier when executing business logic to perform database operations, and obtain a corresponding database connection pool from a key-value pair using the database name.
[0052] exist Figure 4 Based on the service information processing device shown, the service information processing device of the embodiment of the present application further includes: The second configuration unit ( Figure 4), which is not shown in the figure, is used to add a configuration table to each master library, configure a serial number prefix, and the configuration values of the configuration table in each master library are different; if the database table structure changes, a new table is added to each master library, and a new table is also added to the slave library synchronously; the parameters of the configuration file of the slave library are optimized, and the error code of the configuration file ignoring the characteristics is obtained, and the configuration file of the slave library and its parameters are adjusted based on the error code; and the creation module 40 is also used to create thread local variables through ThreadLocal technology and store the created thread local variables.
[0053] As an implementation method, the interceptor module 43 is further configured to: When calling other business modules, the current database ID is obtained from the thread local variable based on the thread ID; the database key value is found according to the database ID, and the corresponding database connection pool is found according to the key value; Executed before an HTTP request is sent, the database identifier in the thread-local variable is added to the request header and passed to other business modules.
[0054] In an exemplary embodiment, the above-mentioned processing units may be implemented by one or more central processing units (CPU), graphics processing units (GPU), baseband processors (BP), application-specific integrated circuits (ASIC), digital signal processors (DSP), programmable logic devices (PLD), complex programmable logic devices (CPLD), field-programmable gate arrays (FPGA), general-purpose processors, controllers, microcontrollers (MCU), microprocessors, or other electronic components.
[0055] In the embodiments of this application, Figure 4 The specific manner in which each unit in the illustrated business information processing device performs operations has been described in detail in the embodiment of the method and will not be elaborated on here.
[0056] Figure 58 is a block diagram of an electronic device according to an exemplary embodiment. The electronic device 800 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or claimed herein.
[0057] like Figure 5 As shown, electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. RAM 803 may also store various programs and data required for the operation of electronic device 800. Computing unit 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to bus 804.
[0058] Multiple components in the electronic device 800 are connected to the I / O interface 805, including an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a magnetic disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the electronic device 800 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0059] The computing unit 801 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as the business information processing method. For example, in some embodiments, the business information processing method may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed onto the electronic device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of the business information processing method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform the business information processing method through any other suitable means (e.g., via firmware).
[0060] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0061] The program code for implementing the methods of the present application can be written in any combination of one or more programming languages. Such program code can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the program code is executed by the processor or controller, the functions / operations specified in the flow charts and / or block diagrams are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0062] In the context of this application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or apparatus. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fibers, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0063] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0064] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0065] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact through a communication network. The client-server relationship arises through computer programs running on the respective computers and having a client-server relationship with each other. The server may be a cloud server, a server in a distributed system, or a server integrated with a blockchain.
[0066] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this application can be achieved. This is not a limitation herein.
[0067] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. Throughout the description of this application, "plurality" means two or more, unless otherwise specifically defined.
[0068] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A business information processing method, characterized in that: Store the business data of each subsystem in an independent database, so that each module in the subsystem can connect to all databases at the same time to form a data source, and define a dynamic data source identifier; The method includes: using multiple databases storing business data of each subsystem as master databases and creating a new database as a slave database; The gateway module receives the HTTP request from the client, obtains the database name corresponding to the access object based on the ID information of the access object in the HTTP request, puts the database identifier into the HTTP request, and forwards the HTTP request to the business module; Among them, the business module is based on the abstract routing data source of the Spring framework, forming a key-value pair locally with the database name as the key and the database connection pool as the value; The business module obtains the database identifier based on the HTTP request and stores it in the thread-local variable of the current thread; obtains the database name from the thread-local variable and selects the corresponding database connection pool based on the key-value pair; When calling other business modules, the corresponding database identifier is obtained from the thread local variable through the interceptor, and the database name is written into the new HTTP request header and passed to the other called business modules.
2. The method according to claim 1, characterized in that The method further comprises: Configuration items are set for the gateway module. The corresponding relationship between the subsystem and the database is configured in the configuration items. The configuration items use the subsystem identification number as the index to establish a mapping relationship with the database name.
3. The method according to claim 1, characterized in that The method further comprises: Create an independent connection pool for each database and load the connection parameters of each database; initialize multiple database connections and form key-value pairs for multiple database connections, and store the database name and the corresponding connection pool in a key-value pair data structure in memory; where the database name is the key and the database connection pool is the key value; When executing business logic to perform database operations, the database name is obtained from the thread identifier, and the corresponding database connection pool is obtained from the key-value pair through the database name.
4. The method according to claim 1, wherein The method further comprises: Add a new configuration table for each master database, configure a serial number prefix, and set different configuration values for each master database. If the database table structure changes, add a new table for each master database and synchronize it with the slave database. Optimize the parameters of the slave database configuration file, obtain the error code for the configuration file ignoring the characteristics, and adjust the slave database configuration file and its parameters based on the error code. Create thread local variables through ThreadLocal technology and store the created thread local variables.
5. The method according to claim 1, wherein The method further comprises: When calling other business modules, a new interceptor is added to trigger the interceptor to obtain the current database identifier from the thread local variable based on the thread identifier; the database key value is found according to the database identifier, and the corresponding database connection pool is found according to the key value; The interceptor is executed before the HTTP request is sent, adds the database identifier in the thread local variable to the request header, and passes it to other business modules.
6. A business information processing device, characterized in that: The device comprises: Create a module to store the business data of each subsystem in an independent database, so that each module in the subsystem can connect to all databases at the same time to form a data source, and define a dynamic data source identifier; use multiple databases storing the business data of each subsystem as the master database, and the newly created database as the slave database; The gateway module receives the HTTP request from the client, obtains the database name corresponding to the access object based on the ID information of the access object in the HTTP request, puts the database identifier into the HTTP request, and forwards the HTTP request to the business module; The business module is used for the abstract routing data source based on the Spring framework. It forms a key-value pair locally with the database name as the key and the database connection pool as the value. It obtains the database identifier based on the HTTP request and stores the database identifier in the thread-local variable of the current thread. It obtains the database name from the thread-local variable and selects the corresponding database connection pool based on the key-value pair. The interceptor module is used to obtain the corresponding database identifier from the thread local variable when calling other business modules, and write the database name into the new HTTP request header to pass it to other called business modules.
7. The device according to claim 6, characterized in that The creation module is also used to: Create an independent connection pool for each database and load the connection parameters of each database; initialize multiple database connections and form key-value pairs for multiple database connections, and store the database name and the corresponding connection pool in a key-value pair data structure in memory; where the database name is the key and the database connection pool is the key value; The gateway module is also used to obtain the database name from the thread identifier when executing business logic to perform database operations, and obtain the corresponding database connection pool from the key-value pair through the database name.
8. The device according to claim 6, characterized in that The device further comprises: The second configuration unit is used to add a new configuration table to each master database and configure a serial number prefix. The configuration values of the configuration table in each master database are different. If the database table structure changes, a new table is added to each master database, and a new table is added to the slave database in synchronization. The parameters of the slave database configuration file are optimized, and the error code of the configuration file ignoring the characteristics is obtained. The slave database configuration file and its parameters are adjusted based on the error code. The creation module is further used to create thread local variables through ThreadLocal technology and store the created thread local variables.
9. An electronic device, characterized in that: include: at least one processor; a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the steps of the business information processing method according to any one of claims 1 to 5.
10. A non-transitory computer-readable storage medium, characterized in that When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the steps of the business information processing method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Multi-tenant SaaS platform rapid building and dynamic expansion method and system
CN112100262A
Data isolation method and system based on tenants
CN115481435A
Multi-version dynamically extensible data source method and device, terminal and storage medium
CN120315681A
Database Virtualization
US20110202667A1