Microservice framework gateway processing method, protocol conversion gateway, electronic equipment and storage medium

By introducing protocol conversion gateway and asynchronous coroutine high concurrency mode into the microservice framework, the problem of inconsistent communication protocols between different microservices is solved, and efficient communication between microservices and flexible allocation of resources is achieved.

CN119996381AActive Publication Date: 2025-05-13THE QUARTERMASTER RES INST OF THE GENERAL LOGISTICS DEPT OF THE CPLA
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411314373.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-20
Publication Date
2025-05-13
Estimated Expiration
2044-09-20

AI Technical Summary

Technical Problem

Under the microservice framework, different microservices use network communication protocols inconsistent due to different development times, resulting in the inability to communicate and call each other between microservices.

Method used

Provides a microservice framework gateway processing method, which realizes service call request processing in high concurrency mode of asynchronous coroutine through protocol conversion gateway. This method includes registration information registration, issuance of protocol format configuration files and protocol conversion configuration files, parsing of service call requests and protocol conversion, ensuring that the communication protocols between different microservices are consistent.

Benefits of technology

It realizes flexible allocation and utilization of service resources under different technologies and environments, improves communication efficiency between microservices, reduces the construction cost of newly built services, and avoids the problem of protocol incompatibility between microservices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119996381A_ABST
    Figure CN119996381A_ABST
Patent Text Reader

Abstract

The invention relates to a micro-service framework gateway processing method. The method comprises the following steps that: a service registers registration information of the service to a registration center; a protocol format configuration file and a protocol conversion configuration file used by the service are published to a configuration center, and when the first micro-service needs to use a second micro-service function, a calling request for the second micro-service is sent to a protocol conversion gateway; the protocol conversion gateway receives the service calling request and performs subsequent processing on the service calling request in an asynchronous coroutine high-concurrency mode; judging whether the communication protocols of the request source service and the target service are consistent or not; and if not, converting the communication protocol used by the service calling request into the communication protocol of the target service, and sending the service calling request using the communication protocol of the target service to the target service to complete service calling. According to the invention, the expandability and flexibility of system development can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a microservice framework gateway processing method, a protocol conversion gateway, an electronic device and a storage medium. Background Art

[0002] The microservice framework makes applications more modular, easier to develop and maintain, and each microservice runs in a different process. They are isolated from each other, and the entire system will not be unavailable due to a failure in one of the service processes.

[0003] The gateway is a key component in the microservice architecture. Its main function is to encapsulate the interfaces of all microservices and provide a unified access interface to the outside world. It forwards client requests to the corresponding microservice instances through routing requests, and repackages the responses returned by the microservices into a format that meets the client's expectations. Internally, the gateway can also serve as the entry point for microservices, managing and monitoring the status and performance of microservices by registering them with the gateway center. In this way, the gateway can control all traffic and provide a centralized control point for microservices, making the entire application easier to manage and monitor.

[0004] The gateway needs to perform protocol identification on the request sent by the client to determine the protocol type used by the client. According to the protocol type used by the client, the gateway converts the request sent by the client into the protocol type supported by the backend service to complete the request proxy. For different types of data sources, you can use microservices with different technical routes to query and access according to the format and characteristics of the data itself. For example, you can query the relational database Mysql through the lightweight FLask backend framework, or transmit time-series data with large data scale through the high-compression gRPC protocol, and you can also access the non-relational database MongoDB through the Spring framework.

[0005] In the prior art, under the microservice framework, there is a problem that different microservices may use different network communication protocols due to different development times, resulting in different microservices being unable to communicate and call each other. Summary of the invention

[0006] In order to solve the above technical problems, the present invention provides a microservice framework gateway processing method, a protocol conversion gateway, an electronic device and a storage medium, wherein:

[0007] A microservice framework gateway processing method comprises the following steps:

[0008] Step S101: The business processing microservice in the business system registers the registration information to the registration center;

[0009] Step S102: The business system administrator publishes the protocol format configuration file and the protocol conversion configuration file used by the business processing microservice to the configuration center;

[0010] Step S103: When the first business processing microservice needs to use the function of the second business processing microservice, the first business processing microservice sends a service call request for the second business processing microservice to the protocol conversion gateway, wherein the first business processing microservice is the source service of the service call request, and the second business processing microservice is the target service of the service call request, and the service call request uses the communication protocol used by the source service;

[0011] Step S104: The protocol conversion gateway receives the service call request and performs subsequent processing on the service call request in an asynchronous coroutine high concurrency mode;

[0012] Step S105: the protocol conversion gateway parses the service call request, obtains the target service, and obtains the communication protocol configuration of the source service and the target service of the service call request from the configuration center;

[0013] Step S106: The protocol conversion gateway determines whether the communication protocol used by the source service and the target service of the service call request is consistent;

[0014] Step S107: if the communication protocols used by the source service of the service call request are inconsistent with those used by the target service, the communication protocol used by the service call request is converted into the communication protocol used by the target service by using the protocol conversion gateway; if the communication protocols used by the source service of the service call request are consistent with those used by the target service, the service call request is not processed;

[0015] Step S108: Send the service call request to the target service to complete the service call.

[0016] Furthermore, the step S101 specifically includes: the business processing microservice sends registration information to the registration center, the registration center writes the received new registration information into the registration table, and deletes the old registration information of the business processing microservice, so that the business processing microservice can be discovered and accessed by other business processing microservices, wherein a business processing microservice has multiple microservice instances, different instances of the same business processing microservice have the same IP address and different port numbers, any microservice instance can implement all functions of the business processing microservice, and the registration center records the registration information of all business processing microservices in the entire business system.

[0017] Furthermore, the step S101 further includes:

[0018] For successfully registered business processing microservices, the registration center regularly performs health checks on their microservice instances. Health checks refer to checking the relevant parameter indicators of the running status of the microservice instances. Microservice instances that pass the check provide service discovery for other business processing microservices. Microservice instances that fail the check will automatically go offline and delete the relevant registration information from the registration center. The business system administrator manually deregisters the business processing microservices and updates the registration information of the business processing microservices as needed.

[0019] Furthermore, in step S102, the protocol format configuration file and the protocol conversion configuration file between different communication protocols in the configuration center are published in XML format and can be manually configured; the protocol format configuration file record includes the protocol name, basic protocol parameters and parameter types, protocol transmission data encapsulation format, and protocol transmission data type; the protocol conversion configuration file record includes the mapping relationship between different data types between two specified communication protocols and the protocol processing function name that implements the conversion function of the two specified communication protocols.

[0020] A protocol conversion gateway, comprising:

[0021] A request receiving module is used to obtain a service call request from a client or a business processing microservice deployed in a microservice cluster, wherein the service call request uses the communication protocol used by its source service;

[0022] Communication module, used to realize concurrent processing of service call requests;

[0023] The protocol parsing module is used to parse the received service call request and obtain the source service and target service of the service call request;

[0024] A protocol judgment module is used to judge whether the communication protocol used by the currently processed service call request is the same as the communication protocol used by the target service. When the communication protocol used by the service call request is the same as the communication protocol used by the target service, the service call request is directly released;

[0025] A protocol conversion module, used to convert the communication protocol used in the service call request into the communication protocol used by the target service when the communication protocol used in the service call request is different from the communication protocol used by the target service;

[0026] The request forwarding module is used to send the service call request to the target service.

[0027] Furthermore, the communication module is also used to implement the following steps: using the asynchronous coroutine high concurrency mode to concurrently process call requests, when the protocol conversion gateway receives a service call request, enabling an asynchronous coroutine to process the service call request, avoiding blocking the main thread while maintaining responsiveness to other service call requests, wherein a coroutine pool is used to maintain each coroutine that processes the service call request, a mutex class is used to control concurrent access, an event circulator is used to schedule and manage all coroutines and asynchronous IO events, and notifies the relevant coroutines to continue execution when an IO event occurs.

[0028] Furthermore, the protocol conversion module includes:

[0029] A configuration reading unit, used to obtain a protocol format configuration file and a protocol conversion configuration file of a communication protocol used by a source service and a target service of a service call request, read the protocol format configuration file of the communication protocol used by the source service of the service call request, the protocol format configuration file of the communication protocol used by the target service of the service call request, and the protocol conversion configuration files of the two protocols from a configuration center, and obtain the protocol formats used by the two services and mapping rules for the two services;

[0030] A conversion judgment unit, used to judge whether the protocol processor can complete the conversion of the protocol used by the service call request, and whether there is a protocol processing function in the protocol processor that takes the protocol format configuration file of the communication protocol used by the source service of the service call request and the protocol format configuration file of the communication protocol used by the target service of the service call request as input;

[0031] A method generating unit, used for generating a protocol processing function in a protocol processor according to the read conversion configuration file, and if a corresponding protocol processing function does not exist in the protocol processor, automatically generating a protocol processing function in the protocol processor according to the protocol conversion configuration files of the two protocols;

[0032] A protocol processor is used to convert the communication protocol used by the service call request into the communication protocol used by the target service of the service call request. If a corresponding protocol processing function exists in the protocol processor, the protocol format configuration file of the communication protocol used by the source service of the service call request and the protocol format configuration file of the communication protocol used by the target service of the service call request are input into the protocol processor to convert the communication protocol used by the service call request into the communication protocol used by the target service of the service call request.

[0033] Furthermore, the request forwarding module is also used to implement the following steps: using a polling algorithm to realize discovery and polling load balancing of business processing microservices, first taking the name of the business processing microservice as input, then sending a service call request, cyclically generating all microservice instances of the specified business processing microservice, and selecting the next microservice instance through the polling algorithm;

[0034] Each time a microservice instance is generated, the index value is increased to ensure uniform polling of each microservice instance. If the index value is greater than the length of the microservice instance list, it is reset to zero to implement circular polling and avoid forwarding service call requests to a single microservice instance.

[0035] Furthermore, the method generating unit generates a protocol processing function including the following steps:

[0036] Declare a function, replace the preset function name with the processing function name in the read protocol conversion configuration file according to the preset protocol processing function template, set the preset input to the service request, the protocol format configuration file of the communication protocol used by the source service of the service request, the protocol format configuration file of the communication protocol used by the target service of the service request, and the protocol conversion configuration file of the two communication protocols in sequence, set the preset output to the service call request using the communication protocol used by the target service, and record the function name in the generated function declaration file;

[0037] Implement a function to parse from a service request to obtain the attribute fields of the communication protocol used by the source service of the service call request and the data fields carried by the request; according to the mapping rules between the communication protocol used by the source service of the service request and the communication protocol used by the target service of the service request in the protocol conversion file, convert the attributes of the communication protocol used by the source service of the service call request and the data fields carried by the service call request obtained by parsing into the format required by the communication protocol used by the target service of the service call request in accordance with the mapping rules and the communication protocol format used by the target service of the service call request; splice the converted attributes and data fields in accordance with the format requirements of the communication protocol used by the target service of the service call request and output them as a function.

[0038] An electronic device includes a memory, a processor, a communication bus and a communication interface, wherein the memory stores a computer program, and the processor executes the computer program to perform the steps of the above-mentioned microservice framework gateway processing method.

[0039] A computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the steps of the above-mentioned microservice framework gateway processing method when running.

[0040] The present invention can realize flexible configuration of heterogeneous protocol conversion rules, greatly improving the reuse and sharing of service resources under different technologies and environments. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0042] Figure 1 A flow chart of a microservice framework gateway processing method provided by an embodiment of the present invention;

[0043] Figure 2 A schematic diagram of a heterogeneous protocol microservice system provided by an embodiment of the present invention;

[0044] Figure 3 A schematic diagram of the composition of a protocol conversion gateway provided in an embodiment of the present invention;

[0045] Figure 4 A schematic diagram of the composition of a protocol conversion module provided in an embodiment of the present invention;

[0046] Figure 5 A protocol conversion flow chart provided for an embodiment of the present invention;

[0047] Figure 6 A schematic diagram of the protocol conversion principle provided by an embodiment of the present invention;

[0048] Figure 7 A schematic diagram of the composition of an electronic device configurable with heterogeneous protocols provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0049] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0050] The microservice framework makes the application more modular, easier to develop and maintain, and each microservice runs in a different process, which is isolated from each other, so the whole system will not be unavailable due to a failure in one of the service processes. However, due to the different development times of each microservice, the network transmission protocols used by different microservices may be different. In this case, when a microservice calls other microservices in the system, there is a problem of protocol conversion between microservices.

[0051] In order to maximize the reuse and sharing of microservice resources under different technologies and environments and reduce the construction cost of new services, the embodiment of the present invention provides a microservice framework gateway processing method and a protocol conversion gateway for configurable heterogeneous protocol conversion applied to a heterogeneous protocol microservice system, wherein the heterogeneous protocol microservice system includes a client, a registration center, a configuration center, a protocol conversion gateway and a microservice cluster. Specifically, Figure 2 As shown:

[0052] On the client side, the user sends a call request to a microservice in the microservice system through a visual interface, and the response to the request is fed back to the user.

[0053] The registration center 201 records the registration information provided by the services in a healthy state in the system so that other services can discover and call it.

[0054] The protocol conversion gateway 202 receives a service call request from a client for a service in the microservice cluster or a service call request from a microservice in the microservice cluster for another microservice in the microservice cluster, and converts the communication protocol used by the received service call request into a service call request using the target service communication protocol according to the target service of the service call request, and sends the converted service call request to the microservice instance running the target service to complete the service call.

[0055] The configuration center 203 publishes microservice configurations and protocol conversion configuration files between microservices of different communication protocols.

[0056] The microservice cluster 204 runs multiple microservices of heterogeneous protocols that provide services for the system, wherein each microservice has multiple microservice instances.

[0057] In an embodiment of the present invention, the service call request is forwarded to the healthy instance in the target microservice cluster through the registration center to complete the mutual call between heterogeneous protocol microservices, and the protocol format configuration files of all microservices and the protocol conversion configuration files between different microservices are published through the configuration center, wherein all microservices can read the required configuration files from the configuration center, and through the protocol conversion gateway, it is possible to convert the service call request using different communication protocols into the service call request using the communication protocol used by the target service of the service call request. In this way, for a newly added microservice, there is no need to configure the original microservice separately. The newly added microservice only needs to register its registration information to the registration center and publish the relevant configuration of the newly added microservice in the configuration center, so that it can be connected to the system for its original microservice to call and call the original microservice, and avoid the incompatibility of communication protocols between different microservices, realize efficient utilization of old microservices, and reduce the system construction cost of the newly added microservice.

[0058] The embodiment of the present invention provides a microservice framework gateway processing method that can configure heterogeneous protocols, such as Figure 1 As shown, the method includes:

[0059] S102, publish the protocol format configuration file and the protocol conversion configuration file used by the business processing microservice to the configuration center. The configuration center publishes the protocol format configuration files supported by all microservices and the protocol conversion configuration files between different communication protocols, wherein the protocol format configuration files and the protocol conversion configuration files are written and published in XML format. After adding a new microservice, it is only necessary to publish the protocol format configuration file of the communication protocol used by the new microservice and the protocol conversion configuration file between the new microservice and the original microservice in the configuration center to complete the configuration of the system after adding the new microservice.

[0060] S103, when the first business processing microservice needs to use the function of the second business processing microservice, it sends a service call request for the second business processing microservice to the protocol conversion gateway. The first business processing microservice is the source service of the service call request, and the second business processing microservice is the target service of the service call request. The service call request uses the communication protocol used by the source service. For example, the protocol used by the first microservice may include: HTTP, gRPC protocol, TCP protocol, etc.

[0061] S104, the protocol conversion gateway receives the service call request and performs subsequent processing on the service call request in an asynchronous coroutine high concurrency mode. After receiving the service call request, the protocol conversion gateway uses asynchronous coroutine technology to process the received service call request in parallel.

[0062] S105, the protocol conversion gateway parses the service call request, obtains the target service, and obtains the communication protocol configuration of the source service and the target service of the service call request from the configuration center. After receiving the service call request, the protocol conversion gateway parses the service call request, obtains the source service address, encapsulated data, target service address, and target call method contained in the service call request, and obtains the corresponding service name from the registration center according to the source service address and the target service address, and then obtains the communication protocol configuration of the source service and the target service from the configuration center according to the obtained service name.

[0063] S106, the protocol conversion gateway determines whether the communication protocol used by the source service of the service call request is consistent with that used by the target service. The consistency of the communication protocol used by the source service and the target service is determined by using the protocol format configuration file obtained from the configuration center. The determination method is to perform forward and reverse matching on the fields in the protocol format configuration file. First, the source service protocol format configuration file is read line by line, and the protocol format configuration file of the target service is searched for matching content in the protocol format configuration file of the target service. If the content in the source service protocol format configuration file can be found in the protocol format configuration file of the target service, reverse matching is performed. The target service protocol format configuration file is read line by line, and the protocol format configuration file of the source service is searched for matching content in the protocol format configuration file of the source service. If the content in the target service protocol format configuration file can be found in the protocol format configuration file of the source service, it is considered that the communication protocol used by the source service and the target service are consistent.

[0064] S107, if the communication protocols of the request source service and the target service are inconsistent, the communication protocol used by the service call request is converted to the communication protocol used by the target service by using the protocol conversion gateway. The protocol conversion gateway inputs the service call request, the protocol format configuration file of the source service, and the protocol format configuration file of the target service into its built-in protocol processor, and converts the communication protocol used by the service call request to the communication protocol used by the target service. If the communication protocols used by the source service and the target service of the service call request are consistent, the service call request is not processed.

[0065] Step S108: Send the service call request to the target service to complete the service call. The protocol conversion gateway forwards the service call request to the target microservice instance with a lower load to complete the service call according to the usage of the target microservice instance.

[0066] The embodiment of the present invention provides a protocol conversion gateway, comprising six modules: a request receiving module, a communication module, a protocol parsing module, a protocol judgment module, a protocol conversion module and a response forwarding module. Figure 3 As shown:

[0067] A request receiving module 301 is used to obtain a service call request from a client or a business processing microservice deployed in a microservice cluster, wherein the service call request uses a communication protocol of its source service;

[0068] The communication module 302 uses an asynchronous high-concurrency mode to implement concurrent processing of service call requests;

[0069] The protocol parsing module 303 is used to parse the received service call request and obtain the source service and target service of the service call request;

[0070] The protocol determination module 304 is used to determine whether the communication protocol used by the currently processed service call request is the same as the communication protocol used by the target service. When the communication protocol used by the service call request is the same as the communication protocol used by the target service, the service call request is directly released.

[0071] A protocol conversion module 305, configured to convert the communication protocol used in the service call request into the communication protocol used by the target service when the communication protocol used in the service call request is different from the communication protocol used in the target service;

[0072] The request forwarding module 306 is used to send the service call request to the target service and perform load balancing on the microservice instances.

[0073] The embodiment of the present invention uses the asynchronous coroutine high concurrency mode in the communication module to process the service call request received by the gateway.

[0074] Asynchronization relies on the IO multiplexing mechanism, which avoids the waste of resources and inefficiency when using blocking IO. Under the asynchronous programming model, each task is non-blocking, and the system uses the event loop mechanism to manage the execution of tasks and the processing of events. When a task needs to wait for IO operations, the system converts it into an event and adds it to the event queue, and then continues to execute other tasks until an event is triggered. The IO input module responds to the user's service call request through the socket and assigns the service call request to different processes for calculation and processing. Each process can be divided into several threads, and the threads are implemented based on the coroutine mechanism. The coroutine mechanism is the key technology of the asynchronous coroutine high concurrency mode. It can manage the execution and switching of multiple coroutine tasks in a single thread. Each coroutine task can be executed and suspended independently. This method reduces thread context switching and improves the efficiency of operation. For example, in the gateway communication module, the program can use Gevent to implement the coroutine of asynchronous IO operations. It uses the greenlet coroutine to encapsulate the Python native coroutine, thereby achieving the effect of high concurrency processing. When processing HTTP requests, the relevant modules use the coroutine HTTP client provided by Gevent to implement non-blocking network communication, and use the coroutine method to process requests and responses, thereby achieving efficient concurrent processing capabilities.

[0075] The embodiment of the present invention provides a protocol conversion module, such as Figure 4 As shown, including:

[0076] The configuration reading unit 401 is used to obtain the format of the communication protocol used by the source service of the service call request and the mapping rule between the format of the communication protocol used by the target service of the service call request and the communication protocol used by the target service of the service call request.

[0077] The conversion determination unit 402 is used to determine whether the protocol processor can complete the conversion of the communication protocol used for the service call request.

[0078] The method generation unit 403 is used to generate a protocol processing function in the protocol processor according to the read protocol conversion configuration file. The method generation unit refers to the protocol processing function template preset in the protocol processor and the protocol conversion configuration file read from the configuration center to generate a protocol processing function for the protocol processor that can implement the two communication protocols recorded in the conversion configuration file.

[0079] The protocol processor 404 is used to convert the communication protocol used by the service call request into the communication protocol used by the target service of the call request.

[0080] The embodiment of the present invention provides a protocol conversion method, such as Figure 5 As shown, the specific implementation steps are:

[0081] Step S501: Read from the configuration center the protocol format configuration file of the communication protocol used by the source service of the service call request, the protocol format configuration file of the communication protocol used by the target service of the service call request, and the protocol conversion configuration file of the two protocols, and obtain the protocol formats used by the two services and the mapping rules for the two services.

[0082] Step S502: Determine whether a protocol processing function that takes the protocol format configuration file of the communication protocol used by the source service of the call request and the protocol format configuration file of the communication protocol used by the target service of the call request as input already exists in the protocol processor.

[0083] Step S503: If the corresponding protocol processing function does not exist in the protocol processor, a protocol processing function is automatically generated in the protocol processor according to the protocol conversion configuration files of the two communication protocols.

[0084] Step S504: If the corresponding protocol processing function exists in the protocol processor, the protocol format configuration file of the communication protocol used by the source service of the call request and the protocol format configuration file of the communication protocol used by the target service of the call request are input into the protocol processor to convert the communication protocol used by the service call request into the communication protocol used by the target service of the service call request.

[0085] The method generation unit refers to the protocol conversion method template preset in the protocol processor and the protocol conversion configuration file read from the configuration center, and generates a protocol processing function for the protocol processor that can realize the conversion of the two communication protocols recorded in the protocol conversion configuration file. The embodiment of the present invention provides a protocol processing function generation method in the method generation unit. The principle is as follows Figure 6 As shown, the specific implementation steps are:

[0086] Step 1: declare a function. According to the preset protocol processing function template, replace the preset function name with the processing function name in the read protocol conversion configuration file. Set the preset input to the service request, the protocol format configuration file of the communication protocol used by the source service of the service request, the protocol format configuration file of the communication protocol used by the target service of the service request, and the protocol conversion configuration file of the two communication protocols in sequence. Set the preset output to a service call request using the communication protocol used by the target service, and record the function name in the generated function declaration file.

[0087] Step 2: Implement the function, parse from the service request to obtain the attribute fields of the communication protocol used by the source service of the service call request and the data fields carried by the request, and according to the mapping rules between the communication protocol used by the source service of the service request and the communication protocol used by the target service of the service request in the protocol conversion file, convert the attributes of the communication protocol used by the source service of the service call request and the data fields carried by the service call request obtained by parsing into the format required by the communication protocol used by the target service of the service call request in accordance with the mapping rules and the communication protocol format used by the target service of the service call request, and splice the converted attributes and data fields according to the format requirements of the communication protocol used by the target service of the service call request and output them as the function.

[0088] An embodiment of the present invention provides an electronic device, such as Figure 7 As shown, it includes: a communication bus 701, a processor 702, a memory 703, and a communication interface 704, which are specifically described as follows:

[0089] The communication bus 701 is the main communication path connecting various components. It can transmit data and control signals to achieve mutual communication and coordination between components. The communication bus can be a peripheral component interconnect standard (PCI) bus or an extended industrial standard architecture (EISA) bus, etc., and usually includes various sub-buses such as an address bus, a data bus, and a control bus to support data transmission, address recognition, and control signal transmission between devices.

[0090] The processor 702 is one of the core components of the electronic device. It is configured to run a specific computer program to execute the steps described in any of the above method embodiments, and is responsible for processing and analyzing the received data, controlling the operating state of the device, and performing various functional operations as needed; the processor can be a general-purpose processor, mainly including: a central processing unit (CPU), a network processor (NP), and can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components;

[0091] The memory 703 is used to store computer programs, data and temporarily stored information required for the operation of the electronic device. It stores computer programs, which include instructions for implementing the method steps, as well as other necessary software and data; the memory mainly includes random access memory (RAM) and non-volatile memory. In addition, the memory can also be one or more storage devices located away from the aforementioned processor.

[0092] The communication interface 704 is an interface for the conversion gateway to communicate with the electronic device, and is responsible for managing data transmission and communication connections between the electronic device and other devices to achieve interaction and data exchange with other devices.

[0093] An embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored, comprising a series of instructions, which are intended to execute the steps in any one of the above-mentioned protocol conversion method embodiments when running on a computer system; when the instructions in the storage medium are executed on the computer system, they enable the computer to effectively convert the request of the service requester into requests of different protocols applicable to multiple microservices, without the need to develop a dedicated gateway for each different protocol, thereby greatly simplifying the development process and improving development efficiency.

[0094] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A microservice framework gateway processing method, characterized in that: The steps include: Step S101: The business processing microservice in the business system registers the registration information to the registration center; Step S102: The business system administrator publishes the protocol format configuration file and the protocol conversion configuration file used by the business processing microservice to the configuration center; Step S103: When the first business processing microservice needs to use the function of the second business processing microservice, the first business processing microservice sends a service call request for the second business processing microservice to the protocol conversion gateway, wherein the first business processing microservice is the source service of the service call request, and the second business processing microservice is the target service of the service call request, and the service call request uses the communication protocol used by the source service; Step S104: The protocol conversion gateway receives the service call request and performs subsequent processing on the service call request in an asynchronous coroutine high concurrency mode; Step S105: the protocol conversion gateway parses the service call request, obtains the target service, and obtains the communication protocol configuration of the source service and the target service of the service call request from the configuration center; Step S106: The protocol conversion gateway determines whether the communication protocol used by the source service and the target service of the service call request is consistent; Step S107: if the communication protocols used by the source service of the service call request are inconsistent with those used by the target service, the communication protocol used by the service call request is converted into the communication protocol used by the target service by using the protocol conversion gateway; if the communication protocols used by the source service of the service call request are consistent with those used by the target service, the service call request is not processed; Step S108: Send the service call request to the target service to complete the service call.

2. A microservice framework gateway processing method according to claim 1, characterized in that: The step S101 specifically includes: the business processing microservice sends registration information to the registration center, the registration center writes the received new registration information into the registration table, and deletes the old registration information of the business processing microservice, so that the business processing microservice can be discovered and accessed by other business processing microservices, wherein a business processing microservice has multiple microservice instances, different instances of the same business processing microservice have the same IP address and different port numbers, any microservice instance can implement all functions of the business processing microservice, and the registration center records the registration information of all business processing microservices in the entire business system.

3. A microservice framework gateway processing method according to claim 2, characterized in that: The step S101 further includes: For successfully registered business processing microservices, the registration center regularly performs health checks on their microservice instances. Health checks refer to checking the relevant parameter indicators of the running status of the microservice instances. Microservice instances that pass the check provide service discovery for other business processing microservices. Microservice instances that fail the check will automatically go offline and delete the relevant registration information from the registration center. The business system administrator manually deregisters the business processing microservices and updates the registration information of the business processing microservices as needed.

4. A microservice framework gateway processing method according to claim 1, characterized in that: In step S102, the protocol format configuration file and the protocol conversion configuration file between different communication protocols in the configuration center are published in XML format and can be manually configured; the protocol format configuration file record includes the protocol name, basic protocol parameters and parameter types, protocol transmission data encapsulation format, and protocol transmission data type; the protocol conversion configuration file record includes the mapping relationship between different data types between two specified communication protocols and the protocol processing function name that implements the conversion function of the two specified communication protocols.

5. A protocol conversion gateway, characterized in that: include: A request receiving module is used to obtain a service call request from a client or a business processing microservice deployed in a microservice cluster, wherein the service call request uses the communication protocol used by its source service; Communication module, used to realize concurrent processing of service call requests; The protocol parsing module is used to parse the received service call request and obtain the source service and target service of the service call request; A protocol judgment module is used to judge whether the communication protocol used by the currently processed service call request is the same as the communication protocol used by the target service. When the communication protocol used by the service call request is the same as the communication protocol used by the target service, the service call request is directly released; A protocol conversion module, used to convert the communication protocol used in the service call request into the communication protocol used by the target service when the communication protocol used in the service call request is different from the communication protocol used by the target service; The request forwarding module is used to send the service call request to the target service.

6. A protocol conversion gateway according to claim 5, characterized in that: The communication module is also used to implement the following steps: using the asynchronous coroutine high concurrency mode to concurrently process call requests, when the protocol conversion gateway receives a service call request, enabling an asynchronous coroutine to process the service call request, avoiding blocking the main thread while maintaining responsiveness to other service call requests, wherein a coroutine pool is used to maintain each coroutine that processes service call requests, a mutex class is used to control concurrent access, an event circulator is used to schedule and manage all coroutines and asynchronous IO events, and notifies the relevant coroutines to continue execution when an IO event occurs.

7. A protocol conversion gateway according to claim 5, characterized in that: The protocol conversion module comprises: A configuration reading unit, used to obtain a protocol format configuration file and a protocol conversion configuration file of a communication protocol used by a source service and a target service of a service call request, read the protocol format configuration file of the communication protocol used by the source service of the service call request, the protocol format configuration file of the communication protocol used by the target service of the service call request, and the protocol conversion configuration files of the two protocols from a configuration center, and obtain the protocol formats used by the two services and mapping rules for the two services; A conversion judgment unit, used to judge whether the protocol processor can complete the conversion of the protocol used by the service call request, and whether there is a protocol processing function in the protocol processor that takes the protocol format configuration file of the communication protocol used by the source service of the service call request and the protocol format configuration file of the communication protocol used by the target service of the service call request as input; A method generating unit, used for generating a protocol processing function in a protocol processor according to the read conversion configuration file, and if a corresponding protocol processing function does not exist in the protocol processor, automatically generating a protocol processing function in the protocol processor according to the protocol conversion configuration files of the two protocols; A protocol processor is used to convert the communication protocol used by the service call request into the communication protocol used by the target service of the service call request. If a corresponding protocol processing function exists in the protocol processor, the protocol format configuration file of the communication protocol used by the source service of the service call request and the protocol format configuration file of the communication protocol used by the target service of the service call request are input into the protocol processor to convert the communication protocol used by the service call request into the communication protocol used by the target service of the service call request.

8. A protocol conversion gateway according to claim 5, characterized in that: The request forwarding module is also used to implement the following steps: using a polling algorithm to realize the discovery and polling load balancing of the business processing microservice, first taking the name of the business processing microservice as input, then sending a service call request, cyclically generating all microservice instances of the specified business processing microservice, and selecting the next microservice instance through the polling algorithm; Each time a microservice instance is generated, the index value is increased to ensure uniform polling of each microservice instance. If the index value is greater than the length of the microservice instance list, it is reset to zero to implement circular polling and avoid forwarding service call requests to a single microservice instance.

9. A protocol conversion gateway according to claim 7, characterized in that: The method generating unit generates a protocol processing function, which comprises the following steps: Declare a function, replace the preset function name with the processing function name in the read protocol conversion configuration file according to the preset protocol processing function template, set the preset input to the service request, the protocol format configuration file of the communication protocol used by the source service of the service request, the protocol format configuration file of the communication protocol used by the target service of the service request, and the protocol conversion configuration file of the two communication protocols in sequence, set the preset output to the service call request using the communication protocol used by the target service, and record the function name in the generated function declaration file; Implement a function to parse from a service request to obtain the attribute fields of the communication protocol used by the source service of the service call request and the data fields carried by the request; according to the mapping rules between the communication protocol used by the source service of the service request and the communication protocol used by the target service of the service request in the protocol conversion file, convert the attributes of the communication protocol used by the source service of the service call request and the data fields carried by the service call request obtained by parsing into the format required by the communication protocol used by the target service of the service call request in accordance with the mapping rules and the communication protocol format used by the target service of the service call request; splice the converted attributes and data fields in accordance with the format requirements of the communication protocol used by the target service of the service call request and output them as a function.

10. An electronic device, characterized in that: It includes a memory, a processor, a communication bus and a communication interface, wherein the memory stores a computer program, and the processor executes the computer program to perform the steps of the microservice framework gateway processing method described in any one of claims 1 to 4.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is configured to execute the steps of the microservice framework gateway processing method according to any one of claims 1 to 4 when running.

Citation Information

Patent Citations

  • Service calling method and device, storage medium and electronic device

    CN113301166A

  • Data gateway for multi-path protocol conversion

    CN118282806A

  • Signaling gateway and its signaling processing method

    US20110106960A1

  • Cloud network having multiple protocols using virtualization overlays across physical and virtualized workloads

    US20200213227A1