Routing method and device for service data access request

By using filters and data source routing algorithms in the remote procedure call framework, flexible routing of business data access requests is achieved, and the problem of changing business code in the existing technology is solved, which improves the flexibility of implementation methods. and development efficiency.

CN119520629APending Publication Date: 2025-02-25BEIJING JINGDONG YUANSHENG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411730763.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

In the prior art, dynamically switching the data source accessed by users requires changes to the business code of each business module, resulting in high code development costs, long cycles, and inflexible implementation methods.

Method used

By introducing filters into the remote procedure call framework for implicit argument transmission, and using the data source routing algorithm to flexibly route business data access requests, independent of the business code of the business module, thereby achieving isolation between business code and routing function.

Benefits of technology

Dynamic data source switching can be achieved without changing the business code of the business module, which improves the flexibility of the implementation method and reduces the cost and cycle of code development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119520629A_ABST
    Figure CN119520629A_ABST
Patent Text Reader

Abstract

The invention discloses a service data access request routing method and device, and relates to the technical field of computers. A specific embodiment of the method comprises the steps that a request message sent by a client is received, the request message comprises a service data access request and a tenant identifier, and the tenant identifier is acquired through a client filter of a remote procedure call framework; filtering the request message through a server filter of a remote procedure call framework to obtain a tenant identifier; and determining a data source corresponding to the tenant identifier according to a data source routing algorithm, and taking the data source as a routing data source of the service data access request. According to the embodiment, isolation of the service code and the routing function is realized, and the routing function of the service data access request does not need to be realized in each service module. And when the data source accessed by the user needs to be dynamically switched, only the function of the routing component is modified, so that the implementation mode is more flexible, the code development cost is reduced, and the code development period is shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for routing a service data access request. Background Art

[0002] Typically, an application product includes multiple business modules to implement different business functions, and multiple data sources are set up to support user business access. When a user requests to access data through a business module, multiple data sources are set up through the business code of the business module to determine which data source the user should access. If there is a need for dynamic data source switching, the business code of the business module also needs to be modified to adapt according to the needs.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art: when it is necessary to dynamically switch the data source accessed by the user, it is necessary to modify the business code of each business module to achieve this, the code changes are large, the implementation method is not flexible, and when the application product includes many business modules, the code development cost is high and the cycle is long. Summary of the invention

[0004] In view of this, an embodiment of the present invention provides a method and device for routing business data access requests, which can perform implicit parameter transmission based on the filter of the remote procedure call framework, and flexibly route business data access requests according to the data source routing algorithm. This process is completely unrelated to the business code of the business module, and realizes the extraction of the routing function of the business data access request from the business code of the business module, and exists as a separate routing component. Each business module can implement the routing function of the business data access request by calling the routing component, thereby realizing the isolation of the business code and the routing function, and there is no need to implement the routing function of the business data access request separately in each business module. When it is necessary to dynamically switch the data source accessed by the user, it is not necessary to implement it by modifying the business code of each business module, but only to modify the function implementation of the routing component. The implementation method is more flexible, reduces the code development cost, and shortens the code development cycle.

[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for routing a service data access request is provided, comprising: Receive a request message sent by a client, wherein the request message includes a business data access request and a tenant identifier, and the tenant identifier is obtained through a client filter of a remote procedure call framework; Filtering the request message through a server-side filter of a remote procedure call framework to obtain the tenant identifier; The data source corresponding to the tenant identifier is determined according to a data source routing algorithm, and the data source is used as a routing data source for the business data access request.

[0006] Optionally, the tenant identifier is added to a temporary status recorder and sent as an implicit parameter; the request message is filtered through a server-side filter of a remote procedure call framework to obtain the tenant identifier, including: filtering the request message through a server-side filter of a remote procedure call framework to obtain a temporary status recorder, and obtaining the tenant identifier from the temporary status recorder.

[0007] Optionally, after filtering the request message through a server-side filter of a remote procedure call framework and obtaining the tenant identifier, the method further includes: storing the tenant identifier in a thread local storage for tenant isolation.

[0008] Optionally, determining the data source corresponding to the tenant identifier according to a data source routing algorithm includes: according to the data source routing algorithm, concatenating database connection information corresponding to the tenant based on the tenant identifier and generating a data source object, and determining the data source corresponding to the tenant identifier according to the data source object.

[0009] Optionally, after using the data source as the routing data source for the business data access request, it also includes: sending the data source to a database access middleware, so as to find the data source from a set of available data sources of the business system through the database access middleware, and establishing a database connection with the data source according to the database connection information corresponding to the tenant, so as to access the data source according to the business data access request.

[0010] According to another aspect of an embodiment of the present invention, a routing device for a service data access request is provided, comprising: A request message receiving module, used to receive a request message sent by a client, wherein the request message includes a business data access request and a tenant identifier, and the tenant identifier is obtained through a client filter of a remote procedure call framework; A tenant identification acquisition module, used to filter the request message through a server filter of a remote procedure call framework to obtain the tenant identification; The access request routing module is used to determine the data source corresponding to the tenant identifier according to the data source routing algorithm, and use the data source as the routing data source for the business data access request.

[0011] Optionally, the tenant identifier is added to the temporary status recorder and sent as an implicit parameter; the tenant identifier acquisition module is also used to: filter the request message through the server-side filter of the remote procedure call framework to obtain the temporary status recorder, and obtain the tenant identifier from the temporary status recorder.

[0012] Optionally, the access request routing module is further used to: according to the data source routing algorithm, splice the database connection information corresponding to the tenant based on the tenant identifier, and generate a data source object, and determine the data source corresponding to the tenant identifier according to the data source object.

[0013] According to another aspect of an embodiment of the present invention, there is provided an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the routing method for business data access requests provided by an embodiment of the present invention.

[0014] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method for routing a service data access request provided by an embodiment of the present invention is implemented.

[0015] An embodiment of the above invention has the following advantages or beneficial effects: by receiving a request message sent by a client, the request message includes a business data access request and a tenant identifier, and the tenant identifier is obtained through a client filter of a remote procedure call framework; filtering the request message through a server filter of the remote procedure call framework to obtain the tenant identifier; determining the data source corresponding to the tenant identifier according to a data source routing algorithm, and using the data source as a technical solution for routing data sources for business data access requests, implicit parameter transmission can be performed based on the filter of the remote procedure call framework, and business data access requests can be flexibly routed according to the data source routing algorithm, and this process is completely unrelated to the business code of the business module, and the routing function of the business data access request is extracted from the business code of the business module, and exists as a separate routing component, and each business module can implement the routing function of the business data access request by calling the routing component, thereby implementing the isolation of the business code and the routing function, and there is no need to implement the routing function of the business data access request separately in each business module. When it is necessary to dynamically switch the data source accessed by the user, it is not necessary to implement it by modifying the business code of each business module, and only the function of the routing component needs to be modified, and the implementation method is more flexible, reducing the code development cost and shortening the code development cycle.

[0016] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention. Figure 1 It is a schematic diagram of a routing system for implementing a service data access request according to an embodiment of the present invention; Figure 2 is a schematic diagram of main steps of a method for routing a service data access request according to an embodiment of the present invention; Figure 3 is a schematic diagram of a routing process of a service data access request according to an embodiment of the present invention; Figure 4 is a schematic diagram of main modules of a routing device for service data access requests according to an embodiment of the present invention; Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied; Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0018] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0019] It should be noted that the collection, collection, updating, analysis, processing, use, transmission, storage and other aspects of user personal information involved in the technical solution disclosed in the present invention are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information, network security and national security.

[0020] In order to solve the technical problems existing in the prior art, the present invention provides a routing method for business data access requests, which can extract the routing function of business data access requests from the business code of the business module and exist as a separate routing component. Each business module can implement the routing function of business data access requests by calling the routing component, thereby realizing the isolation of business code and routing function, and there is no need to implement the routing function of business data access requests separately in each business module. When it is necessary to dynamically switch the data source accessed by the user, it is not necessary to implement it by modifying the business code of each business module, but only to modify the function implementation of the routing component. The implementation method is more flexible, reduces the code development cost, and shortens the code development cycle.

[0021] In the introduction of the embodiments of the present invention, the professional terms and their definitions are as follows: Java: a high-level programming language; RPC: Remote Procedure Call framework; RPC Filter: An automatic filtering technology built into the RPC framework. After configuration, each RPC request will automatically trigger the filter. RPC filters are divided into consumer and provider sides. The consumer side is triggered when a request is made, and the provider side is triggered when a request is received. RPC consumer: RPC request client; RPC provider: RPC request server; Spring: a Java-based development framework. ThreadLocal: In Java language, a data structure whose life cycle is based on the thread level; Mybatis: a database access middleware based on Java language; Dao layer: data source access layer, the present invention is Mybatis layer; Tenants refer to organizations or individuals who use cloud services on cloud computing platforms. They can rent cloud resources to meet their needs. Tenants can be enterprises, organizations, development teams or individual users. Tenants can choose different cloud services according to their needs, such as computing resources, storage space, network bandwidth, etc., and pay according to actual usage. Tenants can manage and configure their own cloud resources through the cloud service provider's management console or API; A user is an individual or system that uses cloud services provided by tenants on a cloud computing platform. Users can be employees, developers, administrators within the tenant or external partners, customers, etc. Users access and use cloud services through the permissions and interfaces provided by the tenant. Users can perform specific operations based on their roles and permissions, such as creating, managing, and monitoring cloud resources, uploading and downloading data, etc.

[0022] Figure 1 FIG. 1 is a schematic diagram of a routing system for implementing a service data access request according to an embodiment of the present invention. Figure 1 As shown, when a tenant sends a business data access request to each business module, the routing of the business data access request will be implemented through the routing component called in the business module to route the business data access requests of different tenants to different databases.

[0023] In one embodiment of the present invention, in order to implement the routing component, based on the implicit parameter transmission of the remote procedure call framework RPC (Remote Procedure Call), RPC filters, the data source dynamic routing class extension interface of the application development framework and the database access middleware, the dynamic data source management of the SaaS (Software as a Service) system and the intelligent routing of business data access requests to the corresponding data source according to the tenant id (tenant unique identifier) ​​can be realized.

[0024] The present invention implements two RPC filters based on the RPC framework to automatically transmit the tenant id from the RPC client to the RPC server. The RPC client automatically puts the tenant id corresponding to the current logged-in user into the RpcContext (RpcContext is essentially a temporary state recorder implemented using ThreadLocal) through the Filter, and automatically transmits it to the RPC server through the RPC request. The RPC server takes the tenant id transmitted from the RpcContext through the filter of the server and puts it into the ThreadLocal. This process does not require any operation on the business side. At the same time, by inheriting the AbstractRoutingDataSource class (data source extension class) in the public development framework Spring of the application system, the data source accessed by the current thread of Spring is specified. The above whole process is automatically implemented by the routing component, which realizes the dynamic data source management of the SaaS system and the intelligent routing of the business data access request according to the tenant id, without the need to implement it separately inside each business module, thereby greatly improving the team development efficiency and reducing the failure rate of data routing implemented inside the business.

[0025] Figure 2FIG. 1 is a schematic diagram of the main steps of a method for routing a service data access request according to an embodiment of the present invention. Figure 2 As shown, the method for routing service data access requests in the embodiment of the present invention mainly includes the following steps S201 to S203.

[0026] Step S201: Receive a request message from the client, the request message includes a business data access request and a tenant identifier, and the tenant identifier is obtained through the client filter of the remote procedure call framework. According to the technical solution of an embodiment of the present invention, when a user logs in to the application from the client (for example, the Web end), when interacting with the business module, a business data access request will be initiated to the server. At this time, the routing component of the present invention will be triggered, and the tenant identifier corresponding to the user will be obtained through the client filter Consumer RPC Filter of the remote procedure call framework, and the tenant identifier will be sent to the server together with the business data access request.

[0027] Specifically, according to an embodiment of the present invention, the tenant identifier is added to the temporary state recorder and sent in an implicit parameter transmission manner. Implicit parameter transmission means that the specified data is passed from the RPC client to the RPC server without the need for business definition to specify parameters. For example, the business module has an interface for querying master data, and the parameter is the master data name. At this time, if the business module is allowed to pass the tenant id, then all business interfaces need to add the tenant id parameter. By implicitly passing parameters through RPC, the parameters of the business interface do not change. The RPC client automatically puts the additional parameters into the RpcContext (temporary state recorder) and transmits it to the server, and the business code is unaware. The RPC filter is an automatic interception function provided by the RPC framework. The business code only needs to implement a specified interface according to the specifications of the RPC framework, and it can automatically trigger an additional logic when the RPC request is called, and the tenant identifier is sent to the RPC server through this additional logic.

[0028] Step S202: Filter the request message through the server filter of the remote procedure call framework to obtain the tenant identifier. According to the technical solution of the present invention, the request message sent by the client at this time includes the business data access request and the tenant identifier obtained by the RPC client. The routing component of the present invention needs to obtain the tenant identifier from the message data to route the business data access request.

[0029] According to one embodiment of the present invention, filtering the request message through the server-side filter of the remote procedure call framework to obtain the tenant identifier may specifically include: filtering the request message through the server-side filter of the remote procedure call framework to obtain a temporary status recorder, and obtaining the tenant identifier from the temporary status recorder. Specifically, when the message data from the client is sent, the routing component will be triggered immediately, and the request message will be intercepted and filtered through the server-side filter Provider RPC Filter of the remote procedure call framework to obtain the temporary status recorder RpcContext, and the tenant identifier corresponding to the user will be obtained from RpcContext for subsequent routing of the user's business data access request.

[0030] According to another embodiment of the present invention, after filtering the request message through the server filter of the remote procedure call framework and obtaining the tenant identifier, it can also include: storing the tenant identifier in the thread local storage for tenant isolation. Among them, the thread local storage refers to ThreadLocal, which is used to store thread-based variables. For example, if two different users access a system at the same time, it can be considered that there are two threads executing in parallel in the system at that time. If the logic of each thread is relatively complex and you want to read the current thread-specific information, you can put this thread-specific information in ThreadLocal, and the subsequent logic can be read out through ThreadLocal. ThreadLocal is based on threads, and different threads are isolated from each other and do not affect each other. Therefore, tenant isolation can be performed by storing the tenant identifier in the thread local storage, thereby facilitating the acquisition of tenant-related information and reducing the probability of routing errors.

[0031] Step S203: Determine the data source corresponding to the tenant identifier according to the data source routing algorithm, and use the data source as the routing data source for the business data access request.

[0032] According to an embodiment of the present invention, determining the data source corresponding to the tenant identifier according to the data source routing algorithm may specifically include: according to the data source routing algorithm, splicing the database connection information corresponding to the tenant based on the tenant identifier, and generating a data source object, and determining the data source corresponding to the tenant identifier according to the data source object. In one embodiment, the data source routing algorithm is obtained by, for example, extending the data source class based on the application system development framework. Taking the system development framework Spring as an example, Spring provides a data source extension class AbstractRoutingDataSource. By inheriting and extending this class, a dynamic data source can be specified. In the present invention, a dynamic data source class DynamicDataSource is defined, which inherits from the data source extension class AbstractRoutingDataSource. The defined dynamic data source class is used to implement the dynamic data source switching function. The determineCurrentLookupKey method is implemented in the dynamic data source class. This method is an abstract method of the data source extension class AbstractToutingDataSource, which needs to be implemented by a subclass of the data source extension class AbstractToutingDataSource. This method is used to inform Spring which data source corresponds to the current request. Then, the present invention defines an intelligent routing class DynamicDataSourceSmartSwitch (that is, the specific implementation of the data source routing algorithm of the present invention). This is a custom Java class, which is used to spell out the database connection information corresponding to the tenant according to the tenant id, and generate a data source object. Through the dynamic data source class DynamicDataSource, Spring is notified which data source corresponds to the current request, thereby achieving the purpose of automatically routing business data access requests to the data source. It has the ability to dynamically manage the data source according to the tenant id and encapsulates the data source intelligent routing method.

[0033] According to an embodiment of the present invention, when a business data access request is sent to a server (located in the Service layer together with the RPC server), the filter of the RPC server is automatically triggered before the server receives the business data access request, and the tenant id is automatically obtained through the filter. Then, the intelligent routing class DynamicDataSourceSmartSwitch is called to generate a dynamic data source DynamicDataSource according to the tenant id, and realize intelligent routing of business data access requests.

[0034] According to an embodiment of the present invention, after the data source is used as the routing data source of the business data access request, it can also include: sending the data source to the database access middleware, so as to find the data source from the available data source set of the business system through the database access middleware, and establish a database connection with the data source according to the database connection information corresponding to the tenant, so as to access the data source according to the business data access request. In an embodiment of the present invention, the database access middleware is, for example, Mybatis. Mybatis accesses the database through the Mapper method. Mybatis will automatically obtain the dynamic data source managed by Spring according to the SpringManagedTransaction class, and then call the dynamic data source to obtain the data source corresponding to the current tenant identifier, obtain the database connection information according to the data source, and establish a database connection with the data source according to the database connection information, so that the database can be accessed. Mybatis can hand over the data source management to Spring. When accessing the database, it will obtain the data source managed by Spring, and generate a connection to the database through the data source specified by Spring. In this case, Spring is like a general manager, and Mybatis is a worker who specifically performs duties. So how does Mybatis use the data source specified by Spring? It is realized by the SpringManagedTransaction class provided by Mybatis that is specifically connected to the Spring framework. This class supports Spring to dynamically set the data source.

[0035] Figure 3 FIG. 1 is a schematic diagram of a routing process of a service data access request according to an embodiment of the present invention. Figure 3 As shown, in one embodiment of the present invention, the business data access process mainly involves the implementation of the web layer, service layer and dao layer. After the user logs in at the web layer, a business data access request is initiated to request access functions. At this time, the client filter Consumer RPC Filter of the remote procedure call framework will obtain the tenant id corresponding to the user login, and save the tenant id to the temporary state recorder RpcContext, and then send the tenant id and the business data access request to the service layer through implicit parameter transmission.

[0036] The service layer is used to provide business services. At the same time, the server-side filter Provider RPC Filter of the remote procedure call framework of the service layer obtains the tenant id by parsing the filtered temporary state recorder RpcContext, and saves the tenant id to the thread local storage ThreadLocal. Then, according to the tenant id, the data source routing algorithm DynamicDataSourceSmartSwitch class performs data source intelligent routing to obtain the dynamic data source DynamicDataSource corresponding to the tenant id or the business data access request.

[0037] The dao layer is used to access the data source. In an embodiment of the present invention, the database access middleware is, for example, Mybatis, which accesses the database through the Mapper method. Mybatis automatically obtains the dynamic data source managed by Spring according to the SpringManagedTransaction class, and then calls the dynamic data source to obtain the data source corresponding to the current tenant id, obtains the database connection information according to the data source, and establishes a database connection with the data source according to the database connection information, thereby accessing the database. As shown in the figure, tenant 1, tenant 2, and tenant 3 correspond to different databases respectively.

[0038] Figure 4 FIG. 1 is a schematic diagram of the main modules of a routing device for service data access requests according to an embodiment of the present invention. Figure 4 As shown, the service data access request routing device 400 according to the embodiment of the present invention mainly includes a request message receiving module 401 , a tenant identification obtaining module 402 and an access request routing module 403 .

[0039] The request message receiving module 401 is used to receive a request message sent by a client, wherein the request message includes a business data access request and a tenant identifier, and the tenant identifier is obtained through a client filter of a remote procedure call framework; A tenant identification acquisition module 402 is used to filter the request message through a server filter of a remote procedure call framework to acquire the tenant identification; The access request routing module 403 is used to determine the data source corresponding to the tenant identifier according to the data source routing algorithm, and use the data source as the routing data source for the business data access request.

[0040] According to one embodiment of the present invention, the tenant identifier is added to the temporary status recorder and sent as an implicit parameter; the tenant identifier acquisition module 402 can also be used to: filter the request message through the server-side filter of the remote procedure call framework to obtain the temporary status recorder, and obtain the tenant identifier from the temporary status recorder.

[0041] According to another embodiment of the present invention, the tenant identification acquisition module 402 can also be used to: filter the request message through the server-side filter of the remote procedure call framework, and after obtaining the tenant identification, store the tenant identification in the thread local storage for tenant isolation.

[0042] According to another embodiment of the present invention, the access request routing module 403 can also be used to: according to the data source routing algorithm, splice the database connection information corresponding to the tenant based on the tenant identifier, and generate a data source object, and determine the data source corresponding to the tenant identifier according to the data source object.

[0043] According to another embodiment of the present invention, the routing device 400 for business data access requests also includes a data source sending module (not shown in the figure), which is used to: after using the data source as the routing data source for the business data access request, send the data source to the database access middleware, so as to find the data source from the available data source set of the business system through the database access middleware, establish a database connection with the data source according to the database connection information corresponding to the tenant, and access the data source according to the business data access request.

[0044] According to the technical solution of the embodiment of the present invention, by receiving the request message sent by the client, the request message includes a business data access request and a tenant identifier, and the tenant identifier is obtained through the client filter of the remote procedure call framework; filtering the request message through the server filter of the remote procedure call framework to obtain the tenant identifier; determining the data source corresponding to the tenant identifier according to the data source routing algorithm, and using the data source as the routing data source of the business data access request, the technical solution can be based on the filter of the remote procedure call framework for implicit parameter transmission, and the business data access request can be flexibly routed according to the data source routing algorithm. This process is completely unrelated to the business code of the business module, and the routing function of the business data access request is extracted from the business code of the business module, and exists as a separate routing component. Each business module can implement the routing function of the business data access request by calling the routing component, thereby realizing the isolation of the business code and the routing function, and there is no need to implement the routing function of the business data access request separately in each business module. When it is necessary to dynamically switch the data source accessed by the user, it is not necessary to implement it by modifying the business code of each business module, and only the function of the routing component needs to be modified. The implementation method is more flexible, reducing the code development cost and shortening the code development cycle.

[0045] Figure 5 An exemplary system architecture 500 is shown to which a method for routing a service data access request or an apparatus for routing a service data access request according to an embodiment of the present invention can be applied.

[0046] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0047] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).

[0048] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0049] Server 505 may be a server that provides various services, such as a background management server that provides support for websites browsed by users using terminal devices 501, 502, and 503 (for example only). The background management server may receive a request message sent by a client for data such as a routing request for a received business data access request, wherein the request message includes a business data access request and a tenant identifier, and the tenant identifier is obtained through a client filter of a remote procedure call framework; filter the request message through a server filter of a remote procedure call framework to obtain the tenant identifier; determine the data source corresponding to the tenant identifier according to a data source routing algorithm, and process the data source as a routing data source for the business data access request, and feed back the processing result (for example, a routing data source result - for example only) to the terminal device.

[0050] It should be noted that the method for routing the service data access request provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the routing device for the service data access request is generally disposed in the server 505 .

[0051] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0052] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 6 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0053] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0054] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.

[0055] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.

[0056] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

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

[0058] The units or modules involved in the embodiments of the present invention may be implemented in software or in hardware. The units or modules described may also be provided in a processor. For example, they may be described as follows: a processor includes a request message receiving module, a tenant identification acquisition module, and an access request routing module. Among them, the names of these units or modules do not constitute limitations on the units or modules themselves in certain circumstances. For example, the request message receiving module may also be described as "a module for sending a tenant identification to the server in response to a client sending a business data access request to the server through a client filter of a remote procedure call framework".

[0059] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: receiving a request message sent by a client, the request message includes a business data access request and a tenant identifier, and the tenant identifier is obtained through a client filter of a remote procedure call framework; filtering the request message through a server filter of a remote procedure call framework to obtain the tenant identifier; determining the data source corresponding to the tenant identifier according to a data source routing algorithm, and using the data source as a routing data source for the business data access request.

[0060] According to the technical solution of the embodiment of the present invention, by receiving the request message sent by the client, the request message includes a business data access request and a tenant identifier, and the tenant identifier is obtained through the client filter of the remote procedure call framework; filtering the request message through the server filter of the remote procedure call framework to obtain the tenant identifier; determining the data source corresponding to the tenant identifier according to the data source routing algorithm, and using the data source as the routing data source of the business data access request, the technical solution can be based on the filter of the remote procedure call framework for implicit parameter transmission, and the business data access request can be flexibly routed according to the data source routing algorithm. This process is completely unrelated to the business code of the business module, and the routing function of the business data access request is extracted from the business code of the business module, and exists as a separate routing component. Each business module can implement the routing function of the business data access request by calling the routing component, thereby realizing the isolation of the business code and the routing function, and there is no need to implement the routing function of the business data access request separately in each business module. When it is necessary to dynamically switch the data source accessed by the user, it is not necessary to implement it by modifying the business code of each business module, and only the function of the routing component needs to be modified. The implementation method is more flexible, reducing the code development cost and shortening the code development cycle.

[0061] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for routing a business data access request, characterized in that: include: Receive a request message sent by a client, wherein the request message includes a business data access request and a tenant identifier, and the tenant identifier is obtained through a client filter of a remote procedure call framework; Filtering the request message through a server-side filter of a remote procedure call framework to obtain the tenant identifier; The data source corresponding to the tenant identifier is determined according to a data source routing algorithm, and the data source is used as a routing data source for the business data access request.

2. The method according to claim 1, characterized in that The tenant identifier is added to the temporary state recorder and sent as an implicit parameter. Filtering the request message through a server-side filter of a remote procedure call framework to obtain the tenant identifier includes: The request message is filtered through a server-side filter of a remote procedure call framework to obtain a temporary status recorder, and the tenant identifier is obtained from the temporary status recorder.

3. The method according to claim 1, characterized in that After filtering the request message through the server filter of the remote procedure call framework and obtaining the tenant identifier, the method further includes: The tenant identification is stored in thread local storage for tenant isolation.

4. The method according to claim 1, characterized in that: Determining the data source corresponding to the tenant identifier according to the data source routing algorithm includes: According to the data source routing algorithm, database connection information corresponding to the tenant is spliced ​​based on the tenant identifier, and a data source object is generated, and the data source corresponding to the tenant identifier is determined according to the data source object.

5. The method according to claim 4, characterized in that After the data source is used as a routing data source for the business data access request, the method further includes: The data source is sent to the database access middleware so that the database access middleware can be used to find the data source from the available data source set of the business system, and a database connection with the data source is established according to the database connection information corresponding to the tenant, so as to access the data source according to the business data access request.

6. A routing device for service data access request, characterized in that: include: A request message receiving module, used to receive a request message sent by a client, wherein the request message includes a business data access request and a tenant identifier, and the tenant identifier is obtained through a client filter of a remote procedure call framework; A tenant identification acquisition module, used to filter the request message through a server filter of a remote procedure call framework to obtain the tenant identification; The access request routing module is used to determine the data source corresponding to the tenant identifier according to the data source routing algorithm, and use the data source as the routing data source for the business data access request.

7. The device according to claim 6, characterized in that The tenant identifier is added to the temporary state recorder and sent as an implicit parameter. The tenant identification acquisition module is also used for: The request message is filtered through a server-side filter of a remote procedure call framework to obtain a temporary status recorder, and the tenant identifier is obtained from the temporary status recorder.

8. The device according to claim 6, characterized in that The access request routing module is also used for: According to the data source routing algorithm, database connection information corresponding to the tenant is spliced ​​based on the tenant identifier, and a data source object is generated, and the data source corresponding to the tenant identifier is determined according to the data source object.

9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.