Micro-service Information Processing Method and Device

CN115988051BActive Publication Date: 2025-08-01CHINA CONSTRUCTION BANK +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211547489.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-05
Publication Date
2025-08-01
Estimated Expiration
2042-12-05

AI Technical Summary

Technical Problem

[0004]目前分布式架构的服务上线过程中,可能在服务还未完成预热工作前就将服务过早暴露至注册中心,导致发往该服务的请求执行异常,造成集群链路波动

Benefits of technology

[0014] In an embodiment of the present invention, according to pre-configured service configuration information, a first original startup instruction and a second original startup instruction are intercepted; wherein, the service configuration information includes the instruction identifiers of the instructions to be intercepted, the first original startup instruction is used to start a service registration client, and the second original startup instruction is used to start a service warm-up executor; according to the service configuration information, when the Spring Cloud microservice component subscribes to the service warm-up completion notification, a first startup instruction is sent to the service registration client, so that after the service registration client starts according to the first startup instruction, it sends a registration request to the service registration center to complete the service online; wherein, the service warm-up completion notification is published by the Spring container after the service warm-up is completed. In this way, after the Spring container completes the service warm-up, the service will be exposed to the service registration center, avoiding the cluster link fluctuation caused by the service going online.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115988051B_ABST
    Figure CN115988051B_ABST
Patent Text Reader

Abstract

The present invention discloses a microservice information processing method and apparatus, relating to the field of distributed technologies. The method includes: intercepting a first original startup instruction and a second original startup instruction according to pre-configured service configuration information; wherein, the service configuration information contains instruction identifiers of instructions to be intercepted, the first original startup instruction is used to start a service registration client, and the second original startup instruction is used to start a service warm-up executor; according to the service configuration information, when a Spring Cloud microservice component subscribes to a service warm-up completion notification, sending a first startup instruction to the service registration client, so that after the service registration client starts according to the first startup instruction, sending a registration request to a service registration center to complete service online; wherein, the service warm-up completion notification is published by the Spring container after the service warm-up is completed. The present invention can avoid cluster link fluctuations caused by service online.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of distributed technologies, and in particular to a microservice information processing method and apparatus. Background Art

[0002] This section aims to provide background or context for the embodiments of the present invention described in the claims. The description herein is not admitted to be prior art merely by virtue of its inclusion in this section.

[0003] In a microservice architecture system, after a single service is started, it needs to immediately initiate a registration connection to the registration center and expose business APIs (Application Programming Interfaces) externally through a regular heartbeat mechanism. Other services obtain the API addresses corresponding to the services through the registration center, and achieve coordination and cooperation between services through this API addressing method to provide ultimate value for users.

[0004] Currently, during the service online process of a distributed architecture, the service may be prematurely exposed to the registration center before the service has completed the warm-up work, resulting in abnormal execution of requests sent to the service and causing fluctuations in the cluster link. Existing service online solutions can only shorten the duration of cluster link fluctuations, but cannot completely prevent cluster link fluctuations caused by service online. Summary of the Invention

[0005] Embodiments of the present invention provide a microservice information processing method for preventing cluster link fluctuations caused by service online. The method includes:

[0006] Intercept a first original start instruction and a second original start instruction according to pre-configured service configuration information; wherein, the service configuration information contains instruction identifiers of instructions to be intercepted, the first original start instruction is used to start a service registration client, and the second original start instruction is used to start a service warm-up executor;

[0007] According to the service configuration information, when a Spring Cloud microservice component subscribes to a service warm-up completion notification, send a first start instruction to the service registration client, so that after the service registration client is started according to the first start instruction, send a registration request to the service registration center to complete service online; wherein, the service warm-up completion notification is published by the Spring container after the service warm-up is completed.

[0008] Embodiments of the present invention also provide a microservice information processing apparatus for preventing cluster link fluctuations caused by service online. The apparatus includes:

[0009] The first processing module is used to intercept a first original startup instruction and a second original startup instruction according to pre-configured service configuration information; wherein, the service configuration information includes the instruction identifiers of the instructions to be intercepted, the first original startup instruction is used to start a service registration client, and the second original startup instruction is used to start a service warm-up executor;

[0010] The second processing module is used to send a first startup instruction to the service registration client according to the service configuration information when the Spring Cloud microservice component subscribes to the service warm-up completion notification, so that after the service registration client starts according to the first startup instruction, it sends a registration request to the service registration center to complete the service online; wherein, the service warm-up completion notification is published by the Spring container after the service warm-up is completed.

[0011] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the above microservice information processing method is implemented.

[0012] An embodiment of the present invention also provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above microservice information processing method is implemented.

[0013] An embodiment of the present invention also provides a computer program product, where the computer program product includes a computer program, and when the computer program is executed by a processor, the above microservice information processing method is implemented.

[0014] In an embodiment of the present invention, according to pre-configured service configuration information, a first original startup instruction and a second original startup instruction are intercepted; wherein, the service configuration information includes the instruction identifiers of the instructions to be intercepted, the first original startup instruction is used to start a service registration client, and the second original startup instruction is used to start a service warm-up executor; according to the service configuration information, when the Spring Cloud microservice component subscribes to the service warm-up completion notification, a first startup instruction is sent to the service registration client, so that after the service registration client starts according to the first startup instruction, it sends a registration request to the service registration center to complete the service online; wherein, the service warm-up completion notification is published by the Spring container after the service warm-up is completed. In this way, after the Spring container completes the service warm-up, the service will be exposed to the service registration center, avoiding the cluster link fluctuation caused by the service going online. Description of the Drawings

[0015] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings. In the drawings:

[0016] Figure 1 is a flowchart of an existing service online process provided in an embodiment of the present invention;

[0017] Figure 2 is a flowchart of a microservice information processing method provided in an embodiment of the present invention;

[0018] Figure 3 is a comparison diagram of an existing service online process and the service online process of the present application in an embodiment of the present invention;

[0019] Figure 4 is a flowchart of an existing service offline process provided in an embodiment of the present invention;

[0020] Figure 5 is a comparison diagram of an existing service offline process and the service offline process of the present invention in an embodiment of the present invention;

[0021] Figure 6 is a schematic diagram of a microservice information processing device provided in an embodiment of the present invention. Detailed Embodiments

[0022] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer and more understandable, the following will further describe the embodiments of the present invention in detail with reference to the accompanying drawings. Herein, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but not to limit the present invention.

[0023] In the technical solutions of this application, the acquisition, storage, use, processing, etc. of data all comply with the relevant regulations of national laws and regulations.

[0024] The term "and / or" in this article only describes an association relationship and indicates that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the term "at least one" in this article means any one of multiple or any combination of at least two of multiple. For example, including at least one of A, B, and C can represent any one or more elements selected from the set composed of A, B, and C.

[0025] In the description of this specification, the terms "include", "including", "have", "containing", etc. are all open-ended terms, meaning including but not limited to. The description referring to terms such as "one embodiment", "one specific embodiment", "some embodiments", "for example", etc. means that the specific features, structures or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of this application. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. The order of steps involved in each embodiment is used to schematically illustrate the implementation of this application, and the order of steps is not limited and can be adjusted appropriately as needed.

[0026] As Figure 1 shown, it is a flowchart of an existing service online process provided by an embodiment of the present invention. According to Figure 1 it can be known that after Spring starts up and completes, the service needs to preheat the business, and the business function can be provided externally only after the preheating is completed. However, the service will send a service registration request to the service registry after Spring starts up and completes, which may cause the service to be prematurely exposed to the registry before all preheating work is completed, resulting in abnormal execution of requests sent to this service and causing fluctuations in the cluster link. After research, it is found that the existing service online scheme can only shorten the duration of cluster link fluctuations, but cannot completely prevent the cluster link from fluctuating caused by service online.

[0027] In response to the above research, an embodiment of the present invention provides a microservice information processing method, as Figure 2 shown, including:

[0028] S201: Intercept the first original start instruction and the second original start instruction according to the pre-configured service configuration information; wherein, the service configuration information contains the instruction identifier of the instruction to be intercepted, the first original start instruction is used to start the service registration client, and the second original start instruction is used to start the service preheating executor;

[0029] S202: According to the service configuration information, when the Spring Cloud microservice component subscribes to the service preheating completion notification, send the first start instruction to the service registration client, so that after the service registration client starts according to the first start instruction, send a registration request to the service registry to complete the service online; wherein, the service preheating completion notification is published by the Spring container after the service preheating is completed.

[0030] In an embodiment of the present invention, according to pre-configured service configuration information, intercept the first original startup instruction and the second original startup instruction; wherein, the service configuration information contains the instruction identifiers of the instructions to be intercepted, the first original startup instruction is used to start the service registration client, and the second original startup instruction is used to start the service warm-up executor; according to the service configuration information, when the Spring Cloud microservice component subscribes to the service warm-up completion notification, send the first startup instruction to the service registration client, so that after the service registration client starts according to the first startup instruction, send a registration request to the service registration center to complete the service online; wherein, the service warm-up completion notification is published by the Spring container after the service warm-up is completed. In this way, the service will only be exposed to the service registration center after the Spring container completes the service warm-up, avoiding the cluster link fluctuations caused by service online.

[0031] The above microservice information processing method will be described in detail below.

[0032] In order to avoid exposing the service to the service registration center prematurely before the service warm-up is completed, the first original startup instruction and the second original startup instruction can be intercepted according to the pre-configured service configuration information, wherein the first original startup instruction is used to start the service registration client, and the second original startup instruction is used to start the service warm-up executor.

[0033] Specifically, the service configuration information contains the instruction identifiers of the instructions to be intercepted, such as the instruction identifier of the first original startup instruction, the instruction identifier of the second original startup instruction, and the instruction identifiers of other instructions to be intercepted.

[0034] Currently, most components providing microservice registration and discovery are introduced into the project engineering in the form of an SDK (Software Development Kit) during the development stage and appended to the dependencies of the service during the application compilation and packaging stage. If the SDK method is used to complete the service online function, relevant function components need to be manually introduced and the application needs to be recompiled and packaged again, which is not applicable to large distributed application systems that are already online and running stably.

[0035] Therefore, in order to achieve runtime secondary modification of the loaded java classes when the application starts without modifying the application deployment package, the embodiment of the present invention uses the java agent bytecode enhancement technology to implement the configuration of service online, such as: receiving the service configuration information configured by the configuration personnel according to the java agent bytecode enhancement technology before intercepting the first original startup instruction and the second original startup instruction according to the pre-configured service configuration information.

[0036] In this way, relying on Java agent bytecode enhancement technology, the relevant logic of service online can be changed while the application service is running.

[0037] Specifically, in one embodiment of the present invention, the service configuration information includes, for example, a first prefix code to be added before the original service launch method and a first postcode to be added after the service preheating method, and the first prefix code includes an instruction identifier of the instruction to be intercepted.

[0038] Therefore, according to the pre-configured service configuration information, the first original startup instruction and the second original startup instruction are intercepted, for example, including: when the service registration online instruction is received, the first prefix code in the service configuration information is executed, and the first original startup instruction and the second original startup instruction are intercepted according to the execution of the first prefix code in the service configuration information.

[0039] Therefore, according to the service configuration information, when the Spring Cloud microservice component subscribes to the service preheating completion notification, a first startup instruction is sent to the service registration client, for example, including: according to the execution of the first postcode in the service configuration information, when the Spring Cloud microservice component subscribes to the service preheating completion notification, a first startup instruction is sent to the service registration client.

[0040] For example, in applications using open-source microservice components (such as Spring Cloud), the startup sequence for components like service registration is entirely determined by the development framework. For example, the mainstream Spring framework provides a container that creates and initializes instances of all business functions and component dependencies. After completing basic framework initialization, the Spring container publishes a service warmup completion notification. Open-source microservice components subscribe to this notification, start the service registration client, and initiate service registration requests to the registry.

[0041] like Figure 3 As shown, a comparison diagram of an existing service launch process provided by an embodiment of the present invention and the service launch process of the present application is shown. The left side is the existing service launch process, which will cause the service to be exposed to the service registration center prematurely before the service preheating is completed. The right side is the service launch process improved by the java agent bytecode enhancement technology in the embodiment of the present invention. By intercepting the first original startup instruction and the second original startup instruction, the timing of the service launch is controlled according to the service configuration information. After the service preheating is completed, a registration request is sent to the registration center to complete the service launch, thereby avoiding exposing the service to the service registration center before the service preheating is completed, and eliminating the cluster link fluctuation caused by the service launch.

[0042] Here, for example, configurable enhanced interception can be achieved through means such as system variables.

[0043] In addition, in order to monitor the health status of the service at any time after it goes online, in another embodiment of the present invention, after sending a registration request to the service registry and completing the service online, it further includes: running a heartbeat connection task thread to report the service health status to the service registry.

[0044] In addition, as Figure 4 shown, it is a flowchart of an existing service offline provided by an embodiment of the present invention. According to Figure 4 it can be known that before the service is closed, the spring cloud component sends a deregistration request to the service registry, and the registry removes the service instance. However, the service invoker regularly fetches the service instance data from the registry and refreshes it to the local cache. As a result, during the period from the instance removal to the cache refresh, the service data of the closed service still remains in the local caches of each service invoker, and each service invoker will still send requests to the offline service, resulting in abnormal execution of the requests sent to this service and causing fluctuations in the cluster link. After research, it is also found that the existing service offline solution can only shorten the duration of the cluster link fluctuations, but cannot completely prevent the cluster link fluctuations caused by service offline.

[0045] Therefore, another embodiment of the present invention further includes: intercepting the spring container to execute the original component instance destruction method according to the pre-configured service configuration information, and sending the service offline request to the service registry; according to the pre-configured service configuration information, after the service registry finishes executing the service offline request, blocking and waiting for the service data in the local caches of each service invoker to expire; according to the pre-configured service configuration information, after the service data in the local caches of each service invoker expires, controlling the spring container to execute the original component instance destruction method to complete the service offline.

[0046] In an embodiment of the present invention, the service configuration information includes: a second pre-code to be added before the original service offline method, a preset duration, and a second post-code to be added after the method of blocking and waiting for the service data in the local caches of each service invoker to expire. The instruction identifier of the instruction to be intercepted is included in the second pre-code, and the preset duration can be configured in combination with the actual application scenario.

[0047] Among them, for example, the configurability of the preset duration can be achieved by means such as environment variables, and the default setting is 30 seconds, which is the default time for spring cloud service discovery cache refresh (i.e., the preset duration).

[0048] Therefore, according to the pre-configured service configuration information, intercept the spring container from executing the original component instance destruction method, and send the service offline request to the service registry. For example, when receiving the service offline request, execute the second pre-code, intercept the spring container from executing the original component instance destruction method according to the execution of the second pre-code, and send the service offline request to the service registry.

[0049] Therefore, after the service offline process is completed according to the service configuration information, block and wait for the service data cached locally by each service invoker to expire. This includes: after the service offline process is completed, block and wait for a preset period of time to make the service data cached locally by each service invoker expire.

[0050] Therefore, according to the pre-configured service configuration information, after the service data cached locally by each service invoker expires, control the spring container to execute the original component instance destruction method. This includes: after the service data cached locally by each service invoker expires, execute the second post-code, and control the spring container to execute the original component instance destruction method according to the execution of the second post-code.

[0051] As Figure 5 shown, it is a comparison diagram of an existing service offline process and the service offline process of the present invention provided by an embodiment of the present invention. Among them, the left side is the existing service offline process. When the application is closed, it will trigger the shutdown hook callback. At this time, the spring container will start to execute the shutdown process, and the original component instance destruction method will be executed in sequence during the shutdown process. That is, in the existing service offline process, the service registry will be notified to go offline only after the original component instance destruction method is executed. At this time, each service party will still send requests to the service according to the service data cached locally by it, but the service has gone offline and cannot respond to these requests, resulting in cluster link fluctuations. The right side is the service offline process of the embodiment of the present invention. Through the service configuration information, intercept the spring container from executing the original component instance destruction method, first notify the service registry to go offline, and then wait for a preset duration. After each service invoker updates the service data cached locally according to the service offline request of the registry, then execute the original component instance destruction method to truly complete the service offline, so as to avoid the service invoker from continuing to send requests to the service after the service goes offline, and completely eliminate the cluster link fluctuations caused by the service offline.

[0052] An embodiment of the present invention also provides a microservice information processing device as described in the following embodiments. Since the principle of the device for solving problems is similar to that of the microservice information processing method, the implementation of the device can refer to the implementation of the microservice information processing method, and the repeated parts will not be described again.

[0053] As Figure 6As shown in the figure, it is a schematic diagram of a microservice information processing device provided by an embodiment of the present invention, including:

[0054] A first processing module 601, configured to intercept a first original startup instruction and a second original startup instruction according to pre-configured service configuration information; wherein, the service configuration information includes an instruction identifier of an instruction to be intercepted, the first original startup instruction is used to start a service registration client, and the second original startup instruction is used to start a service warm-up executor;

[0055] A second processing module 602, configured to send a first startup instruction to the service registration client when the Spring Cloud microservice component subscribes to a service warm-up completion notification according to the service configuration information, so that after the service registration client starts according to the first startup instruction, it sends a registration request to the service registration center to complete service online; wherein, the service warm-up completion notification is published by the Spring container after the service warm-up is completed.

[0056] In a possible implementation manner, it further includes: a configuration module, configured to receive service configuration information configured by a configurator according to the java agent bytecode enhancement technology.

[0057] In a possible implementation manner, the service configuration information includes a first pre-code to be added before the original service online method and a first post-code to be added after the service warm-up method, and the first pre-code includes an instruction identifier of an instruction to be intercepted; the first processing module is specifically configured to execute the first pre-code in the service configuration information when receiving a service registration online instruction, and intercept the first original startup instruction and the second original startup instruction according to the execution of the first pre-code in the service configuration information; the second processing module is specifically configured to send a first startup instruction to the service registration client when the Spring Cloud microservice component subscribes to a service warm-up completion notification according to the execution of the first post-code in the service configuration information.

[0058] 0In a possible implementation manner, it further includes: a third processing module, configured to run a heartbeat connection task thread to report the service health status to the service registration center.

[0059] In a possible implementation manner, it further includes: a fourth processing module, configured to intercept the original component instance destruction method executed by the spring container according to the pre-configured service configuration information, and send a service offline request to the service registration center

[0060] Heart; according to the pre-configured service configuration information, after the service offloading request is executed in the service registry, block and wait for the service data cached locally by each service invoker to expire; according to the pre-configured service configuration information, after the service data cached locally by each service invoker expires, control the spring container to execute the original component instance destruction method to complete the service offloading.

[0061] In a possible implementation manner, the service configuration information includes: a second pre-code to be added before the original service offloading method, a preset duration, and a second post-code to be added after the method of blocking and waiting for the service data cached locally by each service invoker to expire. The second pre-code contains the instruction identifier of the instruction to be intercepted, and the preset duration can be configured; the fourth processing module is specifically configured to, when receiving a service offloading request, execute the second pre-code, intercept the spring container from executing the original component instance destruction method according to the execution of the second pre-code, and send the service offloading request to the service registry; after the service offloading process is completed, block and wait for the preset time length to make the service data cached locally by each service invoker expire; after the service data cached locally by each service invoker expires, execute the second post-code, and control the spring container to execute the original component instance destruction method according to the execution of the second post-code.

[0062] In a possible implementation manner, the service configuration information includes: a second pre-code to be added before the original service offloading method, a preset duration, and a second post-code to be added after the method of blocking and waiting for the service data cached locally by each service invoker to expire. The second pre-code contains the instruction identifier of the instruction to be intercepted, and the preset duration can be configured; the fourth processing module is specifically configured to, when receiving a service offloading request, execute the second pre-code, intercept the spring container from executing the original component instance destruction method according to the execution of the second pre-code, and send the service offloading request to the service registry; after the service offloading process is completed, block and wait for the preset time length to make the service data cached locally by each service invoker expire; after the service data cached locally by each service invoker expires, execute the second post-code, and control the spring container to execute the original component instance destruction method according to the execution of the second post-code.

[0063] An embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the above-mentioned microservice information processing method is implemented.

[0064] An embodiment of the present invention further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the above-mentioned microservice information processing method is implemented.

[0065] An embodiment of the present invention further provides a computer program product. The computer program product includes a computer program. When the computer program is executed by a processor, the above-mentioned microservice information processing method is implemented.

[0066] In the embodiments of the present invention, according to pre-configured service configuration information, the first original startup instruction and the second original startup instruction are intercepted; wherein, the service configuration information contains the instruction identifiers of the instructions to be intercepted, the first original startup instruction is used to start the service registration client, and the second original startup instruction is used to start the service warm-up executor; according to the service configuration information, when the Spring Cloud microservice component subscribes to the service warm-up completion notification, a first startup instruction is sent to the service registration client, so that after the service registration client starts according to the first startup instruction, a registration request is sent to the service registration center to complete the service online; wherein, the service warm-up completion notification is published by the Spring container after the service warm-up is completed. In this way, after the Spring container completes the service warm-up, the service will be exposed to the service registration center, avoiding the cluster link fluctuations caused by the service going online.

[0067] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer-usable program code.

[0068] The present invention is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram can be implemented by computer program instructions, and the combination of the flows and / or blocks in the flowchart and / or block diagram can also be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for realizing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 the functions specified in one block or multiple blocks.

[0069] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device realizes the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 the functions specified in one block or multiple blocks.

[0070] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, so that a series of operation steps are executed on the computer or other programmable apparatus to produce a computer-implemented process, thereby providing instructions for implementing the steps of the process Figure 1 one process or a plurality of processes and / or blocks Figure 1 steps for the functions specified in one block or a plurality of blocks.

[0071] The specific embodiments described above further elaborate on the objectives, technical solutions, and beneficial effects of the present invention. It should be understood that the above description is only for the specific embodiments of the present invention and is not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.

Claims

1. A microservice information processing method, characterized in that, Including: Intercept the first original startup instruction and the second original startup instruction according to pre-configured service configuration information; wherein, the service configuration information contains the instruction identifiers of the instructions to be intercepted, the first original startup instruction is used to start the service registration client, and the second original startup instruction is used to start the service warm-up executor; According to the service configuration information, when the Spring Cloud microservice component subscribes to the service warm-up completion notification, send the first startup instruction to the service registration client, so that after the service registration client starts according to the first startup instruction, send a registration request to the service registration center to complete the service online; wherein, the service warm-up completion notification is published by the Spring container after the service warm-up is completed; Before intercepting the first original startup instruction and the second original startup instruction according to the pre-configured service configuration information, it further includes: receiving the service configuration information configured by the configurator according to the java agent bytecode enhancement technology; The method further includes: intercepting the original component instance destruction method executed by the spring container according to the pre-configured service configuration information, and sending the service offline request to the service registration center; according to the pre-configured service configuration information, after the service registration center finishes executing the service offline request, block and wait for the service data cached locally by each service invoker to expire; according to the pre-configured service configuration information, after the service data cached locally by each service invoker expires, control the spring container to execute the original component instance destruction method to complete the service offline.

2. The microservice information processing method according to claim 1, characterized in that The service configuration information contains the first pre-code to be added before the original service online method and the first post-code to be added after the service warm-up method, and the first pre-code contains the instruction identifier of the instruction to be intercepted; Intercepting the first original startup instruction and the second original startup instruction according to the pre-configured service configuration information includes: When receiving the service registration online instruction, execute the first pre-code in the service configuration information, and intercept the first original startup instruction and the second original startup instruction according to the execution of the first pre-code in the service configuration information; Sending the first startup instruction to the service registration client when the Spring Cloud microservice component subscribes to the service warm-up completion notification according to the service configuration information includes: According to the execution of the first post-code in the service configuration information, send the first startup instruction to the service registration client when the Spring Cloud microservice component subscribes to the service warm-up completion notification.

3. The microservice information processing method according to claim 1, wherein After sending a registration request to the service registration center to complete the service online, it further includes: Running the heartbeat connection task thread to report the service health status to the service registration center.

4. The microservice information processing method according to claim 1, wherein The service configuration information includes: the second pre-code to be added before the original service offline method, the preset duration, and the second post-code to be added after the method of blocking and waiting for the service data cached locally by each service invoker to expire, the second pre-code contains the instruction identifier of the instruction to be intercepted, and the preset duration can be configured; Intercepting the original component instance destruction method executed by the spring container according to the pre-configured service configuration information and sending the service offline request to the service registration center includes: When receiving a service offline request, execute the second pre - code, intercept the original component instance destruction method executed by the spring container according to the execution of the second pre - code, and send the service offline request to the service registry center; After the service offline process is completed according to the service configuration information, block and wait for the service data cached locally by each service invoker to expire, including: After the service offline process is completed, block and wait for a preset period of time to make the service data cached locally by each service invoker expire; According to the pre - configured service configuration information, after the service data cached locally by each service invoker expires, control the spring container to execute the original component instance destruction method, including: After the service data cached locally by each service invoker expires, execute the second post - code, and control the spring container to execute the original component instance destruction method according to the execution of the second post - code.

5. A microservice information processing device, characterized in that, Including: The first processing module is used to intercept the first original start instruction and the second original start instruction according to the pre - configured service configuration information; wherein, the service configuration information contains the instruction identifier of the instruction to be intercepted, the first original start instruction is used to start the service registration client, and the second original start instruction is used to start the service warm - up executor; The second processing module is used to send a first start instruction to the service registration client when the Spring Cloud microservice component subscribes to the service warm - up completion notification according to the service configuration information, so that after the service registration client starts according to the first start instruction, it sends a registration request to the service registry center to complete the service online; wherein, the service warm - up completion notification is published by the Spring container after the service warm - up is completed; The configuration module is used to receive the service configuration information configured by the configurator according to the java agent byte - code enhancement technology; The fourth processing module is used to intercept the original component instance destruction method executed by the spring container according to the pre - configured service configuration information, send the service offline request to the service registry center; according to the pre - configured service configuration information, block and wait for the service data cached locally by each service invoker to expire after the service registry center finishes executing the service offline request; according to the pre - configured service configuration information, control the spring container to execute the original component instance destruction method after the service data cached locally by each service invoker expires to complete the service offline.

6. The microservice information processing device according to claim 5, wherein The service configuration information contains the first pre - code to be added before the original service online method and the first post - code to be added after the service warm - up method, and the first pre - code contains the instruction identifier of the instruction to be intercepted; The first processing module is specifically used to execute the first pre - code in the service configuration information when receiving the service registration online instruction, and intercept the first original start instruction and the second original start instruction according to the execution of the first pre - code in the service configuration information; The second processing module is specifically used to send a first start instruction to the service registration client when the Spring Cloud microservice component subscribes to the service warm - up completion notification according to the execution of the first post - code in the service configuration information.

7. The microservice information processing device according to claim 5, wherein It also includes: A third processing module, which is used to run a heartbeat connection task thread to report the service health status to the service registry center.

8. The microservice information processing device according to claim 5, wherein The service configuration information includes: a second pre-code to be added before the original service offline method, a preset duration, and a second post-code to be added after the method of blocking and waiting for the service data cached locally by each service invoker to expire. The instruction identifier of the instruction to be intercepted is included in the second pre-code, and the preset duration can be configured; A fourth processing module, specifically used for, when receiving a service offline request, executing the second pre-code, intercepting the spring container from executing the original component instance destruction method according to the execution of the second pre-code, and sending the service offline request to the service registry center; After the service offline process is completed, block and wait for a preset time length to expire the service data cached locally by each service invoker; After the service data cached locally by each service invoker expires, execute the second post-code, and control the spring container to execute the original component instance destruction method according to the execution of the second post-code.

9. A computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method according to any one of claims 1 to 4.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, it implements the method according to any one of claims 1 to 4.

11. A computer program product, characterized in that, The computer program product includes a computer program, and when the computer program is executed by the processor, it implements the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Request processing method and device, server and storage medium

    CN113268360A