Nothing Special   »   [go: up one dir, main page]

CN114003348A - Dubbo protocol conversion method and device in operation period - Google Patents

Dubbo protocol conversion method and device in operation period Download PDF

Info

Publication number
CN114003348A
CN114003348A CN202111425696.9A CN202111425696A CN114003348A CN 114003348 A CN114003348 A CN 114003348A CN 202111425696 A CN202111425696 A CN 202111425696A CN 114003348 A CN114003348 A CN 114003348A
Authority
CN
China
Prior art keywords
dubbo
interface
replaced
reference object
configuration information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111425696.9A
Other languages
Chinese (zh)
Inventor
郑泽奇
张顺
张鹏鹏
郑小虎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bank of China Ltd
Original Assignee
Bank of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN202111425696.9A priority Critical patent/CN114003348A/en
Publication of CN114003348A publication Critical patent/CN114003348A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • G06F9/45516Runtime code conversion or optimisation
    • G06F9/4552Involving translation to a different instruction set architecture, e.g. just-in-time translation in a JVM
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • G06F9/45529Embedded in an application, e.g. JavaScript in a Web browser

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention discloses a method and a device for converting a Dubbo protocol in an operation period, which relate to the technical field of cloud computing, and the method comprises the following steps: after the operation of the Dubbo engineering is triggered, scanning a plurality of Dubbo XML configuration files based on instantiation processing to obtain a plurality of Dubbo Reference objects; determining a Dubbo Reference object to be replaced according to the configuration information of the Dubbo interface and the Spring container context of the Dubbo engineering; converting the Dubbo Reference object to be replaced into a corresponding Feign object according to the configuration information of the Dubbo interface; and correspondingly replacing the Dubbo Reference object to be replaced by using the generated Feign object. The invention can perform Dubbo protocol conversion of the operation period consumer, and has low cost and high efficiency.

Description

Dubbo protocol conversion method and device in operation period
Technical Field
The invention relates to the technical field of cloud computing, in particular to a Dubbo protocol conversion method and device in an operation period.
Background
This section is intended to provide a background or context to the embodiments of the invention that are recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
With the gradual maturity of the development of the cloud platform, the system under the cloud gradually migrates to the cloud platform, and the running environment of the program changes from the previous virtual machine running environment to the PaaS environment. These changes cause the call protocol used by the program in the RPC call to change as well, changing from the Dubbo protocol under the cloud to the Http protocol on the cloud. The caller of the program is also modified, hundreds of interface calls may exist in the program, and all interface call modes need to be converted for protocol conversion, which involves a great deal of modification cost. How to automatically convert the protocols of all interfaces in a general way to reduce the development cost is a problem which needs to be solved urgently.
At present, the Dubbo protocol interface is translated into the Http protocol interface for calling through a manual modification mode, and the scheme of the method certainly involves the writing of a large amount of codes and has higher development cost. The existing Dubbo protocol conversion scheme has the following disadvantages.
1. High development and reconstruction cost
The scheme needs to develop new codes, all the existing codes are newly developed and replaced by one set, and if the number of the interfaces is large, the repeated operation can occupy a large amount of labor cost;
2. high requirement for developers
The above requirements for developers require the capability of developing Http protocol interfaces. Both schemes are difficult to implement for personnel just touching the item code.
In summary, a low-cost and general method for converting the Dubbo protocol into the Http protocol is lacking.
Disclosure of Invention
The embodiment of the invention provides an operation period Dubbo protocol conversion method, which is used for Dubbo protocol conversion of an operation period consumer, improving the convenience and conversion efficiency of Dubbo protocol conversion, saving human and material resources, and having low cost and high automation degree, and comprises the following steps:
after the operation of the Dubbo project is triggered, acquiring configuration information of a Dubbo interface according to a plurality of Dubbo XML configuration files;
scanning a plurality of Dubbo XML configuration files based on instantiation processing to obtain a plurality of Dubbo Reference objects;
determining a Dubbo Reference object to be replaced from the plurality of Dubbo Reference objects according to the configuration information of the Dubbo interface and the Spring container context of the Dubbo engineering; the Dubbo Reference object is for consuming a bean of the Dubbo protocol type;
for each Dubbo Reference object to be replaced, converting the Dubbo Reference object to be replaced into a corresponding Feign object according to the configuration information of the Dubbo interface; the Feign object is used for consuming an Http interface;
and correspondingly replacing the Dubbo Reference object to be replaced by using the generated Feign object.
The embodiment of the invention also provides a device for converting the Dubbo protocol in the operating period, which is used for converting the Dubbo protocol of an operating period consumer, improving the convenience and the conversion efficiency of the Dubbo protocol conversion, saving human and material resources, and having low cost and high automation degree, and the device comprises:
the device comprises a configuration information acquisition module of the Dubbo interface, a configuration information acquisition module of the Dubbo interface and a configuration information acquisition module of the Dubbo interface, wherein the Dubbo XML configuration files are used for acquiring the configuration information of the Dubbo interface after the operation of the Dubbo project is triggered;
the Dubbo Reference object determining module is used for scanning a plurality of Dubbo XML configuration files based on instantiation processing to obtain a plurality of Dubbo Reference objects;
the Dubbo Reference object determination module to be replaced is used for determining the Dubbo Reference object to be replaced from the plurality of Dubbo Reference objects according to the configuration information of the Dubbo interface and the Spring container context of the Dubbo engineering; the Dubbo Reference object is for consuming a bean of the Dubbo protocol type;
the device comprises a Feign object conversion module, a replacement module and a storage module, wherein the Feign object conversion module is used for converting each Dubbo Reference object to be replaced into a corresponding Feign object according to the configuration information of a Dubbo interface; the Feign object is used for consuming an Http interface;
and the Feign object replacing module is used for correspondingly replacing the Dubbo Reference object to be replaced by using the generated Feign object.
The embodiment of the invention also provides computer equipment which comprises a memory, a processor and a computer program which is stored on the memory and can be run on the processor, wherein the processor realizes the Dubbo protocol conversion method in the running period when executing the computer program.
The embodiment of the invention also provides a computer readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program realizes the Dubbo protocol conversion method in the operating period.
The embodiment of the invention also provides a computer program product, which comprises a computer program, and when the computer program is executed by a processor, the method for converting the Dubbo protocol in the running period is realized.
In the embodiment of the invention, after the operation of the Dubbo project is triggered, the configuration information of the Dubbo interface is obtained according to a plurality of Dubbo XML configuration files; scanning a plurality of Dubbo XML configuration files based on instantiation processing to obtain a plurality of Dubbo Reference objects; determining a Dubbo Reference object to be replaced from the plurality of Dubbo Reference objects according to the configuration information of the Dubbo interface and the Spring container context of the Dubbo engineering; the Dubbo Reference object is for consuming a bean of the Dubbo protocol type; for each Dubbo Reference object to be replaced, converting the Dubbo Reference object to be replaced into a corresponding Feign object according to the configuration information of the Dubbo interface; the Feign object is used for consuming an Http interface; the generated license object is used for correspondingly replacing the Dubbo Reference object to be replaced, compared with the technical scheme that the Dubbo protocol interface is translated into the Http protocol interface through manual modification in the prior art, the Dubbo Reference object is directly converted into the corresponding license object, so that the conversion of the RPC protocol of a consumer side can be completed in the running Springboot project, the problem of high development cost caused by manually developing codes to realize the conversion of the RPC protocol in the prior art is solved, a large amount of codes are not required to be developed, and manpower and material resources are saved; meanwhile, the problem that in the prior art, a person with code development capability can realize RPC protocol conversion to cause difficulty in implementation is solved, the method is simple to use, and does not invade the original code, so that the conversion convenience of the Dubbo protocol is improved, and the conversion efficiency of the Dubbo protocol is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts. In the drawings:
fig. 1 is a schematic flow chart of a method for converting a Dubbo protocol in an operation period according to an embodiment of the present invention;
fig. 2 is a specific example diagram of a method for converting a Dubbo protocol in an operation period according to an embodiment of the present invention;
fig. 3 is a diagram illustrating a structure of a device for converting a Dubbo protocol during operation according to an embodiment of the present invention;
fig. 4 is a specific example diagram of an operation period Dubbo protocol conversion apparatus according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a computer device provided in an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings. The exemplary embodiments and descriptions of the present invention are provided to explain the present invention, but not to limit the present invention.
The term "and/or" herein merely describes an associative relationship, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, and may mean including any one or more elements selected from the group consisting of A, B and C.
In the description of the present specification, the terms "comprising," "including," "having," "containing," and the like are used in an open-ended fashion, i.e., to mean including, but not limited to. Reference to the description of the terms "one embodiment," "a particular embodiment," "some embodiments," "for example," etc., means that a particular feature, structure, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. The sequence of steps involved in the embodiments is for illustrative purposes to illustrate the implementation of the present application, and the sequence of steps is not limited and can be adjusted as needed.
Embodiments of the present invention relate to the following terms, which are explained as follows:
RPC: remote procedure calls, colloquially, are calls made by one machine to the services of another.
The operation period is as follows: which means during program execution.
Dubbo protocol: an RPC protocol.
Http protocol: an RPC protocol.
Spring: a Java enterprise-level framework is the basis of Spring series framework.
Springboot: a Java development framework derived from Spring.
Class file: the file suffix is class file, which is generated after the Java file is compiled and can be executed by a Java virtual machine.
On the cloud: and (4) cloud platform.
Under cloud: a traditional virtual machine platform.
Bean: the Java objects managed by the Spring container each have some own properties and behaviors.
Dubbo Reference: the Dubbo protocol type is responsible for initiating the called bean.
Class (c): the representation defines a template with some data and logic implementation inside.
Interface: the representation defines a template that does not define the logic implementation that needs to be defined in the class that implements the interface.
And annotating: the special mark in the code is configured by adding @ XXX to the code.
Feign: and the service consumption end calls the framework and is responsible for initiating Http call.
Springboot: the Springboot framework is the mainstream Java system framework with strong functions at present, and can meet the requirement of quickly building projects. Each large website uses a Springboot as a basic development framework, and business codes are developed on the basis of the framework.
Dubbo protocol framework: the Dubbo protocol framework is a high-performance and light-weight open source Java service framework, provides interface agent-oriented high-performance RPC calling, is intelligent in fault tolerance and balancing in charge, automatically registers and discovers services, has high extensible capability, schedules flow in a running period, and controls and operates and maintains visual services. The protocol framework was developed by Alibaba and is also a widely used mainstream framework.
Class (c): a class is an abstract concept that does not exist in real time/space, and defines abstract properties and behaviors for all objects. Like the "Person" class, it may contain many individuals, but it does not exist in the real world itself. A class is a static concept, and does not carry any data itself. When no objects are created for a class, the class itself is not present in the memory space.
Object: an object is a concrete of a class, which is something that is actually present. An object is a dynamic concept. Each object has its own unique properties and behaviors that are different from other objects. The properties of an object may change with its own behavior.
With the gradual maturity of the development of the cloud platform, the system under the cloud gradually migrates to the cloud platform, and the running environment of the program changes from the previous virtual machine running environment to the PaaS environment. These changes cause the call protocol used by the program in the RPC call to change as well, changing from the Dubbo protocol under the cloud to the Http protocol on the cloud. The caller of the program is also modified, hundreds of interface calls may exist in the program, and all interface call modes need to be converted for protocol conversion, which involves a great deal of modification cost. How to automatically convert the protocols of all interfaces in a general way to reduce the development cost is a problem which needs to be solved urgently.
In order to solve the above problems, an embodiment of the present invention provides an operation period Dubbo protocol conversion method, which is used for performing Dubbo protocol conversion of an operation period consumer, so as to improve convenience and conversion efficiency of the Dubbo protocol conversion, save human and material resources, and have low cost and high automation degree, and referring to fig. 1, the method may include:
step 101: after the operation of the Dubbo project is triggered, acquiring configuration information of a Dubbo interface according to a plurality of Dubbo XML configuration files;
step 102: scanning a plurality of Dubbo XML configuration files based on instantiation processing to obtain a plurality of Dubbo Reference objects;
step 103: determining a Dubbo Reference object to be replaced from the plurality of Dubbo Reference objects according to the configuration information of the Dubbo interface and the Spring container context of the Dubbo engineering; the Dubbo Reference object is used to consume a bean of the Dubbo protocol type;
step 104: for each Dubbo Reference object to be replaced, converting the Dubbo Reference object to be replaced into a corresponding Feign object according to the configuration information of the Dubbo interface; the Feign object is used for consuming an Http interface;
step 105: and correspondingly replacing the Dubbo Reference object to be replaced by using the generated Feign object.
In the embodiment of the invention, after the operation of the Dubbo project is triggered, the configuration information of the Dubbo interface is obtained according to a plurality of Dubbo XML configuration files; scanning a plurality of Dubbo XML configuration files based on instantiation processing to obtain a plurality of Dubbo Reference objects; determining a Dubbo Reference object to be replaced from the plurality of Dubbo Reference objects according to the configuration information of the Dubbo interface and the Spring container context of the Dubbo engineering; the Dubbo Reference object is used to consume a bean of the Dubbo protocol type; for each Dubbo Reference object to be replaced, converting the Dubbo Reference object to be replaced into a corresponding Feign object according to the configuration information of the Dubbo interface; the Feign object is used for consuming an Http interface; the generated license object is used for correspondingly replacing the Dubbo Reference object to be replaced, compared with the technical scheme that the Dubbo protocol interface is translated into the Http protocol interface through manual modification in the prior art, the conversion of the RPC protocol of a consumer side can be completed in the running Springboot engineering by directly converting the Dubbo Reference object into the corresponding license object, the problem of high development cost caused by the fact that codes need to be developed manually to realize the conversion of the RPC protocol in the prior art is solved, a large amount of codes are not required to be developed, and manpower and material resources are saved; meanwhile, the problem that in the prior art, a person with code development capability can realize RPC protocol conversion to cause difficulty in implementation is solved, the method is simple to use, and does not invade the original code, so that the conversion convenience of the Dubbo protocol is improved, and the conversion efficiency of the Dubbo protocol is improved.
In specific implementation, after the operation of the Dubbo project is triggered, the configuration information of the Dubbo interface is obtained according to the plurality of Dubbo XML configuration files.
In one embodiment, first, a project using a Spring framework is run, and the Spring framework is started to scan the Dubbo XML configuration and the related code involved in the configuration.
In specific implementation, after the operation of the Dubbo engineering is triggered, the configuration information of the Dubbo interface is acquired according to the plurality of Dubbo XML configuration files, and the plurality of Dubbo XML configuration files are scanned based on instantiation processing to obtain a plurality of Dubbo Reference objects.
In one embodiment, based on the instantiation process, multiple Dubbo XML configuration files are scanned, and a Dubbo Reference object is loaded and instantiated from the multiple Dubbo XML configuration files. The BeanPostProcessor class can be invoked during the startup of the Spring framework to perform the above steps.
In specific implementation, after a plurality of Dubbo XML configuration files are scanned based on instantiation processing to obtain a plurality of Dubbo Reference objects, the Dubbo Reference objects to be replaced are determined from the plurality of Dubbo Reference objects according to the configuration information of the Dubbo interface and the Spring container context of the Dubbo engineering; the Dubbo Reference object described above is used to consume a bean of the Dubbo protocol type.
In one embodiment, the configuration information of the Dubbo interface includes: an id parameter value;
determining a Dubbo Reference object to be replaced from a plurality of Dubbo Reference objects according to the configuration information of a plurality of Dubbo interfaces and the Spring container context of the Dubbo engineering, comprising:
and determining the Dubbo Reference object matched with the id parameter value from the plurality of Dubbo Reference objects as the Dubbo Reference object to be replaced according to the id parameter value in the configuration information of the plurality of Dubbo interfaces.
In one embodiment, based on the class of the ApplicationContextAware interface, acquiring the Spring container context of the Dubbo engineering; the class of the ApplicationContextAware interface is used to obtain beans in the Spring container.
In one embodiment, the configuration information of a plurality of Dubbo interfaces is obtained by analyzing the Dubbo XML configuration file, so as to obtain the id and other related information of the Dubbo interfaces, and then the corresponding Dubbo Reference object is taken out from a Spring container through the id; and determining the Dubbo Reference object matched with the id parameter value as the Dubbo Reference object to be replaced.
In specific implementation, after a Dubbo Reference object to be replaced is determined from the plurality of Dubbo Reference objects according to the configuration information of the Dubbo interface and the Spring container context of the Dubbo engineering, the Dubbo Reference object to be replaced is converted into a corresponding Feign object according to the configuration information of the Dubbo interface for each Dubbo Reference object to be replaced; the above Feign object is used for consuming Http interface.
In one embodiment, the configuration information of the Dubbo interface includes: group parameter values, version parameter values, and interface parameter values.
In a specific embodiment, for each Dubbo Reference object to be replaced, according to the configuration information of the Dubbo interface, converting the Dubbo Reference object to be replaced into a corresponding Feign object, including:
for each Dubbo Reference object to be replaced:
adding @ FeignClient annotation for the Dubbo Reference object to be replaced;
adding @ RequestMapping annotation for all the methods of the Dubbo Reference object to be replaced;
splicing a group parameter value, a version parameter value and an interface parameter value in the configuration information of the Dubbo interface to obtain a URL;
adding the URL as a parameter value of the @ RequestMapping annotation;
and obtaining the Feign object corresponding to the Dubbo Reference object to be replaced.
In one embodiment, for each Dubbo Reference object to be replaced, converting the Dubbo Reference object to be replaced into a corresponding Feign object according to the configuration information of the Dubbo interface, which may include:
and (3) converting each Dubbo Reference object to be replaced into a corresponding Feign object by using a byte code enhancement technology according to the configuration information of the Dubbo interface.
In one embodiment, the @ RequestMapping annotation can be added for all the Dubbo Reference objects by adding @ FeignClient and the object method to convert them into Feign objects.
In one embodiment, a technician is required to write a code to generate an interface call URL according to the Dubbo Reference configuration, and the technician is required to write a code result URL to generate a Feign object, so that the group parameter value, the version parameter value and the interface parameter value in the configuration information of the Dubbo interface can be spliced to obtain the URL; and adds the above URL as the parameter value of the @ RequestMapping annotation.
In one embodiment, the Feign object is in the form of a class file for performing RPC protocol conversion.
In specific implementation, aiming at each Dubbo Reference object to be replaced, converting the Dubbo Reference object to be replaced into a corresponding Feign object according to the configuration information of the Dubbo interface; and after the Feign object is used for consuming an Http interface, the generated Feign object is used for correspondingly replacing the Dubbo Reference object to be replaced.
In the embodiment, after the generated Feign object is used to correspondingly replace the to-be-replaced Dubbo Reference object, the subsequent processing of starting the Spring framework is continuously completed, and after the starting is completed, the Dubbo protocol interface call is converted into the Feign interface call of the Http protocol.
In the above embodiment, the Feign object of the Http protocol may be generated at runtime, and the RPC protocol may be converted by an object dynamic replacement method. The conversion from Dubbo protocol interface calling to Http protocol interface calling under a Springboot framework is aimed at, namely the conversion of a RPC protocol of a consumer side is completed in a running Springboot project.
In specific implementation, the method for converting the Dubbo protocol in the operation period provided by the embodiment of the present invention may further include: acquiring Spring container context of Dubbo engineering based on the class of an ApplicationContextTaware interface; the class of the ApplicationContextAware interface is used to obtain beans in the Spring container.
In the above embodiment, a technician needs to write a code to implement a class of the ApplicationContextAware interface, and can obtain a bean in the Spring container through the class, and the technician needs to write the code to obtain the Dubbo Reference object from the Spring container, and further can determine the Dubbo Reference object to be replaced in the context of the Spring container of the Dubbo engineering.
A specific embodiment is given below to illustrate a specific application of the method of the present invention, and in this embodiment, as shown in fig. 2, the following steps may be included:
step 201: starting a Spring project:
firstly, running a project using a Spring framework, scanning a Dubbo XML configuration file and related codes involved in configuration during the starting process of the Spring framework, and loading and instantiating a Dubbo Reference object from the configuration file.
The BeanPostprocessor class is called up in the Spring starting process, and the following subsequent flow is executed;
step 202: obtaining a Dubbo Reference object:
the source data processed in the step is a Dubbo XML configuration file and a Dubbo Reference object loaded in Spring, the Dubbo XML file is analyzed to obtain related information such as the id of Dubbo, and the corresponding Dubbo Reference object to be replaced is taken out from a Spring container through the id;
step 203: generating a Feign object:
the source data processed in the step is the Dubbo Reference information and the objects analyzed in the step 2, and for all Dubbo Reference objects to be replaced, an @ RequestMapping annotation is added on a method for adding an @ FeignClient and the objects, so that the Dubbo Reference information and the objects are converted into Feign objects;
step 204: dubbo Reference substitution:
the source data processed in the step is the Dubbo Reference information obtained in the step 2 and the Feign object obtained in the step 3, and the corresponding Dubbo Reference object is replaced by the newly generated Feign object;
step 205: and after the replacement, continuing to finish the subsequent processing of Spring starting, and after the starting is finished, converting the Dubbo protocol interface call into a Feign interface call of an Http protocol.
In this embodiment, the basic flow of the embodiment of the present invention is to obtain a Dubbo Reference object, generate a Feign object according to the Dubbo configuration file information, and finally replace the Dubbo Reference object with the Feign object. Wherein the core step is the process of generating Feign objects. The embodiment of the invention can complete the conversion of the protocol only by modifying the code and adding a configuration file.
Of course, it is understood that other variations of the above detailed flow can be made, and all such variations are intended to fall within the scope of the present invention.
In the embodiment of the invention, after the operation of the Dubbo project is triggered, the configuration information of the Dubbo interface is obtained according to a plurality of Dubbo XML configuration files; scanning a plurality of Dubbo XML configuration files based on instantiation processing to obtain a plurality of Dubbo Reference objects; determining a Dubbo Reference object to be replaced from the plurality of Dubbo Reference objects according to the configuration information of the Dubbo interface and the Spring container context of the Dubbo engineering; the Dubbo Reference object is used to consume a bean of the Dubbo protocol type; for each Dubbo Reference object to be replaced, converting the Dubbo Reference object to be replaced into a corresponding Feign object according to the configuration information of the Dubbo interface; the Feign object is used for consuming an Http interface; the generated license object is used for correspondingly replacing the Dubbo Reference object to be replaced, compared with the technical scheme that the Dubbo protocol interface is translated into the Http protocol interface through manual modification in the prior art, the conversion of the RPC protocol of a consumer side can be completed in the running Springboot engineering by directly converting the Dubbo Reference object into the corresponding license object, the problem of high development cost caused by the fact that codes need to be developed manually to realize the conversion of the RPC protocol in the prior art is solved, a large amount of codes are not required to be developed, and manpower and material resources are saved; meanwhile, the problem that in the prior art, a person with code development capability can realize RPC protocol conversion to cause difficulty in implementation is solved, the method is simple to use, and does not invade the original code, so that the conversion convenience of the Dubbo protocol is improved, and the conversion efficiency of the Dubbo protocol is improved.
As mentioned above, the current RPC protocol conversion scheme has the following two disadvantages:
1. development and modification costs are high:
the existing scheme needs to develop new codes, all the existing codes are newly developed and replaced by one set, and if the number of interfaces is large, the repeated operation can occupy a large amount of labor cost.
2. The requirement on developers is high:
the current scheme has certain requirements on developers and needs to have the capability of developing the Feign interface call of the Http protocol. A person just touching the item code would have difficulty implementing the solution.
Aiming at the first defect, the embodiment of the invention avoids the development of a large number of codes, and completes the conversion of RPC protocol call only by modifying limited codes and configuration files, so the development cost is low and controllable, and the cost is not uncontrollable due to the number of interface codes;
aiming at the second defect, the embodiment of the invention does not need developers to comprehensively know project codes and master the configuration method of the Feign interface of the Http protocol, only needs to be modified by the configuration of a section of basically fixed codes and a section of fixed contents, and can be configured according to the invention requirement, thereby having lower requirements on personnel and being easy to use.
To sum up, the embodiment of the present invention can convert the Dubbo protocol interface call into the Http protocol interface call for the Springboot project, and dynamically generate the compiled Http protocol interface call Feign object, which is in the form of a class file, by using the bytecode enhancement technology during the running period of the Springboot project to convert the protocol. And loading the generated class file in the running process of the Springboot project, replacing the previous Dubbo interface call, namely converting the consumer into an Http interface call, and requiring no modification on the original service code.
The embodiment of the invention also provides a device for converting the Dubbo protocol in the operating period, which is as described in the following embodiment. Because the principle of the device for solving the problems is similar to the Dubbo protocol conversion method in the operation period, the implementation of the device can refer to the implementation of the Dubbo protocol conversion method in the operation period, and repeated parts are not described again.
An embodiment of the present invention further provides an operation period Dubbo protocol conversion apparatus, configured to perform Dubbo protocol conversion of an operation period consumer, improve convenience and conversion efficiency of the Dubbo protocol conversion, save human and material resources, and have low cost and high automation degree, as shown in fig. 3, the apparatus includes:
the configuration information acquisition module 301 of the Dubbo interface is configured to acquire the configuration information of the Dubbo interface according to the plurality of Dubbo XML configuration files after the operation of the Dubbo project is triggered;
a Dubbo Reference object determining module 302, configured to scan multiple Dubbo XML configuration files based on instantiation processing, to obtain multiple Dubbo Reference objects;
a to-be-replaced Dubbo Reference object determining module 303, configured to determine, according to the configuration information of the Dubbo interface and the Spring container context of the Dubbo engineering, a to-be-replaced Dubbo Reference object from the plurality of Dubbo Reference objects; the Dubbo Reference object is used to consume a bean of the Dubbo protocol type;
a Feign object conversion module 304, configured to, for each Dubbo Reference object to be replaced, convert the Dubbo Reference object to be replaced into a corresponding Feign object according to configuration information of the Dubbo interface; the Feign object is used for consuming an Http interface;
a Feign object replacing module 305, configured to use the generated Feign object to correspondingly replace the Dubbo Reference object to be replaced.
In one embodiment, the configuration information of the Dubbo interface includes: an id parameter value;
the to-be-replaced Dubbo Reference object determination module is specifically configured to:
and determining the Dubbo Reference object matched with the id parameter value from the plurality of Dubbo Reference objects as the Dubbo Reference object to be replaced according to the id parameter value in the configuration information of the plurality of Dubbo interfaces.
In one embodiment, the configuration information of the Dubbo interface includes: group parameter values, version parameter values, and interface parameter values.
In one embodiment, the Feign object conversion module is specifically configured to:
for each Dubbo Reference object to be replaced:
adding @ FeignClient annotation for the Dubbo Reference object to be replaced;
adding @ RequestMapping annotation for all the methods of the Dubbo Reference object to be replaced;
splicing a group parameter value, a version parameter value and an interface parameter value in the configuration information of the Dubbo interface to obtain a URL;
adding the URL as a parameter value of the @ RequestMapping annotation;
and obtaining the Feign object corresponding to the Dubbo Reference object to be replaced.
In one embodiment, the Feign object conversion module is specifically configured to:
and (3) converting each Dubbo Reference object to be replaced into a corresponding Feign object by using a byte code enhancement technology according to the configuration information of the Dubbo interface.
In one embodiment, further comprising:
a Spring container context obtaining module, configured to:
acquiring Spring container context of Dubbo engineering based on the class of an ApplicationContextTaware interface; the class of the ApplicationContextAware interface is used to obtain beans in the Spring container.
A specific embodiment is given below to illustrate a specific application of the apparatus of the present invention, and in this embodiment, as shown in fig. 4, the specific embodiment may include: the device comprises a Dubbo Reference object acquisition module, an applicationContextAware module and a Feign object generation and replacement module.
Each module is specifically described as follows:
the Dubbo Reference obtaining module depends on an applicationContextAware module, after obtaining the Dubbo Reference through the applicationContextAware module, the Dubbo Reference obtaining module generates a Feign object corresponding to the Dubbo Reference through a Feign object generating module, and finally the replacing module completes the replacing process from the Dubbo Reference object to the Feign object, namely, the conversion from Dubbo protocol calling to Http protocol calling is completed.
1) An ApplicationContextAware module (i.e., the Spring container context obtaining module described above):
the context responsible for acquiring the Spring container can be used for acquiring the Dubbo Reference through the container context (context);
2) a Dubbo Reference obtaining module (i.e. the above-mentioned configuration information obtaining module of the Dubbo interface):
the method is responsible for analyzing id, group, version and interface parameter values in the Dubbo Reference XML configuration;
3) a Feign generation module (i.e. the above-mentioned Dubbo Reference object determination module, the Dubbo Reference object determination module to be replaced, and the Feign object conversion module):
the system is responsible for generating URLs through group, version and interface acquired by the Dubbo Reference acquisition module, and the URLs are as follows: < group >/< version >/< interface >; and acquiring a Dubbo Reference interface through id, and adding a Feign annotation to the interface by using the generated URL to construct a Feign object.
4) Replacement module (i.e. the above-mentioned Feign object replacement module):
and the device is responsible for replacing the Dubbo Reference object by the Feign object generated by the Feign generation module.
In this embodiment, the whole process can be chained by the BeanPostprocessor class, and other modules run inside the process and are triggered to run by the process.
Of course, it is to be understood that other variations of the above-described details may be made, and such variations are intended to fall within the scope of the present invention.
Based on the above inventive concept, as shown in fig. 5, the present invention further provides a computer apparatus 500, which includes a memory 510, a processor 520, and a computer program 530 stored in the memory 510 and executable on the processor 520, wherein the processor 520 executes the computer program 530 to implement the runtime Dubbo protocol conversion method.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method for converting the runtime Dubbo protocol is implemented.
An embodiment of the present invention further 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 method for converting the runtime Dubbo protocol is implemented.
In the embodiment of the invention, after the operation of the Dubbo project is triggered, the configuration information of the Dubbo interface is obtained according to a plurality of Dubbo XML configuration files; scanning a plurality of Dubbo XML configuration files based on instantiation processing to obtain a plurality of Dubbo Reference objects; determining a Dubbo Reference object to be replaced from the plurality of Dubbo Reference objects according to the configuration information of the Dubbo interface and the Spring container context of the Dubbo engineering; the Dubbo Reference object is used to consume a bean of the Dubbo protocol type; for each Dubbo Reference object to be replaced, converting the Dubbo Reference object to be replaced into a corresponding Feign object according to the configuration information of the Dubbo interface; the Feign object is used for consuming an Http interface; the generated license object is used for correspondingly replacing the Dubbo Reference object to be replaced, compared with the technical scheme that the Dubbo protocol interface is translated into the Http protocol interface through manual modification in the prior art, the conversion of the RPC protocol of a consumer side can be completed in the running Springboot engineering by directly converting the Dubbo Reference object into the corresponding license object, the problem of high development cost caused by the fact that codes need to be developed manually to realize the conversion of the RPC protocol in the prior art is solved, a large amount of codes are not required to be developed, and manpower and material resources are saved; meanwhile, the problem that in the prior art, a person with code development capability can realize RPC protocol conversion to cause difficulty in implementation is solved, the method is simple to use, and does not invade the original code, so that the conversion convenience of the Dubbo protocol is improved, and the conversion efficiency of the Dubbo protocol is improved.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (15)

1. A method for converting a Dubbo protocol in an operation period is characterized by comprising the following steps:
after the operation of the Dubbo project is triggered, acquiring configuration information of a Dubbo interface according to a plurality of Dubbo XML configuration files;
scanning a plurality of Dubbo XML configuration files based on instantiation processing to obtain a plurality of Dubbo Reference objects;
determining a Dubbo Reference object to be replaced from the plurality of Dubbo Reference objects according to the configuration information of the Dubbo interface and the Spring container context of the Dubbo engineering; the Dubbo Reference object is for consuming a bean of the Dubbo protocol type;
for each Dubbo Reference object to be replaced, converting the Dubbo Reference object to be replaced into a corresponding Feign object according to the configuration information of the Dubbo interface; the Feign object is used for consuming an Http interface;
and correspondingly replacing the Dubbo Reference object to be replaced by using the generated Feign object.
2. The method of claim 1, wherein the configuration information of the Dubbo interface comprises: an id parameter value;
determining a Dubbo Reference object to be replaced from a plurality of Dubbo Reference objects according to the configuration information of a plurality of Dubbo interfaces and the Spring container context of the Dubbo engineering, comprising:
and determining the Dubbo Reference object matched with the id parameter value from the plurality of Dubbo Reference objects as the Dubbo Reference object to be replaced according to the id parameter value in the configuration information of the plurality of Dubbo interfaces.
3. The method of claim 1, wherein the configuration information of the Dubbo interface comprises: group parameter values, version parameter values, and interface parameter values.
4. The method of claim 3, wherein for each Dubbo Reference object to be replaced, converting the Dubbo Reference object to be replaced into a corresponding Feign object according to the configuration information of the Dubbo interface, comprises:
for each Dubbo Reference object to be replaced:
adding @ FeignClient annotation for the Dubbo Reference object to be replaced;
adding @ RequestMapping annotation for all the methods of the Dubbo Reference object to be replaced;
splicing a group parameter value, a version parameter value and an interface parameter value in the configuration information of the Dubbo interface to obtain a URL;
adding the URL as a parameter value of the @ RequestMapping annotation;
and obtaining the Feign object corresponding to the Dubbo Reference object to be replaced.
5. The method of claim 1, wherein for each Dubbo Reference object to be replaced, converting the Dubbo Reference object to be replaced into a corresponding Feign object according to the configuration information of the Dubbo interface, comprising:
and (3) converting each Dubbo Reference object to be replaced into a corresponding Feign object by using a byte code enhancement technology according to the configuration information of the Dubbo interface.
6. The method of claim 1, further comprising:
acquiring Spring container context of Dubbo engineering based on the class of an ApplicationContextTaware interface; the class of the ApplicationContextAware interface is used to obtain beans in the Spring container.
7. An operation period Dubbo protocol conversion apparatus, characterized by comprising:
the device comprises a configuration information acquisition module of the Dubbo interface, a configuration information acquisition module of the Dubbo interface and a configuration information acquisition module of the Dubbo interface, wherein the Dubbo XML configuration files are used for acquiring the configuration information of the Dubbo interface after the operation of the Dubbo project is triggered;
the Dubbo Reference object determining module is used for scanning a plurality of Dubbo XML configuration files based on instantiation processing to obtain a plurality of Dubbo Reference objects;
the Dubbo Reference object determination module to be replaced is used for determining the Dubbo Reference object to be replaced from the plurality of Dubbo Reference objects according to the configuration information of the Dubbo interface and the Spring container context of the Dubbo engineering; the Dubbo Reference object is for consuming a bean of the Dubbo protocol type;
the device comprises a Feign object conversion module, a replacement module and a storage module, wherein the Feign object conversion module is used for converting each Dubbo Reference object to be replaced into a corresponding Feign object according to the configuration information of a Dubbo interface; the Feign object is used for consuming an Http interface;
and the Feign object replacing module is used for correspondingly replacing the Dubbo Reference object to be replaced by using the generated Feign object.
8. The apparatus of claim 7, wherein the configuration information of the Dubbo interface comprises: an id parameter value;
the to-be-replaced Dubbo Reference object determination module is specifically configured to:
and determining the Dubbo Reference object matched with the id parameter value from the plurality of Dubbo Reference objects as the Dubbo Reference object to be replaced according to the id parameter value in the configuration information of the plurality of Dubbo interfaces.
9. The apparatus of claim 7, wherein the configuration information of the Dubbo interface comprises: group parameter values, version parameter values, and interface parameter values.
10. The apparatus of claim 9, wherein the Feign object transformation module is specifically configured to:
for each Dubbo Reference object to be replaced:
adding @ FeignClient annotation for the Dubbo Reference object to be replaced;
adding @ RequestMapping annotation for all the methods of the Dubbo Reference object to be replaced;
splicing a group parameter value, a version parameter value and an interface parameter value in the configuration information of the Dubbo interface to obtain a URL;
adding the URL as a parameter value of the @ RequestMapping annotation;
and obtaining the Feign object corresponding to the Dubbo Reference object to be replaced.
11. The apparatus of claim 7, wherein the Feign object transformation module is specifically configured to:
and (3) converting each Dubbo Reference object to be replaced into a corresponding Feign object by using a byte code enhancement technology according to the configuration information of the Dubbo interface.
12. The apparatus of claim 7, further comprising:
a Spring container context obtaining module, configured to:
acquiring Spring container context of Dubbo engineering based on the class of an ApplicationContextTaware interface; the class of the ApplicationContextAware interface is used to obtain beans in the Spring container.
13. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any one of claims 1 to 6 when executing the computer program.
14. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by a processor, implements the method of any one of claims 1 to 6.
15. A computer program product, characterized in that the computer program product comprises a computer program which, when being executed by a processor, carries out the method of any one of claims 1 to 6.
CN202111425696.9A 2021-11-26 2021-11-26 Dubbo protocol conversion method and device in operation period Pending CN114003348A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111425696.9A CN114003348A (en) 2021-11-26 2021-11-26 Dubbo protocol conversion method and device in operation period

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111425696.9A CN114003348A (en) 2021-11-26 2021-11-26 Dubbo protocol conversion method and device in operation period

Publications (1)

Publication Number Publication Date
CN114003348A true CN114003348A (en) 2022-02-01

Family

ID=79930695

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111425696.9A Pending CN114003348A (en) 2021-11-26 2021-11-26 Dubbo protocol conversion method and device in operation period

Country Status (1)

Country Link
CN (1) CN114003348A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170242664A1 (en) * 2016-02-18 2017-08-24 Line Corporation Method, apparatus, system, and non-transitory computer readable medium for extending at least one function of a package file
CN109587246A (en) * 2018-12-06 2019-04-05 国云科技股份有限公司 Method for realizing micro-service framework integrating free combination of multiple communication protocols
CN112905919A (en) * 2021-03-15 2021-06-04 杭州涂鸦信息技术有限公司 Back-end application calling method and device, computer equipment and readable storage medium
CN113448689A (en) * 2021-07-09 2021-09-28 中国银行股份有限公司 Dubbo protocol conversion device and method in operation period
CN113467972A (en) * 2021-06-30 2021-10-01 广州华多网络科技有限公司 Communication interface construction method, communication interface construction device, computer equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170242664A1 (en) * 2016-02-18 2017-08-24 Line Corporation Method, apparatus, system, and non-transitory computer readable medium for extending at least one function of a package file
CN109587246A (en) * 2018-12-06 2019-04-05 国云科技股份有限公司 Method for realizing micro-service framework integrating free combination of multiple communication protocols
CN112905919A (en) * 2021-03-15 2021-06-04 杭州涂鸦信息技术有限公司 Back-end application calling method and device, computer equipment and readable storage medium
CN113467972A (en) * 2021-06-30 2021-10-01 广州华多网络科技有限公司 Communication interface construction method, communication interface construction device, computer equipment and storage medium
CN113448689A (en) * 2021-07-09 2021-09-28 中国银行股份有限公司 Dubbo protocol conversion device and method in operation period

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
尹吉欢: "Dubbo对Spring Cloud说:来老弟,我要拥抱你", pages 1 - 5, Retrieved from the Internet <URL:https://mp.weixin.qq.com/s/2bihRMYNiLD1Pe352UAlaA> *

Similar Documents

Publication Publication Date Title
US8713514B2 (en) Heterogeneous language data typing without executable regeneration
US20130145352A1 (en) Business process execution language program simulation
CN106547527B (en) JavaScript file construction method and device
CN113326030B (en) A method and device for processing a service request
CN113448689A (en) Dubbo protocol conversion device and method in operation period
US20230401058A1 (en) Semantic functional wrappers of services
CN111966597B (en) Test data generation method and device
CN111506314A (en) Project development method, device, server and medium
CN113971110A (en) Interface testing method, apparatus, device and computer-readable storage medium
Jain et al. Performance analysis of various server hosting techniques
CN108810164A (en) Device supporting SaaS application flow customization and operation as required
CN110175119A (en) A kind of test method of interface, calculates equipment and storage medium at device
CN1744038A (en) A Component Assembly Method Based on Unified Component Package Structure
Dunnweber et al. HOC-SA: A grid service architecture for higher-order components
US8276165B2 (en) Continuation-based runtime callback invocation
CN110704099B (en) Alliance chain construction method and device and electronic equipment
CN114003348A (en) Dubbo protocol conversion method and device in operation period
CN111124386B (en) Animation event processing method, device, equipment and storage medium based on Unity
de Carvalho Silva et al. A platform of scientific workflows for orchestration of parallel components in a cloud of high performance computing applications
CN114490318A (en) Environment management system and method for realizing weak isolation based on bytecode enhancement
Kukla et al. A general and scalable solution for heterogeneous workflow invocation and nesting
CN114115909A (en) Method and device for converting Dubbo protocol in compiling period
CN114675867B (en) A data processing method, device, server and storage medium
CN113986346A (en) Analysis method and device for Dubbo interface implementation class
JP2014229114A (en) OSGi SERVICE REGISTRATION DEVICE, REGISTRATION METHOD AND REGISTRATION PROGRAM

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination