Microservice orchestration method, execution method, device and server
Through custom script configuration templates and virtual machine hot loading technology, configuration files corresponding to microservice interfaces are generated, which solves the orchestration problems of complex data types and business logic in existing technologies and realizes efficient microservice orchestration and execution.
Patent Information
- Application Number
- CN202111562419.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-20
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2041-12-20
AI Technical Summary
Existing service orchestration methods cannot effectively orchestrate complex data types and business logic, resulting in increased R&D costs and complexity.
By generating a configuration file corresponding to each microservice interface, using the preset script configuration template to customize the data processing logic, combined with the hot loading and execution of the virtual machine, the processing of complex data types can be achieved.
It reduces the complexity and cost of the R&D process, facilitates system maintenance and expansion, and improves the system's usability and practicality.
Smart Images

Figure CN114217887B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence technology, and in particular relates to a microservice orchestration method, execution method, device and server. Background Art
[0002] With the development of distributed and microservice software architecture, applications are decomposed into multiple smaller microservices in the entire system service architecture. Each microservice is developed, deployed, and maintained by an independent team. In this architectural model, a complete business process needs to be implemented through collaboration between various microservices. Service orchestration is used to assemble various independent microservices to realize complete business functions and provide unified external services.
[0003] However, existing service orchestration methods use Domain-Specific Language (DSL) for configuration to complete the business logic processing during the service orchestration process. For simple data types and business logic, the service orchestration process can be implemented through the configuration of this domain-specific language. However, as business needs become more complex and changeable, complex data types and business logic are restricted by established rules, making it impossible to effectively orchestrate services. Redevelopment is required to achieve this, increasing R&D costs and complexity. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a microservice orchestration method, execution method, device, and server, which can reduce the complexity and R&D costs of the R&D process.
[0005] A first aspect of an embodiment of the present invention provides a microservice orchestration method, which may include:
[0006] Generate a configuration file corresponding to each microservice interface according to the preset script configuration template and the microservice interface information in the service orchestration file corresponding to the target microservice combination; wherein the content of the configuration file includes the data processing logic corresponding to the microservice interface;
[0007] Compile the configuration file to obtain an executable class file corresponding to the configuration file;
[0008] The class file is hot loaded in the virtual machine, and the class file is executed in the virtual machine according to the microservice interface information.
[0009] In a specific implementation of the first aspect, the configuration file is used to process parameters associated with the microservice interface, where the parameters associated with the microservice interface include input parameters before calling the microservice interface and response data after calling the microservice interface;
[0010] Accordingly, the processing of the parameters associated with the microservice interface includes:
[0011] Performing verification processing on the input parameters;
[0012] Based on the data processing logic, the input parameters are processed according to the input parameter data format of the microservice interface;
[0013] After obtaining the response data, performing verification processing on the response data;
[0014] Based on the data processing logic, the response data is processed according to the response data format of the microservice interface;
[0015] The data processing logic includes one or more of data filling, format conversion, data assembly and data filtering.
[0016] In a specific implementation of the first aspect, the configuration file further includes response code conversion logic; the response code conversion logic is used to convert the response code generated by calling the microservice interface based on the response code conversion logic when an exception occurs in calling the microservice interface;
[0017] Accordingly, the response code generated by calling the microservice interface is converted based on the response code conversion logic, including:
[0018] Based on the mapping relationship preset in the response code conversion logic, convert the response code to obtain an error response code with a unified format;
[0019] Accordingly, before converting the response code, the microservice orchestration method further includes:
[0020] If the response code generated by calling the microservice interface is a null value, the response code is filled by executing the data filling logic when processing the response data based on the data processing logic.
[0021] A second aspect of an embodiment of the present invention provides a microservice execution method, which may include:
[0022] In response to a microservice call request sent by a client, obtain a service orchestration file of a target microservice combination corresponding to the microservice call request; wherein the service orchestration file includes a configuration file corresponding to at least one microservice interface;
[0023] In the process of calling the microservice interface in the target microservice combination according to the service orchestration file, loading the executable class file corresponding to the configuration file, and executing the class file according to the microservice interface information in the service orchestration file and the parameters associated with the microservice interface;
[0024] After all microservices in the target microservice combination are executed according to the service orchestration file, the result information is output and fed back to the client;
[0025] Among them, the configuration file is a preset script configuration template, which generates a script file corresponding to each microservice interface according to the microservice interface information in the service orchestration file corresponding to the target microservice combination; the content of the configuration file includes: the data processing logic corresponding to the microservice interface; the executable class file is obtained by compiling the configuration file, and is hot loaded and executed through the virtual machine.
[0026] In a specific implementation of the second aspect, the parameters associated with the microservice interface include input parameters before calling the microservice interface and response data after calling the microservice interface;
[0027] Accordingly, according to the microservice interface information in the service orchestration file, the class file is executed for the parameters associated with the microservice interface, including:
[0028] Performing verification processing on the input parameters;
[0029] After the verification process passes, the input parameters are processed based on the data processing logic according to the input parameter data format of the microservice interface;
[0030] After obtaining the response data, performing verification processing on the response data;
[0031] After the verification process passes, the response data is processed based on the data processing logic according to the response data format of the microservice interface;
[0032] The data processing logic includes one or more of data filling, format conversion, data assembly and data filtering.
[0033] In a specific implementation of the second aspect, the configuration file further includes response code conversion logic; and before outputting the result information and feeding it back to the client, the microservice execution method further includes:
[0034] Based on the response code conversion logic, the response code generated by calling the microservice interface is converted to obtain an error response code with a unified format;
[0035] Accordingly, before converting the response code, the microservice orchestration method further includes:
[0036] If the response code generated by calling the microservice interface is a null value, when the response data is processed based on the data processing logic, the data filling logic is executed to fill the response code.
[0037] A third aspect of an embodiment of the present invention provides a microservice orchestration device, which may include:
[0038] A configuration unit is configured to generate a configuration file corresponding to each microservice interface according to the microservice interface information in the service orchestration file corresponding to the target microservice combination according to a preset script configuration template; wherein the content of the configuration file includes the data processing logic corresponding to the microservice interface;
[0039] A compiling unit, configured to compile the configuration file to obtain an executable class file corresponding to the configuration file;
[0040] A loading unit is used to hot load the class file in the virtual machine and execute the class file in the virtual machine according to the microservice interface information.
[0041] In a specific implementation of the third aspect, the configuration file is used to process parameters associated with the microservice interface, where the parameters associated with the microservice interface include input parameters before calling the microservice interface and response data after calling the microservice interface;
[0042] Accordingly, the device further includes:
[0043] A first verification unit, configured to perform verification processing on the input parameters;
[0044] A first processing unit is configured to process the input parameters according to the input parameter data format of the microservice interface based on the data processing logic;
[0045] A second verification unit is used to verify the response data after obtaining the response data;
[0046] A second processing unit is configured to process the response data according to the response data format of the microservice interface based on the data processing logic;
[0047] The data processing logic includes one or more of data filling, format conversion, data assembly and data filtering.
[0048] In a specific implementation of the third aspect, the configuration file further includes response code conversion logic; the response code conversion logic is used to convert the response code generated by calling the microservice interface based on the response code conversion logic when an exception occurs in calling the microservice interface;
[0049] Accordingly, the device further includes:
[0050] A response code conversion unit, configured to convert the response code based on a mapping relationship preset in the response code conversion logic to obtain an error response code with a unified format;
[0051] Accordingly, before converting the response code, the device further includes:
[0052] A filling unit is used to fill the response code by executing data filling logic when processing the response data based on the data processing logic if the response code generated by calling the microservice interface is a null value.
[0053] A fourth aspect of an embodiment of the present invention provides a microservice execution device, which may include:
[0054] An acquisition unit is configured to, in response to a microservice call request sent by a client, acquire a service orchestration file of a target microservice combination corresponding to the microservice call request; wherein the service orchestration file includes a configuration file corresponding to at least one microservice interface;
[0055] an execution unit, configured to load an executable class file corresponding to the configuration file during a process of calling a microservice interface in the target microservice combination according to the service orchestration file, and execute the class file according to parameters associated with the microservice interface according to the microservice interface information in the service orchestration file;
[0056] An output unit, configured to output result information and feed it back to the client after all microservices in the target microservice combination are executed according to the service orchestration file;
[0057] Among them, the configuration file is a preset script configuration template, which generates a script file corresponding to each microservice interface according to the microservice interface information in the service orchestration file corresponding to the target microservice combination; the content of the configuration file includes: the data processing logic corresponding to the microservice interface; the executable class file is obtained by compiling the configuration file, and is hot loaded and executed through the virtual machine.
[0058] In a specific implementation of the fourth aspect, the parameters associated with the microservice interface include input parameters before calling the microservice interface and response data after calling the microservice interface;
[0059] Accordingly, the execution unit includes:
[0060] A first verification module, configured to perform verification processing on the input parameters;
[0061] A first processing module is used to process the input parameters based on the data processing logic according to the input parameter data format of the microservice interface after the verification process passes;
[0062] A second verification module is used to verify the response data after obtaining the response data;
[0063] A second processing module is used to process the response data based on the data processing logic according to the response data format of the microservice interface after the verification process passes;
[0064] The data processing logic includes one or more of data filling, format conversion, data assembly and data filtering.
[0065] In a specific implementation of the fourth aspect, the configuration file further includes response code conversion logic; and before outputting the result information and feeding it back to the client, the microservice execution device further includes:
[0066] A conversion unit, configured to convert the response code generated by calling the microservice interface based on the response code conversion logic to obtain an error response code with a unified format;
[0067] Accordingly, before converting the response code, the microservice execution device further includes:
[0068] A filling unit is used to execute the data filling logic to fill the response code when processing the response data based on the data processing logic if the response code generated by calling the microservice interface is a null value.
[0069] A fifth aspect of an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0070] A fourth aspect of an embodiment of the present invention provides a server, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above methods when executing the computer program.
[0071] A fifth aspect of an embodiment of the present invention provides a computer program product, which, when running on a server, enables the server to execute the steps of any of the above methods.
[0072] Compared with the prior art, the embodiments of the present invention have the following advantages: the embodiments of the present invention generate a corresponding configuration file corresponding to each microservice interface in the target microservice combination according to a preset script configuration template, and process the parameters associated with calling the microservice interface according to the data processing logic of the configuration file, thereby realizing the processing function of complex data types based on a customized configuration file or a script extension based on a script configuration template; through the dynamic hot loading and execution of the virtual machine, the adaptation of the configuration file can be completed quickly without the need for code development, thereby reducing the complexity and R&D cost of the R&D process and facilitating the subsequent maintenance and expansion of the system; and having strong ease of use and practicality. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0074] Figure 1 A schematic diagram of the implementation process of the microservice orchestration method provided in an embodiment of the present invention;
[0075] Figure 2 A schematic diagram of a script processing flow provided by an embodiment of the present invention;
[0076] Figure 3 A relationship diagram for mapping response data provided by an embodiment of the present invention;
[0077] Figure 4 A schematic diagram of the implementation process of the microservice execution method provided in an embodiment of the present invention;
[0078] Figure 5 A schematic diagram of the architecture of the microservice execution process provided by an embodiment of the present invention;
[0079] Figure 6 A schematic diagram of the architecture of microservice orchestration processing during the execution process provided by an embodiment of the present invention;
[0080] Figure 7 A schematic diagram of the structure of a microservice orchestration device provided in an embodiment of the present invention;
[0081] Figure 8 A schematic diagram of the structure of a microservice execution device provided in an embodiment of the present invention;
[0082] Figure 9 A schematic block diagram of a server provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0083] In order to make the purpose, features, and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described below are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0084] Embodiments of the present invention can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results.
[0085] Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0086] The execution subject of the embodiments of the present invention may be an artificial intelligence-based server for executing the microservice orchestration and execution method of the embodiments of the present invention. The server may be a standalone server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0087] See also Figure 1 , an embodiment of a microservice orchestration method in an embodiment of the present invention may include:
[0088] Step S101: Generate a configuration file corresponding to each microservice interface according to the preset script configuration template and the microservice interface information in the service orchestration file corresponding to the target microservice combination; wherein the content of the configuration file includes: the data processing logic corresponding to the microservice interface.
[0089] For example, the script configuration template can be the script template class AbstractOpenApiPayloadParser. In actual applications, tasks corresponding to microservice interface calls in microservice orchestration files can implement this script template class as needed. Task nodes requiring custom processing can also be customized, thus supporting microservice orchestration script extensions and custom processing logic, meeting complex data format requirements and other complexities.
[0090] Exemplarily, the target microservice combination is a collection of multiple microservices that need to be called to complete a complete business process. The service orchestration file is the processing logic for calling each microservice node corresponding to a complete business process, and can be a configuration described based on a DSL language. The service orchestration file includes microservice interface information corresponding to each microservice node. The microservice interface information can include input parameter specifications and output parameter specifications. The configuration file corresponding to each microservice interface is generated based on the microservice interface information, which can be implemented based on a custom script. The server receives code information input by the user or developer based on the script configuration template.
[0091] For example, Figure 2 As shown in Figure (b), the context environment for receiving code information input by users or developers based on the script configuration template may include: current step request response data stepInputOutput, current step process context flowStepContext, current step configuration flowStepConfig, and orchestration process context openApiFlowContext.
[0092] Among them, such as Figure 2 As shown in Figure (a), a script extension is used to implement the configuration file corresponding to each microservice interface. The corresponding processing flow nodes of the script extension include: input parameter validation (validateInput), request parameter assembly (assemblyInput), response data signature verification (validateOutput), response data assembly (assemblyOutput), and response data padding (paddingOutpu). The data processing logic in the configuration file processes the parameters associated with the microservice interface.
[0093] Exemplarily, the data processing logic may include data filling, data type conversion, data assembly, response data type conversion, and response data filtering; for example, parameter filling reqParamPadding, parameter type conversion reqParamTypeMapping, request parameter assembly assemblyInput, response data assembly assemblyOutput, response data type conversion respParamTypeMapping, response data filtering respParamList, etc.
[0094] Exemplarily, data assembly may also include data serialization, deserialization, format conversion, etc., for example: Objectobj = parseJson(jsonStr) / / deserialize the json string format into a json object; String jsonStr = toJsonString(jsonObj) / / serialize the json object into a json string; BigDecimal amount = fenToYuan(value) / / amount format conversion, converting fen to yuan.
[0095] S102: Compile the configuration file to obtain an executable class file corresponding to the configuration file.
[0096] For example, the server can compile the configuration file through a virtual machine to generate an executable class file, which can be a binary code file that the server can execute. This allows customized configuration files to be used to process complex data and logic in the microservice orchestration process based on business needs, ensuring server system stability and meeting the requirements of different microservice call interfaces and client business needs.
[0097] S103: hot-load the class file in the virtual machine, and execute the class file in the virtual machine according to the microservice interface information.
[0098] Exemplarily, the server can hot-load the class file through the class loading mechanism of the virtual machine. While executing the microservice orchestration process, a thread is started in the background through the virtual machine to periodically detect the timestamp changes of the class file. If the timestamp of the class file changes, the class file is reloaded.
[0099] Alternatively, after generating the configuration file, corresponding identification information is generated at the same time, and the class file obtained after compiling the configuration file is cached; when the configuration file needs to be executed next time, the class file in the cache can be queried based on the identification information. If the class file is found, it is executed directly without the need to compile and load it again; dynamic calling and execution is realized, saving execution events and improving execution efficiency.
[0100] In some embodiments, the configuration file is used to process parameters associated with the microservice interface, where the parameters associated with the microservice interface include input parameters before calling the microservice interface and response data after calling the microservice interface;
[0101] Accordingly, the processing of the parameters associated with the microservice interface includes:
[0102] Performing verification processing on the input parameters;
[0103] Based on the data processing logic, the input parameters are processed according to the input parameter data format of the microservice interface;
[0104] After obtaining the response data, performing verification processing on the response data;
[0105] Based on the data processing logic, the response data is processed according to the response data format of the microservice interface;
[0106] The data processing logic includes one or more of data filling, format conversion, data assembly and data filtering.
[0107] For example, when verifying the input parameters, the necessity and format of the requested input parameters may be verified, for example:
[0108] var merNo = reqData.get("merNo"); / / Get the value of the specified field from the input parameter
[0109] isEmpty(merNo){
[0110] return false; / / If it is a null value, an error response message is returned
[0111] }.
[0112] For example, the input parameters of the request are assembled according to the input parameter specifications of the internal microservice interface. The input parameter data can be external request data or input parameters or output parameters in the preceding orchestration task, for example:
[0113] stepInput.set("mno",reqData.get("merNo")); / / Get the value of the specified field from the input parameter
[0114] stepInput.set("uid",context.getStepInput("findUserStep","uid")); / / Get the value of the specified field from the input of other steps
[0115] stepInput.set("uname",context.getStepOutput("findUserStep","uname")); / / Get the value of the specified field from other step outputs.
[0116] Among them, when assembling data, the corresponding values can also be processed, such as data serialization, deserialization, format conversion, etc. For example:
[0117] Object obj = parseJson(jsonStr); / / Deserialize the json string format into a json object
[0118] String jsonStr = toJsonString(jsonObj); / / Serialize the json object into a json string
[0119] BigDecimal amount = fenToYuan(value); / / Convert the amount format from fen to yuan.
[0120] Exemplarily, performing verification processing on the response data is verifying the response data after the internal microservice is called.
[0121] For example, the data assembly process for the response data can be to reprocess the response data after the internal microservice call, and perform data format conversion, field filtering, etc. as required. For example:
[0122] output.remove("tid"); / / Remove a field
[0123] output.formatTime("createTime"); / / Time formatting.
[0124] Exemplarily, performing data filling processing on the response data may be assembling the fields of the response data according to the input and output in other steps according to the requirements of this call response, and outputting a complete response data message.
[0125] The above customized links are used to complete the processing of parameter field data in the orchestration process. According to the specific service interface, the format or field name of the external input parameter fields is converted according to the requirements of the internal interface, thus realizing the processing of complex data.
[0126] In some embodiments, the configuration file further includes response code conversion logic; the response code conversion logic is used to convert the response code generated by calling the microservice interface based on the response code conversion logic when an exception occurs when calling the microservice interface;
[0127] Accordingly, the response code generated by calling the microservice interface is converted based on the response code conversion logic, including:
[0128] Based on the mapping relationship preset in the response code conversion logic, convert the response code to obtain an error response code with a unified format;
[0129] Accordingly, before converting the response code, the microservice orchestration method further includes:
[0130] If the response code generated by calling the microservice interface is a null value, the response code is filled by executing the data filling logic when processing the response data based on the data processing logic.
[0131] For example, since different microservices may be maintained and developed by different R&D teams, there will be certain differences in the corresponding interface response message formats. During the process of orchestrating and processing microservices, the server must also shield the differences in internal responses from the outside world and standardize external responses by unifying the format of response codes, so that the client can process the service response results through consistent processing logic.
[0132] For example, when calling a microservice in the target microservice composition, an exception may occur, and the server will generate a response code to indicate the error. Microservice call exceptions include system call communication exceptions (such as network timeouts) and business exceptions (such as normal system processing but business processing failure).
[0133] For example, for abnormal calls and communications between systems, the gateway orchestration service platform can define corresponding response codes to indicate errors; for example, the response code corresponding to service connection timeout is 500001, the response code corresponding to service call timeout is 500001, and the response code corresponding to service call abnormality is 500999.
[0134] For example, for business exceptions, different internal applications have their own response code specifications. For example, application A corresponds to the six-digit number 020005, which represents illegal parameters, and application B corresponds to 026011, which represents illegal parameters.
[0135] For example, Figure 3As shown in the figure, the mapping relationship diagram preset in the response code conversion logic shows the mapping rule relationship. Based on the type code corresponding to the scenario and the business interface response code, it is mapped to a unified response code.
[0136] The scenario can be based on the interface dimension (such as the interface number) or the service dimension (such as the service category code) as a reference, and can be flexibly set as needed. For example, in the interface dimension, the interface number is C0001.A5013; the internal response code 020006 in the C0001.A5013 interface can be mapped to 0007, indicating incorrect parameters; the internal response code 020006 in the P0001.A5013 interface can be mapped to 0025, indicating that the verification code failed.
[0137] In addition, one type of error has the same mapping response code. For example, the six-digit number 020005 corresponding to application A represents an illegal parameter, and the six-digit number 026011 corresponding to application B represents an illegal parameter. The 020005 corresponding to application A can be mapped to 0008, indicating an illegal parameter; and the 026011 corresponding to application B can also be mapped to 0008, indicating an illegal parameter.
[0138] For example, in actual applications, there may be a situation where the response code of the business interface does not exist or is returned as empty. The response code can also be filled in according to other response fields in the data filling paddingOutpu link corresponding to the response data.
[0139] It's important to note that you can choose to perform conversion based on the interface or business dimension, depending on the actual interface. You must also configure the mapping in advance based on the corresponding interface number or business code. If you need to respond to internal error messages externally, use pre-defined placeholders when configuring the mapping description to replace the internal information. For example, "Illegal parameter - {innerMsg}" will be converted to "Illegal parameter - incorrect phone number format."
[0140] Through the embodiments of the present invention, in the process of orchestrating internal microservices, there will be service interfaces with different specifications and standards, such as existing historical interfaces and newly built systems, which require the orchestration system to be compatible. The configuration file cannot achieve the flexibility of the script due to implementation limitations. When the configuration file cannot meet the requirements, the adaptation can be quickly completed through a custom script without code development, which reduces the tedious online process of R&D, testing and release, and reduces the impact of system changes on system stability. Since each microservice is maintained and developed by different teams, there will be certain differences in the interface response message format specifications. As a service orchestration system, it needs to shield internal differences from the outside and standardize external responses through a unified response code. Consumers can process service response results through consistent response processing logic rules.
[0141] See also Figure 4 , an embodiment of a microservice execution method in an embodiment of the present invention may include:
[0142] S401: In response to a microservice call request sent by a client, obtain a service orchestration file of a target microservice combination corresponding to the microservice call request; wherein the service orchestration file includes a configuration file corresponding to at least one microservice interface.
[0143] S402: In the process of calling the microservice interface in the target microservice combination according to the service orchestration file, the executable class file corresponding to the configuration file is loaded, and the class file is executed according to the microservice interface information in the service orchestration file and the parameters associated with the microservice interface.
[0144] S403: After all microservices in the target microservice combination are executed according to the service orchestration file, result information is output and fed back to the client.
[0145] Among them, the configuration file is a preset script configuration template, which generates a script file corresponding to each microservice interface according to the microservice interface information in the service orchestration file corresponding to the target microservice combination; the content of the configuration file includes: the data processing logic corresponding to the microservice interface; the executable class file is obtained by compiling the configuration file, and is hot loaded and executed through the virtual machine.
[0146] For example, when a client accesses a server to make a service call, the client initiates a microservice call request according to the gateway's interface protocol specification. The server's internal gateway executes multiple internal microservices according to the service orchestration configuration (such as a service orchestration file), and responds to the client with the final processing result according to the gateway message specification, completing the entire request interaction.
[0147] like Figure 5 As shown, the server receives a microservice call request from a client, which includes parameters input in JSON format. Upon receiving the microservice call request, the server decrypts and verifies its signature, then executes the service call process based on the input parameters. During the service call, the server orchestrates the service with the target microservice combination. After executing all microservices in the target microservice combination, the server encrypts and signs the execution results, generates a JSON response, and returns it to the client, completing the entire service request processing process.
[0148] In some embodiments, the parameters associated with the microservice interface include input parameters before calling the microservice interface and response data after calling the microservice interface;
[0149] Accordingly, according to the microservice interface information in the service orchestration file, the class file is executed for the parameters associated with the microservice interface, including:
[0150] Performing verification processing on the input parameters;
[0151] After the verification process passes, the input parameters are processed based on the data processing logic according to the input parameter data format of the microservice interface;
[0152] After obtaining the response data, performing verification processing on the response data;
[0153] After the verification process passes, the response data is processed based on the data processing logic according to the response data format of the microservice interface;
[0154] The data processing logic includes one or more of data filling, format conversion, data assembly and data filtering.
[0155] For example, Figure 6 As shown, the server executes the microservice processing flow based on the dependencies between the microservices in the service orchestration file. As shown in the figure, the processing flow of the service orchestration task may include: based on the configuration in the service orchestration file, determining whether the current microservice needs to be executed. If execution is required, the client input parameters (ClientInput) and the input or output parameters of the preceding microservice are processed according to the data processing logic in the configuration file. For example, data is assembled and processed, and parameters are verified at the input task node (taskNode.input). If the parameter verification passes, the business process of the current microservice is executed. If the parameter verification fails, the configuration in the service orchestration file is used to determine whether the current microservice can be downgraded.
[0156] When executing the current microservice's business process, if an exception occurs during service execution, the configuration in the service orchestration file is used to determine whether the current microservice can be downgraded. For example, if too many interfaces accessing the current microservice cause an execution exception, the system will determine whether to downgrade the current microservice to prevent it from being idle. If the service is executing normally, the system will output response data through the task node (taskNode.output). The response data will be parameter-validated based on the configuration file in the service orchestration file. If the validation passes, the system will determine whether to terminate the execution based on the service orchestration file. If so, the service call process will be terminated. If not, the system will continue to execute the next microservice call task based on the service orchestration file. If the response data parameter validation fails, the system will determine whether the current microservice can be downgraded based on the service orchestration file. If the current microservice can be downgraded, the system will continue to execute the next microservice call task based on the service orchestration file. If the current microservice cannot be downgraded, the system will terminate the current service call process.
[0157] For example, when executing the processing flow of microservices, the server can selectively execute the configuration items in the service orchestration file according to the system properties (systemProperties), such as determining whether execution is required, the input parameter verification process, the output parameter verification process, and the determination process of whether to terminate.
[0158] In some embodiments, the configuration file further includes response code conversion logic; before outputting the result information and feeding it back to the client, the microservice execution method further includes:
[0159] Based on the response code conversion logic, the response code generated by calling the microservice interface is converted to obtain an error response code with a unified format;
[0160] Accordingly, before converting the response code, the microservice orchestration method further includes:
[0161] If the response code generated by calling the microservice interface is a null value, when the response data is processed based on the data processing logic, the data filling logic is executed to fill the response code.
[0162] To sum up, the embodiment of the present invention generates a corresponding configuration file corresponding to each microservice interface in the target microservice combination according to a preset script configuration template, and processes the parameters associated with calling the microservice interface according to the data processing logic of the configuration file, so that the processing function of complex data types can be realized based on a customized configuration file or a script extension based on a script configuration template; through the dynamic hot loading and execution of the virtual machine, the adaptation of the configuration file can be completed quickly without the need for code development, which reduces the complexity and R&D cost of the R&D process and facilitates the subsequent maintenance and expansion of the system.
[0163] In some application scenarios, when orchestrating internal microservices, there will be service interfaces with different specifications and standards. For example, existing historical interfaces and newly built systems require compatibility with the orchestration system. Configuration files cannot achieve the flexibility of scripts due to implementation limitations. When configuration files cannot meet the requirements, custom scripts can be used to quickly complete the adaptation without code development, reducing the tedious online process of R&D, testing, and release, and reducing the impact of system changes on system stability. Since each microservice is maintained and developed by different teams, there will be certain differences in the interface response message format specifications. As a service orchestration system, it needs to shield internal differences from the outside world and standardize external responses through unified response codes. Clients can process service response results through consistent processing logic rules.
[0164] It should be understood that the order of execution of the steps in the above embodiments does not necessarily mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0165] Corresponding to the microservice orchestration method described in the above embodiment, Figure 7 A structural diagram of an embodiment of a microservice orchestration device provided by an embodiment of the present invention is shown.
[0166] In this embodiment, a microservice orchestration device may include:
[0167] Configuration unit 71 is configured to generate a configuration file corresponding to each microservice interface according to the microservice interface information in the service orchestration file corresponding to the target microservice combination according to a preset script configuration template; wherein the content of the configuration file includes the data processing logic corresponding to the microservice interface;
[0168] A compiling unit 72 is configured to compile the configuration file to obtain an executable class file corresponding to the configuration file;
[0169] The loading unit 73 is used to hot load the class file in the virtual machine and execute the class file in the virtual machine according to the microservice interface information.
[0170] In a specific implementation of the embodiment of the present invention, the configuration file is used to process parameters associated with the microservice interface, where the parameters associated with the microservice interface include input parameters before calling the microservice interface and response data after calling the microservice interface;
[0171] Accordingly, the device further includes:
[0172] A first verification unit, configured to perform verification processing on the input parameters;
[0173] A first processing unit is configured to process the input parameters according to the input parameter data format of the microservice interface based on the data processing logic;
[0174] A second verification unit is used to verify the response data after obtaining the response data;
[0175] A second processing unit is configured to process the response data according to the response data format of the microservice interface based on the data processing logic;
[0176] The data processing logic includes one or more of data filling, format conversion, data assembly and data filtering.
[0177] In a specific implementation of the embodiment of the present invention, the configuration file further includes response code conversion logic; the response code conversion logic is used to convert the response code generated by calling the microservice interface based on the response code conversion logic when an exception occurs in calling the microservice interface;
[0178] Accordingly, the device further includes:
[0179] A response code conversion unit, configured to convert the response code based on a mapping relationship preset in the response code conversion logic to obtain an error response code with a unified format;
[0180] Accordingly, before converting the response code, the device further includes:
[0181] A filling unit is used to fill the response code by executing data filling logic when processing the response data based on the data processing logic if the response code generated by calling the microservice interface is a null value.
[0182] Corresponding to the microservice execution method described in the above embodiment, Figure 8 A structural diagram of an embodiment of a microservice execution device provided by an embodiment of the present invention is shown.
[0183] In this embodiment, a microservice execution device may include:
[0184] The acquisition unit 81 is configured to, in response to a microservice call request sent by a client, acquire a service orchestration file of a target microservice combination corresponding to the microservice call request; wherein the service orchestration file includes a configuration file corresponding to at least one microservice interface;
[0185] An execution unit 82 is configured to load an executable class file corresponding to the configuration file during the process of calling the microservice interface in the target microservice combination according to the service orchestration file, and execute the class file according to the parameters associated with the microservice interface according to the microservice interface information in the service orchestration file;
[0186] An output unit 83 is configured to output result information and feed it back to the client after all microservices in the target microservice combination are executed according to the service orchestration file;
[0187] Among them, the configuration file is a preset script configuration template, which generates a script file corresponding to each microservice interface according to the microservice interface information in the service orchestration file corresponding to the target microservice combination; the content of the configuration file includes: the data processing logic corresponding to the microservice interface; the executable class file is obtained by compiling the configuration file, and is hot loaded and executed through the virtual machine.
[0188] In a specific implementation of the embodiment of the present invention, the parameters associated with the microservice interface include input parameters before calling the microservice interface and response data after calling the microservice interface;
[0189] Accordingly, the execution unit includes:
[0190] A first verification module, configured to perform verification processing on the input parameters;
[0191] A first processing module is used to process the input parameters based on the data processing logic according to the input parameter data format of the microservice interface after the verification process passes;
[0192] A second verification module is used to verify the response data after obtaining the response data;
[0193] A second processing module is used to process the response data based on the data processing logic according to the response data format of the microservice interface after the verification process passes;
[0194] The data processing logic includes one or more of data filling, format conversion, data assembly and data filtering.
[0195] In a specific implementation of the embodiment of the present invention, the configuration file further includes response code conversion logic; before outputting the result information and feeding it back to the client, the microservice execution device further includes:
[0196] A conversion unit, configured to convert the response code generated by calling the microservice interface based on the response code conversion logic to obtain an error response code with a unified format;
[0197] Accordingly, before converting the response code, the microservice execution device further includes:
[0198] A filling unit is used to execute the data filling logic to fill the response code when processing the response data based on the data processing logic if the response code generated by calling the microservice interface is a null value.
[0199] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices, modules and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0200] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0201] Figure 9 A schematic block diagram of a server provided by an embodiment of the present invention is shown. For ease of description, only parts related to the embodiment of the present invention are shown.
[0202] In this embodiment, the server 9 may include: a processor 90, a memory 91, and computer-readable instructions 92 stored in the memory 91 and executable on the processor 90, such as computer-readable instructions for executing the above-mentioned presentation generation method. When the processor 90 executes the computer-readable instructions 92, the steps in the above-mentioned various presentation generation method embodiments are implemented, such as Figure 1 Alternatively, when the processor 90 executes the computer-readable instructions 92, the functions of the modules / units in the above-mentioned device embodiments are realized, for example, Figure 7 The units 71 to 73 shown or Figure 8 The functions of the units 81 to 83 are shown.
[0203] Exemplarily, the computer-readable instructions 92 may be divided into one or more modules / units, which are stored in the memory 91 and executed by the processor 90 to implement the present invention. The one or more modules / units may be a series of computer-readable instruction segments capable of implementing specific functions, and the instruction segments are used to describe the execution process of the computer-readable instructions 92 in the server 9.
[0204] Those skilled in the art will understand that Figure 9 This is only an example of the server 9 and does not constitute a limitation on the server 9. The server 9 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the server 9 may also include input and output devices, network access devices, buses, etc.
[0205] The processor 90 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0206] The memory 91 can be an internal storage unit of the server 9, such as the server 9's hard drive or memory. Alternatively, the memory 91 can be an external storage device of the server 9, such as a plug-in hard drive, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash memory card, etc. Furthermore, the memory 91 can include both the internal storage unit of the server 9 and an external storage device. The memory 91 is used to store the computer-readable instructions and other instructions and data required by the server 9. The memory 91 can also be used to temporarily store data that has been output or is about to be output.
[0207] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0208] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0209] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0210] In the embodiments provided in this application, it should be understood that the disclosed devices / servers and methods can be implemented in other ways. For example, the device / server embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0211] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0212] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0213] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application can implement all or part of the process steps in the above-mentioned method embodiments by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When executed by a processor, the computer program can implement the steps of each of the above-mentioned method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form. The computer-readable storage medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium. It should be noted that the content of the computer-readable storage medium can be appropriately increased or decreased based on the requirements of legislation and patent practice in a jurisdiction. For example, in some jurisdictions, based on legislation and patent practice, computer-readable storage media do not include electric carrier signals and telecommunication signals.
[0214] The above-described embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A microservice orchestration method, characterized in that: include: Generate a configuration file corresponding to each microservice interface according to the preset script configuration template and the microservice interface information in the service orchestration file corresponding to the target microservice combination; wherein the content of each configuration file includes the data processing logic for different data types corresponding to each microservice interface; Compiling the configuration files to obtain executable class files corresponding to each configuration file; Hot loading the class file in the virtual machine, and executing the class file in the virtual machine according to the microservice interface information; The service orchestration file includes tasks corresponding to each microservice interface call, and the tasks of each microservice interface call include: formulating script extensions of the script template class according to requirements, determining the processing logic of each microservice node; or customizing the processing logic of each microservice node for task nodes that require customized processing; While hot loading the class file, start a thread that periodically detects the timestamp of the class file, and reload the class file when the timestamp changes; or after generating the configuration file, generate corresponding identification information for each configuration file, cache the class file obtained after compiling the configuration file, and when the cached configuration file is executed again, query the class file in the cache according to the identification information and execute it.
2. The method according to claim 1, characterized in that The configuration file is used to process parameters associated with the microservice interface, where the parameters associated with the microservice interface include input parameters before calling the microservice interface and response data after calling the microservice interface; Accordingly, the processing of the parameters associated with the microservice interface includes: Performing verification processing on the input parameters; Based on the data processing logic, the input parameters are processed according to the input parameter data format of the microservice interface; After obtaining the response data, performing verification processing on the response data; Based on the data processing logic, the response data is processed according to the response data format of the microservice interface; The data processing logic includes one or more of data filling, format conversion, data assembly and data filtering.
3. The method according to claim 2, characterized in that The configuration file also includes response code conversion logic; the response code conversion logic is used to convert the response code generated by calling the microservice interface based on the response code conversion logic when there is an exception in calling the microservice interface; Accordingly, the response code generated by calling the microservice interface is converted based on the response code conversion logic, including: Based on the mapping relationship preset in the response code conversion logic, convert the response code to obtain an error response code with a unified format; Accordingly, before converting the response code, the microservice orchestration method further includes: If the response code generated by calling the microservice interface is a null value, the response code is filled by executing the data filling logic when processing the response data based on the data processing logic.
4. A microservice execution method, characterized in that: include: In response to a microservice call request sent by a client, obtain a service orchestration file of a target microservice combination corresponding to the microservice call request; wherein the service orchestration file includes a configuration file corresponding to at least one microservice interface; In the process of calling the microservice interface in the target microservice combination according to the service orchestration file, loading the executable class file corresponding to the configuration file, and executing the class file according to the microservice interface information in the service orchestration file and the parameters associated with the microservice interface; After all microservices in the target microservice combination are executed according to the service orchestration file, the result information is output and fed back to the client; The configuration file is a preset script configuration template that generates a script file corresponding to each microservice interface based on the microservice interface information in the service orchestration file corresponding to the target microservice combination; the content of the configuration file includes: data processing logic corresponding to the microservice interface; the executable class file is compiled from the configuration file and is hot-loaded and executed by a virtual machine; the service orchestration file includes tasks corresponding to each microservice interface call, and the tasks called by each microservice interface include: script extensions of the script template class formulated according to requirements, and processing logic of each microservice node determined; or customized processing logic of each microservice node for task nodes that require customized processing; While hot loading the class file, start a thread that periodically detects the timestamp of the class file, and reload the class file when the timestamp changes; or after generating the configuration file, generate corresponding identification information for each configuration file, cache the class file obtained after compiling the configuration file, and when the cached configuration file is executed again, query the class file in the cache according to the identification information and execute it.
5. The method according to claim 4, characterized in that The parameters associated with the microservice interface include input parameters before calling the microservice interface and response data after calling the microservice interface; Accordingly, according to the microservice interface information in the service orchestration file, the class file is executed for the parameters associated with the microservice interface, including: Performing verification processing on the input parameters; After the verification process passes, the input parameters are processed based on the data processing logic according to the input parameter data format of the microservice interface; After obtaining the response data, performing verification processing on the response data; After the verification process passes, the response data is processed based on the data processing logic according to the response data format of the microservice interface; The data processing logic includes one or more of data filling, format conversion, data assembly and data filtering.
6. The method according to claim 5, characterized in that The configuration file also includes response code conversion logic; before outputting the result information and feeding it back to the client, the microservice execution method further includes: Based on the response code conversion logic, the response code generated by calling the microservice interface is converted to obtain an error response code with a unified format; Accordingly, before converting the response code, the microservice execution method further includes: If the response code generated by calling the microservice interface is a null value, when the response data is processed based on the data processing logic, the data filling logic is executed to fill the response code.
7. A microservice orchestration device, characterized in that: include: A configuration unit is configured to generate a configuration file corresponding to each microservice interface according to the microservice interface information in the service orchestration file corresponding to the target microservice combination according to a preset script configuration template; wherein the content of the configuration file includes the data processing logic corresponding to the microservice interface; A compiling unit, configured to compile the configuration file to obtain an executable class file corresponding to the configuration file; A loading unit, configured to hot load the class file in the virtual machine and execute the class file in the virtual machine according to the microservice interface information; The configuration unit is further configured to include tasks corresponding to calls to each microservice interface in the service orchestration file, wherein the tasks for calling each microservice interface include: formulating script extensions of the script template class according to requirements to determine the processing logic of each microservice node; or customizing the processing logic of each microservice node for task nodes that require customized processing; The loading unit is also used to start a thread that periodically detects the timestamp of the class file while hot loading the class file, and reload the class file when the timestamp changes; or after generating the configuration file, generate corresponding identification information for each configuration file, cache the class file obtained after compiling the configuration file, and when the cached configuration file is executed again, query the class file in the cache according to the identification information and execute it.
8. A microservice execution device, characterized in that: include: An acquisition unit is configured to, in response to a microservice call request sent by a client, acquire a service orchestration file of a target microservice combination corresponding to the microservice call request; wherein the service orchestration file includes a configuration file corresponding to at least one microservice interface; an execution unit, configured to load an executable class file corresponding to the configuration file during a process of calling a microservice interface in the target microservice combination according to the service orchestration file, and execute the class file according to parameters associated with the microservice interface according to the microservice interface information in the service orchestration file; An output unit, configured to output result information and feed it back to the client after all microservices in the target microservice combination are executed according to the service orchestration file; The configuration file is a preset script configuration template that generates a script file corresponding to each microservice interface based on the microservice interface information in the service orchestration file corresponding to the target microservice combination; the content of the configuration file includes: data processing logic corresponding to the microservice interface; the executable class file is compiled from the configuration file and is hot-loaded and executed by a virtual machine; the service orchestration file includes tasks corresponding to each microservice interface call, and the tasks called by each microservice interface include: script extensions of the script template class formulated according to requirements, and processing logic of each microservice node determined; or customized processing logic of each microservice node for task nodes that require customized processing; While hot loading the class file, start a thread that periodically detects the timestamp of the class file, and reload the class file when the timestamp changes; or after generating the configuration file, generate corresponding identification information for each configuration file, cache the class file obtained after compiling the configuration file, and when the cached configuration file is executed again, query the class file in the cache according to the identification information and execute it.
9. A computer-readable storage medium storing computer-readable instructions, characterized in that: When the computer-readable instructions are executed by a processor, the steps of the method according to any one of claims 1 to 3 or claims 4 to 6 are implemented.
10. A server comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein: When the processor executes the computer-readable instructions, the steps of the method according to any one of claims 1 to 3 or claims 4 to 6 are implemented.
Citation Information
Patent Citations
Method and device for testing micro-service Dubbo interface
CN110908908A
Micro-service arrangement method and system, micro-service execution method and system, architecture, equipment and storage medium
CN111078315A
Development method of Zeus framework based on SpringBoot and Zeus framework
CN111813394A