Service fuse method and device based on Dubbo framework

By using Nacos to define and manage fuse switch parameters in the Dubbo framework, combined with Dubbo filter interception and parameter change listener, manual control fuse of the service is achieved, solving the problem of the lack of manual control fuse mechanism in the Dubbo framework, and enhancing the system flexibility and stability.

CN115277820BActive Publication Date: 2025-01-10BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210920491.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-02
Publication Date
2025-01-10
Estimated Expiration
2042-08-02

AI Technical Summary

Technical Problem

The existing Dubbo framework does not support manual control of fuses, and cannot achieve temporary fuses to a certain service, and lacks a mechanism for manual control of fuses.

Method used

Intercept service requests through Dubbo filters and read the fuse switch parameters from Nacos. If the parameter is the on fuse value, fuse measures will be taken to support the user to manually configure and modify the fuse parameters, and update the bean definition in real time through the parameter change listener.

Benefits of technology

The mechanism of adding manual control of fuses in the Dubbo framework is implemented, allowing users to fuse a certain service as needed, avoiding the occurrence of avalanche effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115277820B_ABST
    Figure CN115277820B_ABST
Patent Text Reader

Abstract

The present invention discloses a service fuse method and device based on Dubbo framework, the method comprising: intercepting service request through Dubbo filter; reading fuse switch parameters corresponding to the service requested by the intercepted service request from Nacos, wherein the fuse switch parameters are manually configured, and the fuse switch parameters include: a first parameter value for indicating opening the fuse; if the read fuse switch parameter is the first parameter value, taking a pre-set fuse measure for the intercepted service request. Compared with the automatic fuse mechanism currently provided by Dubbo, the present invention adds a manual intervention mechanism and is more flexible.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of service fuse technology, and in particular to a service fuse method and device based on a Dubbo framework. Background Art

[0002] Dubbo is an open-source, high-performance service framework that enables applications to implement service output and input functions through high-performance RPC, and can be seamlessly integrated with the Spring framework. Fusing refers to the instability of a resource in the system call link, which may cause requests to pile up, leading to cascading errors. At this time, the unstable resources are isolated and fused, and for subsequent call requests, the target service is no longer called, and it returns directly to quickly release resources. Avoid the "avalanche effect".

[0003] The components such as Hystrix, resilience4j, and Sentinel supported by the Dubbo framework can all implement service degradation and circuit breaking, and support setting circuit breaking conditions in multiple dimensions, including the proportion of slow interface calls, the proportion of exceptions, the number of exceptions, and other dimensions. It also supports developers to customize the simulated return content. Once the circuit breaking condition is triggered, the pre-defined return content is directly returned, and the Dubbo service is no longer called. When the service is judged to have been restored according to the circuit breaking conditions, it returns to normal. However, the current Dubbo framework does not support manual control of circuit breaking. For example, it is currently impossible to manually temporarily circuit breaker a service. Therefore, the prior art Dubbo framework lacks a mechanism for manual control of circuit breaking. Summary of the invention

[0004] In order to solve at least one technical problem in the above-mentioned background technology, the present invention proposes a service fusing method and device based on the Dubbo framework.

[0005] In order to achieve the above object, according to one aspect of the present invention, a service fusing method based on the Dubbo framework is provided, the method comprising:

[0006] Intercept service requests through Dubbo filters;

[0007] Reading from Nacos the fuse switch parameter corresponding to the service requested by the intercepted service request, wherein the fuse switch parameter is manually configured, and the fuse switch parameter includes: a first parameter value for indicating that the fuse is turned on;

[0008] If the read fuse switch parameter is the first parameter value, a pre-set fuse measure is taken for the intercepted service request.

[0009] Optionally, the fuse switch parameter further includes: a second parameter value for indicating closing the fuse;

[0010] The service fusing method based on the Dubbo framework also includes:

[0011] If the read fuse switch parameter is the second parameter value, the intercepted service request is processed.

[0012] Optionally, the service fusing method based on the Dubbo framework further includes:

[0013] Use the parameter change monitor to monitor in real time whether the parameters of each fuse switch in Nacos have changed;

[0014] If the fuse switch parameters are changed, reload the bean definition to make the changed parameters take effect.

[0015] Optionally, the service fusing method based on the Dubbo framework further includes:

[0016] Obtaining a modification instruction from a user to modify the fuse switch parameters of a target service;

[0017] According to the modification instruction, the fuse switch parameters corresponding to the target service in Nacos are modified accordingly.

[0018] In order to achieve the above object, according to another aspect of the present invention, a service fuse device based on the Dubbo framework is provided, the device comprising:

[0019] The service request interception unit is used to intercept service requests through Dubbo filters;

[0020] The fuse switch parameter reading unit is used to read the fuse switch parameter corresponding to the service requested by the intercepted service request from Nacos, wherein the fuse switch parameter is manually configured, and the fuse switch parameter includes: a first parameter value used to indicate opening the fuse;

[0021] The fuse measure execution unit is used to take a preset fuse measure for the intercepted service request if the read fuse switch parameter is a first parameter value.

[0022] Optionally, the fuse switch parameter further includes: a second parameter value for indicating closing the fuse;

[0023] The service fuse device based on the Dubbo framework also includes:

[0024] The service request processing unit is used to process the intercepted service request if the read fuse switch parameter is a second parameter value.

[0025] Optionally, the service fuse device based on the Dubbo framework further includes:

[0026] The parameter change monitoring unit is used to monitor in real time whether the parameters of each fuse switch in Nacos have changed through the parameter change monitor;

[0027] The parameter validation unit is used to reload the bean definition if the fuse switch parameters change, so that the changed parameters can take effect.

[0028] Optionally, the service fuse device based on the Dubbo framework further includes:

[0029] A parameter modification instruction acquisition unit, used to acquire a modification instruction from a user to modify a fuse switch parameter of a target service;

[0030] The parameter modification unit is used to modify the fuse switch parameters corresponding to the target service in Nacos according to the modification instruction.

[0031] In order to achieve the above-mentioned purpose, according to another aspect of the present invention, a computer device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned service fuse method based on the Dubbo framework when executing the computer program.

[0032] In order to achieve the above-mentioned purpose, according to another aspect of the present invention, a computer-readable storage medium is further provided, on which a computer program / instruction is stored, and when the computer program / instruction is executed by a processor, the steps of the above-mentioned service fuse method based on the Dubbo framework are implemented.

[0033] In order to achieve the above-mentioned purpose, according to another aspect of the present invention, a computer program product is also provided, including a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned service fuse method based on the Dubbo framework.

[0034] The beneficial effects of the present invention are:

[0035] The embodiment of the present invention defines the fuse switch parameters through Nacos, intercepts the service request through the Dubbo filter, reads the fuse switch parameters corresponding to the service requested by the intercepted service request from Nacos, and if the read fuse switch parameter is the first parameter value, a pre-set fuse measure is taken for the intercepted service request. The present invention can realize artificially breaking a service by defining the fuse switch parameters through Nacos, and realizes adding a mechanism of manually controlling the breaking in the Dubbo framework of the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0037] Figure 1 This is a first flow chart of a service fusing method based on the Dubbo framework according to an embodiment of the present invention;

[0038] Figure 2 This is a second flow chart of the service fusing method based on the Dubbo framework according to an embodiment of the present invention;

[0039] Figure 3 This is a third flow chart of a service fusing method based on the Dubbo framework according to an embodiment of the present invention;

[0040] Figure 4 It is the framework diagram of the present invention;

[0041] Figure 5 This is a first structural block diagram of a service fuse device based on the Dubbo framework according to an embodiment of the present invention;

[0042] Figure 6 This is a second structural block diagram of a service fuse device based on the Dubbo framework according to an embodiment of the present invention;

[0043] Figure 7 This is a third structural block diagram of a service fuse device based on the Dubbo framework according to an embodiment of the present invention;

[0044] Figure 8 It is a schematic diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0045] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0046] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0047] It should be noted that the terms "including" and "having" and any variations thereof in the specification and claims of the present invention and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or apparatus.

[0048] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0049] It should be noted that the acquisition, storage, use, and processing of data in the technical solution of this application are in compliance with the relevant provisions of national laws and regulations.

[0050] Figure 1 This is the first flow chart of the service fusing method based on the Dubbo framework in an embodiment of the present invention. Figure 1 As shown, in one embodiment of the present invention, the service fusing method based on the Dubbo framework of the present invention includes steps S101 to S103.

[0051] Step S101, intercepting the service request through the Dubbo filter.

[0052] In the embodiment of the present invention, the Dubbo filter intercepts every service request.

[0053] Step S102, reading the fuse switch parameter corresponding to the service requested by the intercepted service request from Nacos, wherein the fuse switch parameter is manually configured, and the fuse switch parameter includes: a first parameter value for indicating that the fuse is turned on. In one embodiment of the present invention, the fuse switch parameter also includes: a second parameter value for indicating that the fuse is turned off.

[0054] In a specific embodiment of the present invention, the first parameter value is on, and the second parameter value is off.

[0055] The present invention utilizes Nacos parameter management to save fuse switch parameters. Users can set fuse switch parameters corresponding to each service in Nacos and can change the fuse switch parameters. In addition, users can also add and delete fuse switch parameters in Nacos.

[0056] The present invention increases the fuse switch parameter through Nacos parameter management. When a method of a certain service needs to be fused, the corresponding Nacos parameter value is modified and the corresponding switch is turned on to achieve fusion. Thus, a manual control fuse mechanism is added to the prior art Dubbo framework.

[0057] Nacos is a dynamic service discovery, configuration and service management platform that provides three functions: registration center, configuration center and dynamic DNS service. It can seamlessly connect to popular frameworks such as Springcloud, Spring, Dubbo, etc. Nacos's functions include: DNS-based and RPC-based service discovery (can be used as a registration center for springcloud), dynamic configuration service (can be used as a configuration center), and dynamic DNS service.

[0058] Step S103: If the read fuse switch parameter is the first parameter value, a pre-set fuse measure is taken for the intercepted service request.

[0059] The present invention determines whether the service corresponding to the service request is within the range of the fused service interface by querying the fuse switch parameters. If so, a pre-set fuse measure is taken, otherwise, the execution continues.

[0060] In one embodiment of the present invention, the service fusing method based on the Dubbo framework further includes:

[0061] If the read fuse switch parameter is the second parameter value, the intercepted service request is processed.

[0062] like Figure 2 As shown, in one embodiment of the present invention, the service fusing method based on the Dubbo framework of the present invention includes step S201 and step S202.

[0063] Step S201: Monitor in real time whether the parameters of each fuse switch in Nacos have changed through a parameter change monitor.

[0064] like Figure 4 As shown, the present invention sets a parameter change monitor for monitoring whether the parameters of each fuse switch in Nacos have changed.

[0065] Step S202: If there is a change in the fuse switch parameters, the bean definition is reloaded to make the changed parameters effective.

[0066] The present invention utilizes Nacos parameter management to save fuse switch parameters. When the parameter value changes (open or close), the parameter change listener will listen to the change and reload the bean definition of the service provider, so as to achieve the purpose of real-time effectiveness of parameter changes.

[0067] like Figure 3 As shown, in one embodiment of the present invention, the service fusing method based on the Dubbo framework of the present invention includes step S301 and step S302.

[0068] Step S301, obtaining a modification instruction from a user to modify the fuse switch parameters of a target service;

[0069] Step S302: modify the fuse switch parameters corresponding to the target service in Nacos according to the modification instruction.

[0070] In one embodiment of the present invention, the user can also add and delete fuse switch parameters in Nacos.

[0071] From the above embodiments, the present invention supports manual configuration of the fuse conditions by defining Nacos parameters. At the same time, when the parameter value changes, it can be monitored in real time and handled accordingly through the Dubbo filter. Compared with the automatic fuse mechanism currently provided by Dubbo, the present invention adds a manual intervention mechanism, which is more flexible.

[0072] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0073] Based on the same inventive concept, an embodiment of the present invention also provides a service fuse device based on the Dubbo framework, which can be used to implement the service fuse method based on the Dubbo framework described in the above embodiment, as described in the following embodiment. Since the principle of solving the problem by the service fuse device based on the Dubbo framework is similar to that of the service fuse method based on the Dubbo framework, the embodiment of the service fuse device based on the Dubbo framework can refer to the embodiment of the service fuse method based on the Dubbo framework, and the repeated parts will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.

[0074] Figure 5 This is a first structural block diagram of a service fuse device based on the Dubbo framework according to an embodiment of the present invention. Figure 5 As shown, in one embodiment of the present invention, the service fuse device based on the Dubbo framework of the present invention includes:

[0075] A service request interception unit 1, used to intercept service requests through a Dubbo filter;

[0076] The fuse switch parameter reading unit 2 is used to read the fuse switch parameter corresponding to the service requested by the intercepted service request from Nacos, wherein the fuse switch parameter is manually configured, and the fuse switch parameter includes: a first parameter value for indicating opening the fuse;

[0077] The fuse measure execution unit 3 is configured to take a preset fuse measure for the intercepted service request if the read fuse switch parameter is a first parameter value.

[0078] In one embodiment of the present invention, the fuse switch parameter further includes: a second parameter value for indicating a closed fuse;

[0079] The service fuse device based on the Dubbo framework also includes:

[0080] The service request processing unit is used to process the intercepted service request if the read fuse switch parameter is a second parameter value.

[0081] like Figure 6 As shown, in one embodiment of the present invention, the service fuse device based on the Dubbo framework of the present invention also includes:

[0082] The parameter change monitoring unit 4 is used to monitor in real time whether the parameters of each fuse switch in Nacos have changed through the parameter change monitor;

[0083] The parameter validation unit 5 is used to reload the bean definition if there is a change in the fuse switch parameter to make the changed parameter take effect.

[0084] like Figure 7 As shown, in one embodiment of the present invention, the service fuse device based on the Dubbo framework of the present invention also includes:

[0085] A parameter modification instruction acquisition unit 6, used to acquire a modification instruction from a user to modify the fuse switch parameters of a target service;

[0086] The parameter modification unit 7 is used to modify the fuse switch parameters corresponding to the target service in Nacos according to the modification instruction.

[0087] In order to achieve the above object, according to another aspect of the present application, a computer device is also provided. Figure 8 As shown, the computer device includes a memory, a processor, a communication interface and a communication bus. A computer program that can be executed on the processor is stored in the memory. When the processor executes the computer program, the steps in the above-mentioned embodiment method are implemented.

[0088] The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.

[0089] The memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer executable programs and units, such as the corresponding program units in the above method embodiments of the present invention. The processor executes various functional applications of the processor and works data processing by running the non-transitory software programs, instructions and modules stored in the memory, that is, implementing the method in the above method embodiments.

[0090] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0091] The one or more units are stored in the memory, and when executed by the processor, the method in the above embodiment is performed.

[0092] The specific details of the above-mentioned computer device can be understood by referring to the corresponding related descriptions and effects in the above-mentioned embodiments, and will not be repeated here.

[0093] In order to achieve the above purpose, according to another aspect of the present application, a computer-readable storage medium is also provided, wherein the computer-readable storage medium stores a computer program, and the computer program implements the steps in the service fuse method based on the Dubbo framework when executed in a computer processor. Those skilled in the art can understand that the implementation of all or part of the process in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and the program can include the process of the embodiment of each method as described above when executed. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk (Hard Disk Drive, abbreviated as: HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above-mentioned types of memory.

[0094] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a computer program product is also provided, including a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned service fuse method based on the Dubbo framework.

[0095] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0096] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A service fusing method based on Dubbo framework, characterized in that: include: Intercept service requests through Dubbo filters; Read the fuse switch parameters corresponding to the service requested by the intercepted service request from Nacos, wherein the fuse switch parameters are manually configured and include: a first parameter value for indicating that the fuse is turned on and a second parameter value for indicating that the fuse is turned off. Users can set the fuse switch parameters corresponding to each service in Nacos and can modify the fuse switch parameters. Users can also add and delete fuse switch parameters in Nacos. When a method of a service needs to be fused, the fuse can be realized by modifying the parameter value of the corresponding Nacos fuse switch parameter and turning on the corresponding switch. If the read fuse switch parameter is the first parameter value, a pre-set fuse measure is taken for the intercepted service request; If the read fuse switch parameter is the second parameter value, the intercepted service request is processed; Use the parameter change monitor to monitor in real time whether the parameters of each fuse switch in Nacos have changed; If the fuse switch parameters are changed, reload the bean definition to make the changed parameters take effect.

2. The service fusing method based on the Dubbo framework according to claim 1 is characterized in that: Also includes: Obtaining a modification instruction from a user to modify the fuse switch parameters of a target service; According to the modification instruction, the fuse switch parameters corresponding to the target service in Nacos are modified accordingly.

3. A service fuse device based on the Dubbo framework, characterized in that: include: The service request interception unit is used to intercept service requests through Dubbo filters; The fuse switch parameter reading unit is used to read the fuse switch parameters corresponding to the service requested by the intercepted service request from Nacos, wherein the fuse switch parameters are manually configured, and the fuse switch parameters include: a first parameter value for indicating that the fuse is turned on and a second parameter value for indicating that the fuse is turned off. The user can set the fuse switch parameters corresponding to each service in Nacos, and can change the fuse switch parameters. The user can also add and delete fuse switch parameters in Nacos; when a method of a certain service needs to be fused, the fuse can be realized by modifying the parameter value of the corresponding Nacos fuse switch parameter and turning on the corresponding switch; a fuse measure execution unit, configured to take a preset fuse measure for the intercepted service request if the read fuse switch parameter is a first parameter value; a service request processing unit, configured to process the intercepted service request if the read fuse switch parameter is a second parameter value; The parameter change monitoring unit is used to monitor in real time whether the parameters of each fuse switch in Nacos have changed through the parameter change monitor; The parameter validation unit is used to reload the bean definition if the fuse switch parameters change, so that the changed parameters can take effect.

4. The service fuse device based on the Dubbo framework according to claim 3 is characterized in that: Also includes: A parameter modification instruction acquisition unit, used to acquire a modification instruction from a user to modify a fuse switch parameter of a target service; The parameter modification unit is used to modify the fuse switch parameters corresponding to the target service in Nacos according to the modification instruction.

5. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to claim 1 or 2 are implemented.

6. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the method according to claim 1 or 2 are implemented.

7. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to claim 1 or 2 are implemented.

Citation Information

Patent Citations

  • Interface processing method and device, storage medium and processor

    CN107659431A

  • Network request fusing method and device, computer equipment and storage medium

    CN114553786A