CN-122019012-A - Loading method, device, equipment and medium for dynamically loading data source
Abstract
The disclosure relates to the technical field of data processing, and provides a loading method, a device, equipment and a medium for dynamically loading a data source. The method comprises the steps of responding to service application starting, starting DFlow a loading device, triggering SpringBoot a framework to load DFlow an automatic configuration class, initializing a core component comprising an initializer, a configuration provider, a connection application processor and a data source agent, integrating DFlow the loading device with the service application, responding to a call request of a service method, controlling a non-invasive logic interception section to intercept the call request, controlling the non-invasive logic interception section to release the call request to a transparent data source object according to a preset release rule, controlling the transparent data source object to acquire a data source instance, and executing the service method according to the data source instance. The method and the system ensure service non-perception switching and system stability, and remarkably improve scheduling flexibility and operation and maintenance efficiency under a multi-data source architecture.
Inventors
- JIN MACHAO
Assignees
- 中化数智科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260209
Claims (10)
- 1. A loading method for dynamically loading a data source, the method comprising: in response to the service application launch, enabling DFlow the loading device, triggering SpringBoot the framework to load DFlow the auto-configuration class, controlling DFlow the auto-configuration class to initialize a core component comprising an initializer, a configuration provider, a connection application processor, and a data source agent; Carrying out DFlow integration of the loading device and the service application according to the initializer, the configuration provider, the connection application processor and the data source agent; Responding to a call request of a received service method, controlling DFlow a non-invasive logic interception section of a loading device to intercept the call request; Controlling DFlow a non-invasive logic interception section release call request of the loading device to a transparent data source object of the DFlow loading device according to a preset release rule; Controlling DFlow a transparent data source object of the loading device to acquire a data source instance; according to a data source example, a business method is performed.
- 2. The method for dynamically loading data sources according to claim 1, wherein the integrating DFlow the loading device with the service application according to the initializer, the configuration provider, the connection application processor, and the data source agent comprises: The control initializer calls a configuration provider to receive a data source configuration list returned by the server and analyzes the data source configuration list to obtain effective configuration; The control initializer is connected with the connection application processor, sends a connection application request to the server according to the effective configuration, receives a successful connection result returned by the server and synchronizes to the initializer; The control initializer calls the data source agent, creates a data source instance and constructs an internal association object, and registers the data source instance as a data source node in the Spring container to complete DFlow integration of the loading device and the service application.
- 3. The method according to claim 1, wherein the controlling DFlow the transparent data source object of the non-invasive logic intercepting section release call request of the loading device to DFlow loading device according to the preset release rule comprises: controlling DFlow the non-invasive logic interception cut surface of the loading device to check whether DFlow notes and corresponding notes resolvers exist; if the transparent data source object does not exist, the non-invasive logic is controlled to intercept the section plane and directly release the call request to the DFlow loading device.
- 4. A method of loading a dynamic load data source as recited in claim 3 wherein after controlling DFlow a non-invasive logical intercept facet of the loading device to check if DFlow annotations and corresponding annotation parsers are present, the method further comprises: if so, the control annotation parser parses the target data source name, Controlling a non-invasive logic interception section to inquire whether a data source node corresponding to a registered target data source in a Spring container; if not, controlling the non-invasive logic interception section to directly release the call request to the transparent data source object of DFlow loading device.
- 5. The method for dynamically loading data sources according to claim 4, wherein after controlling the non-invasive logical interception cut plane to query whether the data source node corresponding to the target data source is registered in the Spring container, the method further comprises: if the data source node is registered, the node name of the data source node corresponding to the target data source is written into a local storage object, and the non-invasive logic interception section release call request is controlled to be sent to the transparent data source object of the DFlow loading device.
- 6. The method according to claim 5, wherein if there is no DFlow annotation and corresponding annotation parser or if there is DFlow annotation and corresponding annotation parser, but the data source node corresponding to the target data source in the Spring container is unregistered, the data source instance corresponds to the default data source, and if there is DFlow annotation and corresponding annotation parser, and the data source node corresponding to the target data source in the Spring container is registered, the data source instance corresponds to the target data source.
- 7. The loading method for dynamically loading data sources according to claim 5, after executing the business method according to the data source example, the method further comprising: and controlling the non-invasive logic interception section to clear the node names in the local storage object.
- 8. A loading apparatus for dynamically loading a data source, the apparatus comprising: An initialization unit configured to, in response to a service application launch, enable DFlow the loading device, trigger SpringBoot the framework to load DFlow the auto-configuration class, control DFlow the auto-configuration class to initialize core components including an initializer, a configuration provider, a connection application processor, and a data source agent; the integrated unit is configured to integrate DFlow the loading device and the business application according to the initializer, the configuration provider, the connection application processor and the data source agent; The interception unit is configured to control DFlow a non-invasive logic interception section of the loading device to intercept the call request in response to receiving the call request of the service method; The release unit is configured to control DFlow the non-invasive logic of the loading device to intercept the section release call request to DFlow the transparent data source object of the loading device according to a preset release rule; an acquisition unit configured to control DFlow the transparent data source object of the loading device to acquire a data source instance; And the execution unit is configured to execute the business method according to the data source example.
- 9. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1-7 when the computer program is executed.
- 10. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the method according to any of claims 1-7.
Description
Loading method, device, equipment and medium for dynamically loading data source Technical Field The present disclosure relates to the field of data loading technologies, and in particular, to a loading method, apparatus, device, and medium for dynamically loading a data source. Background With the expansion of enterprise business scale and the increase of system complexity, the coexistence of multiple data sources has become a mainstream architecture. On one hand, different service modules independently deploy databases (such as an order data source, a member data source and a commodity data source of an e-commerce platform) to realize service decoupling, and on the other hand, in order to ensure high availability, a core service adopts a master-slave data source and disaster recovery data source architecture to avoid single-point faults. Although the multi-data source architecture solves the problems of single-library performance bottleneck and usability, new challenges are brought, and how to realize efficient dynamic switching among multiple data sources according to load fluctuation, fault states and service requirements becomes a key for guaranteeing system stability. For example, the order reading flow is increased rapidly in a period of time, part of requests need to be switched from one data source to another data source, when the main data source is down, the writing flow needs to be switched to the standby main data source in seconds, and when a batch processing task is executed at night, the analysis flow needs to be switched to the off-line data source, so that the influence on-line business is avoided. In the existing solutions relying on the client routing framework, for example Sharding-JDBC needs to explicitly define the connection target object of each calling method or class in the code, which limits the ability of dynamic switching, resulting in that the application cannot be scheduled in the horizontal direction. Disclosure of Invention In view of this, the embodiments of the present disclosure provide a loading method, apparatus, device, and medium for dynamically loading a data source, so as to solve the problem in the prior art that a connection target object of each calling method or class needs to be defined in a code, which limits the capability of dynamic switching, and results in that an application cannot be scheduled in a horizontal direction. According to a first aspect of the disclosed embodiments, a loading method for dynamically loading a data source is provided, the method includes starting DFlow a loading device in response to service application starting, triggering SpringBoot a framework to load DFlow an automatic configuration class, controlling DFlow the automatic configuration class to initialize a core component comprising an initializer, a configuration provider, a connection application processor and a data source agent, integrating DFlow the loading device and the service application according to the initializer, the configuration provider, the connection application processor and the data source agent, controlling DFlow non-invasive logic interception section interception call request of the loading device in response to receiving call request of the service method, controlling DFlow non-invasive logic interception release call request of the loading device to a transparent data source object of the DFlow loading device according to preset release rules, controlling DFlow the transparent data source object of the loading device to obtain a data source instance, and executing the service method according to the data source instance. In a second aspect of the disclosed embodiments, a loading device for dynamically loading a data source is provided, the device including an initializing unit configured to enable DFlow the loading device in response to a service application launch, trigger SpringBoot a framework to load DFlow an auto-configuration class, control DFlow the auto-configuration class to initialize a core component including an initializer, a configuration provider, a connection application processor, and a data source agent, an integrating unit configured to integrate DFlow the loading device with the service application according to the initializer, the configuration provider, the connection application processor, and the data source agent, an intercepting unit configured to control DFlow a non-invasive logical interception plane of the loading device to intercept the call request in response to receiving the call request of the service method, a releasing unit configured to control DFlow the non-invasive logical interception plane of the loading device to release the call request to DFlow a transparent data source object of the loading device according to a preset release rule, an acquiring unit configured to control DFlow the transparent data source object of the loading device to acquire the data source instance, and an executing unit configured to