Communication Method, Communication Device, Electronic Device and Medium

By dynamically modifying the protocol type using JavaAgent components on the microservice provider, the high cost and complexity of multi-protocol communication in the microservice system is solved, and efficient multi-protocol communication is achieved.

CN115834734BActive Publication Date: 2025-07-08杭州米络星科技(集团)有限公司
View PDF 1 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The existing microservices support multi-protocol communication methods with high cost and low efficiency, and lead to high complexity of microservice systems.

Method used

By setting up JavaAgent components on the service provider, dynamically modifying and supporting multiple protocol types, using the packet header of the requested data packet to determine the target protocol type, and performing deserialization and serialization operations to achieve communication between different clusters.

Benefits of technology

It reduces the transformation cost of original microservices, improves development efficiency, reduces the complexity of the microservice system, and does not require additional proxy services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115834734B_ABST
    Figure CN115834734B_ABST
Patent Text Reader

Abstract

The present invention provides a communication method, a communication device, an electronic device and a medium. The method is applied to a service provider, and a JavaAgent component is provided on the service provider. The JavaAgent component is used to dynamically modify multiple protocol types supported by the service provider. The method includes: receiving a request data packet sent by a service consumer; determining a target protocol type based on the header of the request data packet, and performing a deserialization operation on the request data packet based on the target protocol type to obtain request parameters; processing the request parameters to obtain a processing result, and performing a serialization operation on the processing result and then returning it to the service consumer. The present invention reduces the development cost, improves the development efficiency, and at the same time reduces the complexity of the microservice system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet communication technologies, and in particular, to a communication method, a communication device, an electronic device, and a medium. Background Art

[0002] With the rapid development of microservices, there are also many mature solutions for microservice communication methods and protocols, and they are constantly updated and iterated. Generally, only one set of communication protocols is used for communication in a set of microservice clusters. However, due to technology upgrades and iterations, as well as the integration of different services, it is necessary to establish communication between different clusters using different protocols, which will result in the problem that services in the new cluster need to support multiple sets of communication protocols. Currently, the conventional methods for microservices to support multi-protocol communication include: (1) making hard-coded modifications to the original service to add support for new protocols. However, the compatibility of different communication protocols is complex, the learning cost is high, and at the same time, all the original services need to be transformed, resulting in high transformation costs and large workloads. (2) Adding a proxy service that supports the new service protocol and forwards requests to the original service for processing. However, this method increases the communication link, increases communication latency and maintenance costs. At the same time, the proxy service needs to support multiple protocols simultaneously, and the compatibility of different communication protocols is complex. In summary, the existing methods for microservices to support multi-protocol communication have high development costs, low efficiency, and high complexity of the microservice system. Summary of the Invention

[0003] In view of this, the purpose of the present invention is to provide a communication method, a communication device, an electronic device, and a medium, which reduce the development cost, improve the development efficiency, and at the same time reduce the complexity of the microservice system.

[0004] To achieve the above purpose, the technical solutions adopted in the embodiments of the present invention are as follows:

[0005] In a first aspect, an embodiment of the present invention provides a communication method, which is applied to a service provider. The service provider is provided with a JavaAgent component, and the JavaAgent component is used to dynamically modify multiple protocol types supported by the service provider. The method includes: receiving a request data packet sent by a service consumer; determining a target protocol type based on the packet header of the request data packet, and performing a deserialization operation on the request data packet based on the target protocol type to obtain request parameters; processing the request parameters to obtain a processing result, and performing a serialization operation on the processing result and then returning it to the service consumer.

[0006] In an implementation manner, after performing a deserialization operation on the request data packet based on the target protocol type to obtain request parameters, the method further includes: adding a protocol type flag corresponding to the target protocol type to the request parameters.

[0007] In one embodiment, the processing result includes a protocol type tag; returning the processed result to the service consumer after serialization operations includes: reading the protocol type tag in the processing result; determining a packet encapsulation method based on the protocol type tag, and performing serialization operations on the processing result based on the packet encapsulation method to obtain a processed result data packet; returning the processed result data packet to the service consumer.

[0008] In one embodiment, before receiving a request data packet sent by the service consumer, the method further includes: reading configuration information of the service provider; wherein the configuration information includes: multiple protocol types and configuration information of the registration center; determining a proxy data packet of the JavaAgent component based on the configuration information, and storing the proxy data packet in a preset directory of the server.

[0009] In one embodiment, before receiving a request data packet sent by the service consumer, the method further includes: sending service metadata provided by the service provider to the registration center to provide service information to the service consumer.

[0010] In a second aspect, an embodiment of the present invention provides a communication device. The device is applied to the service provider, and the service provider is provided with a JavaAgent component, and the JavaAgent component is used to dynamically modify multiple protocol types supported by the service provider; the device includes: a data acquisition module, configured to receive a request data packet sent by the service consumer; a packet unpacking module, configured to determine a target protocol type based on the packet header of the request data packet, and perform deserialization operations on the request data packet based on the target protocol type to obtain request parameters; a packet encapsulation module, configured to process the request parameters to obtain a processing result, and perform serialization operations on the processing result and then return it to the service consumer.

[0011] In one embodiment, the device further includes: a tagging module, configured to add a protocol type tag corresponding to the target protocol type to the request parameters.

[0012] In one embodiment, the processing result includes a protocol type tag; the packet encapsulation module is further configured to: read the protocol type tag in the processing result; determine a packet encapsulation method based on the protocol type tag, and perform serialization operations on the processing result based on the packet encapsulation method to obtain a processed result data packet; return the processed result data packet to the service consumer.

[0013] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the steps of the method according to any one of the first aspects provided above.

[0014] Fourthly, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, it executes the steps of the method according to any one of the above-mentioned first aspects.

[0015] The embodiments of the present invention bring the following beneficial effects:

[0016] The above-mentioned communication method, communication device, electronic device and medium provided by the embodiments of the present invention are applied to a service provider side, and a JavaAgent component is set on the service provider side. The JavaAgent component is used to dynamically modify various protocol types supported by the service provider side; the service provider side receives a request data packet sent by a service consumer side; then, based on the header of the request data packet, a target protocol type is determined, and an anti-serialization operation is performed on the request data packet based on the target protocol type to obtain request parameters; finally, the request parameters are processed to obtain a processing result, and the processing result is serialized and then returned to the service consumer side. Through the JavaAgent component, the above method can dynamically modify the protocol types supported by the service provider side without intruding into the original microservice engineering code, thereby reducing the transformation of the original microservice, reducing the opening cost, and improving the development efficiency; during the communication process, the service provider side can determine the target protocol type according to the header of the request data packet sent by the service consumer side, and communicate with the service consumer side based on the target protocol type, so as to realize communication between different clusters of different protocols; at the same time, the above method does not require adding a new proxy service, reducing the complexity of the microservice system.

[0017] Other features and advantages of the present invention will be described in the following description of the specification, and part of them will become obvious from the description of the specification, or be understood by implementing the present invention. The objectives and other advantages of the present invention are achieved and obtained by the structures specifically pointed out in the specification, claims and drawings.

[0018] To make the above-mentioned objectives, features and advantages of the present invention more obvious and understandable, the following specific preferred embodiments are given, and in conjunction with the accompanying drawings, the detailed description is as follows. Description of the Drawings

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

[0020] Figure 1 It is a flowchart of a communication method provided by an embodiment of the present invention;

[0021] Figure 2 Schematic diagram of a multi - protocol adaptive communication based on JavaAgent provided by an embodiment of the present invention;

[0022] Figure 3 Schematic diagram of the structure of a communication device provided by an embodiment of the present invention;

[0023] Figure 4 Schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Detailed implementation manners

[0024] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Apparently, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0025] Conventional methods for microservices to support multi - protocol communication include: (1) making hard - coded modifications to the original service to add support for new protocols. However, the compatibility of different communication protocols is complex, with a high learning cost. At the same time, all original services need to be transformed, resulting in high transformation costs and large workloads. (2) Adding a proxy service that supports new service protocols and forwards requests to the original service for processing. However, this method increases the communication link length, adding communication latency and maintenance costs. At the same time, the proxy service needs to support multiple protocols simultaneously, and the compatibility of different communication protocols is complex. In summary, the existing methods for microservices to support multi - protocol communication have high development costs, low efficiency, and high complexity of the microservice system.

[0026] Based on this, a communication method, a communication device, an electronic device and a medium provided by the embodiments of the present invention can reduce development costs, improve development efficiency, and at the same time reduce the complexity of the microservice system.

[0027] To facilitate the understanding of this embodiment, a communication method disclosed in the embodiments of the present invention will be introduced in detail first. This method can be executed by an electronic device, such as a smart phone, a computer, a tablet computer, etc. This method is applied to the service provider side, and a JavaAgent component is set on the service provider side. The JavaAgent component is used to dynamically modify various protocol types supported by the service provider side. Specifically, JavaAgent is a technology introduced in JDK1.5 that can dynamically modify Java bytecode. After a Java class is compiled, it forms bytecode that is executed by the Java Virtual Machine (JVM). Before the JVM executes this bytecode, the bytecode information is obtained, and these bytecodes are modified through a bytecode converter to complete some additional functions. Based on this, in the embodiments of the present invention, a JavaAgent project can be created on the service provider side to implement the function of automatically adapting to the new microservice communication protocol.

[0028] See Figure 1 The flowchart of a communication method shown in the figure schematically shows that this method mainly includes the following steps S101 to step S103:

[0029] Step S101: Receive the request data packet sent by the service consumer side.

[0030] In one implementation, the service provider side can register with the registration center and provide the service metadata provided by the service provider side to the registration center to provide service information to the service consumer side; the service consumer side can subscribe to the required service information from the registration center, and the registration center will notify the service consumer side to update the service metadata when the service metadata on the service provider side changes. The service consumer side parses the service metadata and communicates with the service provider side using the relevant communication protocol. Specifically, the service consumer side first assembles the request parameters and performs a serialization encoding operation (i.e., packet encapsulation operation) on the request parameters according to the requirements of the communication protocol to obtain the request data packet. Then, according to the information such as the IP address and port in the service metadata, the request data packet is sent to the service consumer side according to the Transmission Control Protocol (TCP).

[0031] Step S102: Determine the target protocol type based on the packet header of the request data packet, and perform a deserialization operation on the request data packet based on the target protocol type to obtain the request parameters.

[0032] In one embodiment, after receiving a request data packet, the service consumer end can determine the protocol type by the packet header of the request data packet, determine the communication protocol used by the service consumer end, that is, determine the target protocol type; then, according to different target protocol types, different unpacking methods are adopted to perform deserialization operations on the request data packet to obtain the request parameters of the service consumer end.

[0033] Step S103: Process the request parameters to obtain a processing result, and perform serialization operations on the processing result and then return it to the service consumer end.

[0034] In one embodiment, the service consumer end can send the request parameters obtained from the deserialization operation to the corresponding interface method for processing and obtain a processing result; then, according to the packet method corresponding to the target protocol type, perform serialization operations on the processing result and then return the processing result to the service consumer end.

[0035] The above communication method provided by the embodiments of the present invention, through the JavaAgent component, can dynamically modify the protocol type supported by the service provider end with zero intrusion into the original microservice engineering code, thereby reducing the transformation of the original microservice, reducing the opening cost, and improving the development efficiency; during the communication process, the service provider end can determine the target protocol type according to the packet header of the request data packet sent by the service consumer end and implement communication with the service consumer end based on the target protocol type, thereby enabling communication between different clusters of different protocols; at the same time, the above method does not require adding a new proxy service, reducing the complexity of the microservice system.

[0036] In order to distinguish the request parameters corresponding to different protocol types and avoid communication errors, in the above method provided by the embodiments of the present invention, after performing deserialization operations on the request data packet based on the target protocol type to obtain the request parameters, it further includes: adding a protocol type mark corresponding to the target protocol type to the request parameters. In specific implementation, the service consumer end performs deserialization operations on the request data packet according to the unpacking method corresponding to the target protocol type to obtain the request parameters of the service consumer end, and adds a protocol type mark corresponding to the target protocol type to the request parameters.

[0037] Further, the processing result obtained by processing the request parameters obtained from the deserialization operation by the service consumer end includes the corresponding protocol type mark. When performing serialization operations on the processing result and then returning it to the service consumer end, the following methods can be adopted including but not limited to: first, read the protocol type mark in the processing result; then, determine the packet method based on the protocol type mark, and perform serialization operations on the processing result based on the packet method to obtain a processing result data packet; finally, return the processing result data packet to the service consumer end.

[0038] In specific implementation, the service consumer end can read the protocol type flag in the return result, find the corresponding different packet encapsulation methods according to the protocol type flag, and then perform serialization operations on the return result according to the packet encapsulation methods to obtain a processed result data packet and return it to the consumer of the service consumer end.

[0039] In one implementation manner, in order to implement communication between different clusters using different protocols, a JavaAgent component needs to be pre-created in the embodiments of the present invention, that is, a JavaAgent project is created, which specifically includes:

[0040] (1) Read the configuration information of the service provider end; wherein, the configuration information includes: various protocol types and the configuration information of the registration center.

[0041] In specific implementation, the configuration information of the service provider end can be read. The configuration information includes: various protocol types, specifically including the protocol types supported by the original service, the new protocol types that need to be added, and the relevant configuration information of the corresponding registration center.

[0042] (2) Determine the proxy data packet of the JavaAgent component based on the configuration information, and store the proxy data packet in a preset directory of the server.

[0043] In specific implementation, according to the configuration information, through the java SPI mechanism, the original service Registry process can be re-determined, the process of registering with the registration center corresponding to the new protocol type can be added, and through the java SPI mechanism, the unpacking process and packet encapsulation process of the service provider end can be re-determined. The specific unpacking process and packet encapsulation process include:

[0044] (a) After receiving the request data packet, judge the protocol type through the packet header;

[0045] (b) According to different protocol types, use different unpacking methods to perform deserialization operations on the request data packet to obtain request parameters, and add protocol type flags to the request parameters;

[0046] (c) Transmit the request parameters obtained from the deserialization operation to the corresponding interface for processing, and obtain a processing result, wherein the processing result contains a protocol type flag;

[0047] (d) Read the protocol type flag in the return result, find the corresponding different packet encapsulation methods according to the protocol type flag, perform serialization operations on the processing result, and return the processing result to the consumer.

[0048] Further, the above services can be packaged into a corresponding auto-protocols-agent-1.0.0.jar package (i.e., the proxy data packet), and the auto-protocols-agent-1.0.0.jar package can be placed in the specified directory (i.e., the preset directory) / data / agent / of the server. There is an auto-protocols-config.properties file in this directory, which contains: the protocol types supported by the original service, the new protocol types to be added, and the relevant configuration information of the corresponding registry.

[0049] Based on the above configuration, when starting the service provider, add the relevant agent configuration: -javaagent: / data / agent / auto-protocols-agent-1.0.0.jar, and the zero-intrusion multi-protocol adaptation function can be realized in the original microservice, so as to realize the communication between different clusters using different protocols.

[0050] For ease of understanding, the embodiment of the present invention provides a schematic diagram of multi-protocol adaptive communication based on JavaAgent, see Figure 2 As shown in the figure, an agent is set on the service provider side. The service consumer 1, the registry 1, and the service provider can form a microservice cluster based on Protocol 1, and the service consumer 2, the registry 2, and the service provider can form a microservice cluster based on Protocol 2.

[0051] The service provider registers with the registry 1 and the registry 2 respectively, and sends the service metadata to the registry 1 and the registry 2 respectively; the service consumer 1 subscribes to the required service information from the registry 1. At the same time, the registry 1 will notify the service consumer 1 to update the service metadata when the service provider changes the service metadata; the service consumer 2 subscribes to the required service information from the registry 2. At the same time, the registry 2 will notify the service consumer 2 to update the service metadata when the service provider changes the service metadata.

[0052] When the service consumer 1 invokes relevant service information from the service provider, the service consumer 1 can perform serialization encoding operations on the request parameters according to the requirements of Protocol 1 to obtain Request Packet 1, and send Request Packet 1 to the service provider; the service provider can determine the protocol type adopted according to the packet header of Request Packet 1 through the agent as Protocol 1, and then perform deserialization operations on Request Packet 1 according to the unpacking method corresponding to Protocol 1 to obtain the request parameters of the service consumer 1, and add the protocol type mark of Protocol 1; then, after processing the request parameters, a processing result is obtained (the processing result includes the protocol type mark of Protocol 1); finally, read the protocol type mark in the processing result, and determine the packet encapsulation method as the packet encapsulation method corresponding to Protocol 1 according to the protocol type mark. After performing serialization operations on the processing result using the packet encapsulation method corresponding to Protocol 1, the processing result is returned to the service consumer 1 to realize the communication between the service consumer 1 and the service provider.

[0053] When the service consumer 2 invokes relevant service information from the service provider, the service consumer 2 can perform serialization encoding operations on the request parameters according to the requirements of Protocol 2 to obtain Request Packet 2, and send Request Packet 2 to the service provider; the service provider can determine the protocol type adopted according to the packet header of Request Packet 2 through the agent as Protocol 2, and then perform deserialization operations on Request Packet 2 according to the unpacking method corresponding to Protocol 2 to obtain the request parameters of the service consumer 2, and add the protocol type mark of Protocol 2; then, after processing the request parameters, a processing result is obtained (the processing result includes the protocol type mark of Protocol 2); finally, read the protocol type mark in the processing result, and determine the packet encapsulation method as the packet encapsulation method corresponding to Protocol 2 according to the protocol type mark. After performing serialization operations on the processing result using the packet encapsulation method corresponding to Protocol 2, the processing result is returned to the service consumer 2 to realize the communication between the service consumer 2 and the service provider.

[0054] The above method provided by the embodiments of the present invention realizes the function of zero intrusion into the original microservice project code and automatic adaptation to new microservice protocols by only writing a protocol adaptation JavaAgent, which improves the ability of a microservice project to quickly support multi-microservice communication, reduces the workload of modifying and developing the original service, improves development efficiency, and at the same time reduces the complexity of the microservice system and improves maintainability; in addition, when the protocol adaptation JavaAgent is complete enough, only by adding a reference to the JavaAgent in the startup parameters, the ability of the microservice project to dynamically add new protocols can be realized. At present, the JavaAgent supports protocol adaptation for SpringCloud, Dubbo, DubboX, SOFARPC, and KKRPC, and has a wide range of applications.

[0055] For the foregoing communication method, an embodiment of the present invention further provides a communication device, which is applied to a service provider end. The service provider end is provided with a JavaAgent component, and the JavaAgent component is used to dynamically modify multiple protocol types supported by the service provider end; see Figure 3 The schematic structural diagram of a communication device shown in

[0056] A data acquisition module 301, configured to receive a request data packet sent by a service consumer end;

[0057] A packet unpacking module 302, configured to determine a target protocol type based on the packet header of the request data packet, and perform a deserialization operation on the request data packet based on the target protocol type to obtain request parameters;

[0058] A packet packing module 303, configured to process the request parameters to obtain a processing result, and perform a serialization operation on the processing result and then return it to the service consumer end.

[0059] The above communication device provided by the embodiment of the present invention, through the JavaAgent component, can zero-invade the original microservice engineering code, dynamically modify the protocol types supported by the service provider end, thereby reducing the transformation of the original microservice, reducing the opening cost, and improving the development efficiency; during the communication process, the service provider end can determine the target protocol type according to the packet header of the request data packet sent by the service consumer end, and realize communication with the service consumer end based on the target protocol type, so as to realize communication between different clusters of different protocols; at the same time, the above device does not need to add a new proxy service, reducing the complexity of the microservice system.

[0060] In an implementation manner, the above device further includes: a marking module, configured to add a protocol type mark corresponding to the target protocol type to the request parameters.

[0061] In an implementation manner, the processing result includes a protocol type mark; specifically, the packet packing module 303 is further configured to: read the protocol type mark in the processing result; determine a packet packing method based on the protocol type mark, and perform a serialization operation on the processing result based on the packet packing method to obtain a processing result data packet; return the processing result data packet to the service consumer end.

[0062] In an implementation manner, the above device further includes a configuration module, configured to: read the configuration information of the service provider end; where the configuration information includes: multiple protocol types and configuration information of a registration center; determine a proxy data packet of the JavaAgent component based on the configuration information, and store the proxy data packet in a preset directory of the server.

[0063] In one embodiment, the above device further includes a registration module, configured to: send service metadata provided by the service provider to a registration center to provide service information to the service consumer.

[0064] It should be noted that the device provided in the embodiment of the present invention has the same implementation principle and technical effects as those in the foregoing method embodiment. For a brief description, for the parts not mentioned in the device embodiment, reference may be made to the corresponding content in the foregoing method embodiment.

[0065] The embodiment of the present invention also provides an electronic device. Specifically, the electronic device includes a processor and a storage device; a computer program is stored on the storage device, and when the computer program is run by the processor, it executes the method according to any one of the above embodiments.

[0066] Figure 4 FIG. 10 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. The electronic device 100 includes: a processor 40, a memory 41, a bus 42, and a communication interface 43. The processor 40, the communication interface 43, and the memory 41 are connected through the bus 42. The processor 40 is configured to execute an executable module stored in the memory 41, such as a computer program.

[0067] Among them, the memory 41 may include a high-speed random access memory (RAM, Random Access Memory), and may also include a non-volatile memory, such as at least one disk memory. Through at least one communication interface 43 (which may be wired or wireless), a communication connection is established between the system network element and at least one other network element, and the Internet, a wide area network, a local area network, a metropolitan area network, etc. can be used.

[0068] The bus 42 may be an ISA bus, a PCI bus, an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 4 only a bidirectional arrow is used in FIG. 10, but it does not mean that there is only one bus or one type of bus.

[0069] Among them, the memory 41 is used to store a program. After receiving an execution instruction, the processor 40 executes the program. The method executed by the device defined by the flow process disclosed in any one of the foregoing embodiments of the present invention can be applied to the processor 40 or implemented by the processor 40.

[0070] The processor 40 may be an integrated circuit chip with the ability to process signals. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in the processor 40 or the instructions in the form of software. The above-mentioned processor 40 may be a general-purpose processor, including a central processing unit (CPU for short), a network processor (NP for short), etc.; it may also be a digital signal processor (DSP for short), an application specific integrated circuit (ASIC for short), a field-programmable gate array (FPGA for short), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute various methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present invention can be directly embodied as being executed and completed by the hardware decoding processor, or executed and completed by the combination of the hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory 41, and the processor 40 reads the information in the memory 41 and combines its hardware to complete the steps of the above method.

[0071] The computer program product of the readable storage medium provided by the embodiments of the present invention includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the methods described in the foregoing method embodiments. For the specific implementation, reference can be made to the foregoing method embodiments and will not be elaborated herein.

[0072] If the above-mentioned functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.

[0073] Finally, it should be noted that the above-mentioned embodiments are only specific implementation manners of the present invention, used to illustrate the technical solutions of the present invention, rather than limiting it. The protection scope of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the technical field can still modify the technical solutions recorded in the foregoing embodiments, or easily conceive of changes, or perform equivalent replacements for some of the technical features; and these modifications, changes, or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. A communication method, characterized in that, The method is applied to a service provider, and a JavaAgent component is provided on the service provider. The JavaAgent component is used to dynamically modify multiple protocol types supported by the service provider. The method includes: Receiving a request data packet sent by a service consumer; Determining a target protocol type based on the header of the request data packet, and performing a deserialization operation on the request data packet based on the target protocol type to obtain request parameters; Processing the request parameters to obtain a processing result, and performing a serialization operation on the processing result and then returning it to the service consumer; Before receiving the request data packet sent by the service consumer, the method further includes: reading the configuration information of the service provider; wherein, the configuration information includes: multiple protocol types and configuration information of a registration center; determining a proxy data packet of the JavaAgent component based on the configuration information, and storing the proxy data packet in a preset directory of the server; wherein, according to the configuration information, through the java SPI mechanism, re-determining the original service Registry process, adding a process of registering to the registration center corresponding to the new protocol type, and through the java SPI mechanism, re-determining the unpacking process and packet encapsulation process of the service provider.

2. The communication method according to claim 1, wherein After performing a deserialization operation on the request data packet based on the target protocol type to obtain request parameters, the method further includes: Adding a protocol type flag corresponding to the target protocol type to the request parameters.

3. The communication method according to claim 2, characterized in that The protocol type flag is included in the processing result; performing a serialization operation on the processing result and then returning it to the service consumer includes: Reading the protocol type flag in the processing result; Determining a packet encapsulation method based on the protocol type flag, and performing a serialization operation on the processing result based on the packet encapsulation method to obtain a processed result data packet; Returning the processed result data packet to the service consumer.

4. The communication method according to claim 1, wherein Before receiving the request data packet sent by the service consumer, the method further includes: Sending service metadata provided by the service provider to the registration center to provide service information to the service consumer.

5. A communication device, characterized in that, The device is applied to a service provider, and a JavaAgent component is provided on the service provider. The JavaAgent component is used to dynamically modify multiple protocol types supported by the service provider; The device includes: A data acquisition module, configured to receive a request data packet sent by a service consumer; An unpacking module, configured to determine a target protocol type based on the header of the request data packet, and perform a deserialization operation on the request data packet based on the target protocol type to obtain request parameters; A packet encapsulation module, configured to process the request parameters to obtain a processing result, and perform a serialization operation on the processing result and then return it to the service consumer; The device further includes: a configuration module, configured to read the configuration information of the service provider; wherein, the configuration information includes: configuration information of multiple protocol types and a registry center; determine a proxy data packet of the JavaAgent component based on the configuration information, and store the proxy data packet in a preset directory of the server; wherein, according to the configuration information, re-determine the original service Registry process through the java SPI mechanism, add a process of registering to the registry center corresponding to the new protocol type, and re-determine the unpacking process and packet encapsulation process of the service provider through the java SPI mechanism.

6. The communication device according to claim 5, wherein The device further includes: a marking module, configured to add a protocol type mark corresponding to the target protocol type to the request parameters.

7. The communication device according to claim 6, wherein The processing result includes the protocol type mark; the packet encapsulation module is further configured to: Read the protocol type mark in the processing result; Determine a packet encapsulation method based on the protocol type mark, and perform a serialization operation on the processing result based on the packet encapsulation method to obtain a processed result data packet; Return the processed result data packet to the service consumer.

8. An electronic device, characterized in that, It includes a processor and a memory, the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the steps of the method according to any one of claims 1 to 4.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is run by the processor, it executes the steps of the method according to any one of claims 1 to 4 above.

Citation Information

Patent Citations

  • Data processing method and device of micro-service system and electronic equipment

    CN114942856A