A service arrangement method and device

By customizing service mapping and call information in service configuration information, processing call requests and generating task queues, the problems of high development costs and long update cycles caused by hard coding are solved, and flexibility and efficiency are improved.

CN113535419BActive Publication Date: 2024-11-15BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1

Patent Information

Application Number
CN202010301332.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-16
Publication Date
2024-11-15
Estimated Expiration
2040-04-16

AI Technical Summary

Technical Problem

In the prior art, the processing and calling chains of services are hard-coded, which requires modification of code when business needs or service changes, increasing development costs and delaying product update cycle.

Method used

By pre-customizing the service mapping information, service call information and service interface execution order in the service configuration information, processing call requests based on these information, generating a task queue and using threads to execute task nodes, so as to meet business needs without development, and adding The flexibility of service calls and reduces development costs.

Benefits of technology

It realizes that business needs can be met without development, improves the flexibility of service calls and product update cycle, improves the flexibility of service mapping through result integration scripts and parameter entry and return result mapping scripts, and improves the processing speed of parallel execution of service interfaces. , saving script compilation time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113535419B_ABST
    Figure CN113535419B_ABST
Patent Text Reader

Abstract

The present invention discloses a service orchestration method and device, and relates to the field of computer technology. A specific implementation of the method includes: obtaining preset service configuration information according to the interface name and business input parameters in the call request; wherein the service configuration information includes service mapping information, service call information and service interface execution order; obtaining the corresponding service processing script according to the script address in the service mapping information, grouping the service interfaces of the service call information according to the service interface execution order, taking the service interfaces belonging to the same group as task nodes, and generating a task queue; pulling the task node from the task queue according to the service interface execution order of the service interface in the task node, executing the service interface of the task node, and obtaining the return result; assembling the return result using the service processing script, and returning the assembled result. The method increases the flexibility of service calls, reduces development costs, and improves the product update cycle.
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 service orchestration method and device. Background Art

[0002] As the business develops, different business scenarios usually require calling multiple services to meet business needs. For example, for the business scenario of querying user information, it is necessary to call three services: user basic information query, user account information query, and user level information query. In addition, when calling the service, a series of processing such as parameter packaging, conversion, and filtering is required.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0004] The processing of services and the service call chain are hard-coded, that is, the data is directly written into the code for compilation and development. If the business requirements or services change, the code must be modified to solve the problem, which increases development costs and delays product refinement cycles. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a service orchestration method and device, which pre-customizes service mapping information, service call information and service interface execution order in the service configuration information, and processes the call request based on the service configuration information after receiving the call request, so as to meet business needs without development, increase the flexibility of service calls, reduce development costs, and improve the product update cycle.

[0006] To achieve the above objective, according to one aspect of an embodiment of the present invention, a service orchestration method is provided.

[0007] A service orchestration method according to an embodiment of the present invention comprises: obtaining preset service configuration information according to an interface name and business input parameters in a call request; wherein the service configuration information comprises service mapping information, service call information and service interface execution order; obtaining a corresponding service processing script according to a script address in the service mapping information, grouping service interfaces of the service call information according to the service interface execution order, taking the service interfaces belonging to the same group as task nodes, and generating a task queue; pulling the task node from the task queue according to the service interface execution order of the service interface in the task node, executing the service interface of the task node using a thread, and obtaining a return result; assembling the return result using the service processing script, and returning the assembled result.

[0008] Optionally, the service mapping information is configured with a mapping relationship between the return results and the task execution order, and the service processing script includes a result integration script; the return results are assembled using the service processing script, including: by executing the result integration script, to obtain the corresponding return results according to the task execution order for personalized assembly.

[0009] Optionally, the service mapping information is also configured with a mapping relationship between the business input and the service interface input, and the service processing script also includes an input parameter mapping script, and the input parameter mapping script is used to implement the mapping of the business input to the service interface input; before using a thread to execute the service interface of the task node, the method also includes: converting the business input into the service interface input through the input parameter mapping script.

[0010] Optionally, the service mapping information is also configured with a mapping relationship between the return result and the business processing result, and the service processing script also includes a return result mapping script, and the return result mapping script is used to realize the mapping of the return result and the business processing result; before the step of assembling the return result using the service processing script, the method also includes: converting the return result into the business processing result through the return result mapping script; assembling the return result using the service processing script, including: obtaining the corresponding business processing result for personalized assembly according to the task execution order by executing the result integration script.

[0011] Optionally, a thread is used to execute the service interface of the task node to obtain a return result, including: traversing the service interface of the task node; when the task node includes multiple service interfaces, using the same number of threads as the service interfaces to execute multiple service interfaces in parallel; after the execution of the service interface of the task node is completed, using the result integration script to merge the execution results of multiple threads to obtain a return result.

[0012] Optionally, the business input parameters are converted into the service interface input parameters through the input parameter mapping script, including: obtaining a script engine according to the script type of the input parameter mapping script; executing the input parameter mapping script according to a pre-saved script compilation package of the input parameter mapping script, and outputting the service interface input parameters.

[0013] Optionally, after the step of obtaining the script engine, the method further includes: determining whether a script compilation package of the input parameter mapping script is saved; if the script compilation package is not saved, using the script engine to parse the input parameter mapping script to obtain the script content; compiling and packaging the script content to generate a script compilation package, and saving the script compilation package.

[0014] To achieve the above objective, according to another aspect of an embodiment of the present invention, a service orchestration device is provided.

[0015] A service orchestration device according to an embodiment of the present invention includes: an information acquisition module, which is used to obtain preset service configuration information according to an interface name and business input parameters in a call request; wherein the service configuration information includes service mapping information, service call information and service interface execution order; a service parsing module, which is used to obtain a corresponding service processing script according to a script address in the service mapping information, group the service interfaces of the service call information according to the service interface execution order, and use the service interfaces belonging to the same group as task nodes to generate a task queue; a service calling module, which is used to pull the task node from the task queue according to the service interface execution order of the service interface in the task node, use a thread to execute the service interface of the task node, and obtain a return result; a service integration module, which is used to assemble the return result using the service processing script and return the assembled result.

[0016] Optionally, the service mapping information is configured with a mapping relationship between the return results and the task execution order, and the service processing script includes a result integration script; the service integration module is also used to obtain the corresponding return results for personalized assembly according to the task execution order by executing the result integration script.

[0017] Optionally, the service mapping information is also configured with a mapping relationship between the business input parameters and the service interface input parameters, and the service processing script also includes an input parameter mapping script, and the input parameter mapping script is used to implement the mapping of the business input parameters to the service interface input parameters; the device also includes: an input parameter conversion module, which is used to convert the business input parameters into the service interface input parameters through the input parameter mapping script before using the thread to execute the service interface of the task node.

[0018] Optionally, the service mapping information is also configured with a mapping relationship between the return result and the business processing result, and the service processing script also includes a return result mapping script, and the return result mapping script is used to implement the mapping of the return result and the business processing result; the device also includes: an output parameter conversion module, which is used to convert the return result into the business processing result through the return result mapping script before using the service processing script to assemble the return result; the service integration module is also used to obtain the corresponding business processing results according to the task execution order for personalized assembly by executing the result integration script.

[0019] Optionally, the service call module is also used to traverse the service interface of the task node; when the task node includes multiple service interfaces, the multiple service interfaces are executed in parallel using the same number of threads as the service interfaces; when the service interface of the task node is executed, the result integration script is used to merge the execution results of the multiple threads to obtain a return result.

[0020] Optionally, the input parameter conversion module is further used to obtain a script engine according to the script type of the input parameter mapping script; execute the input parameter mapping script according to a pre-saved script compilation package of the input parameter mapping script, and output the service interface input parameter.

[0021] Optionally, the input parameter conversion module is also used to determine whether a script compilation package of the input parameter mapping script is saved after obtaining the script engine; if the script compilation package is not saved, use the script engine to parse the input parameter mapping script to obtain the script content; compile and package the script content to generate a script compilation package, and save the script compilation package.

[0022] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device is provided.

[0023] An electronic device according to an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a service orchestration method according to an embodiment of the present invention.

[0024] To achieve the above objective, according to another aspect of the embodiments of the present invention, a computer readable medium is provided.

[0025] A computer-readable medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, a service orchestration method according to an embodiment of the present invention is implemented.

[0026] An embodiment of the above invention has the following advantages or beneficial effects: by pre-customizing service mapping information, service call information and service interface execution order in the service configuration information, after receiving the call request, the call request is processed based on the service configuration information, and business needs can be met without development, thereby increasing the flexibility of service calls, reducing development costs, and improving the product update cycle; obtaining the return results of business needs through the result integration script for assembly, thereby realizing personalized processing; realizing the conversion of business input parameters and service interface input parameters through the input parameter mapping script, and realizing the conversion of return results and business processing results through the return result mapping script, thereby further improving the flexibility of service mapping.

[0027] An embodiment of the above invention has the following advantages or beneficial effects: using the same number of threads as the service interfaces in the task node to execute each service interface in parallel, and merging the execution results of each service interface, thereby improving the speed of interface processing and reducing thread overhead; using a pre-saved script compilation package to execute the script, saving script compilation time and improving script parsing efficiency; saving the script compilation package during script parsing, saving the subsequent script compilation time and improving script parsing efficiency.

[0028] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0030] Figure 1 is a schematic diagram of main steps of a service orchestration method according to an embodiment of the present invention;

[0031] Figure 2 is a timing diagram of a service orchestration method according to an embodiment of the present invention;

[0032] Figure 3 is a schematic diagram of the main process of the service orchestration method according to an embodiment of the present invention;

[0033] Figure 4 is a schematic diagram of the relationship between business lines and mapping services in the service orchestration method according to an embodiment of the present invention;

[0034] Figure 5 is a schematic diagram of a task queue data model in a service orchestration method according to an embodiment of the present invention;

[0035] Figure 6 is a schematic diagram of arrangement of task nodes in a task queue in a service orchestration method according to an embodiment of the present invention;

[0036] Figure 7 is a schematic diagram of a service interface execution process of a task node in a service orchestration method according to an embodiment of the present invention;

[0037] Figure 8 is a schematic diagram of the implementation process of script parsing in the service orchestration method according to an embodiment of the present invention;

[0038] Fig. 9 is a schematic diagram of a script parsing interface design in a service orchestration method according to an embodiment of the present invention;

[0039] Fig.10 is a schematic diagram of main modules of a service orchestration device according to an embodiment of the present invention;

[0040] Fig.11 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0041] Fig.12 It is a schematic diagram of the structure of a computer device suitable for implementing the electronic device of the embodiment of the present invention. DETAILED DESCRIPTION

[0042] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0043] The technical terms involved in the embodiments of the present invention are explained below.

[0044] Service orchestration: It is to arrange and combine some services with single responsibilities to form a large service that can meet business needs.

[0045] RPC: It is the abbreviation of Remote Procedure Call, which is a protocol for requesting services from a remote computer program over the network without having to understand the underlying network technology.

[0046] Generalized call: A method of completing RPC interface calls through dynamic proxy without relying on the service provider interface on the client side.

[0047] ScriptEngineManager: JDK comes with a script parsing engine that can be used to parse scripts in multiple languages. JDK (Java Development Kit) is a software development kit for the Java language.

[0048] Groovy: is an agile development language based on JVM (Java Virtual Machine).

[0049] url: The abbreviation of Uniform Resource Locator, which is a method used to specify the location of information on the World Wide Web service program of the Internet.

[0050] Thread pool: A form of multithreaded processing in which tasks are added to a queue and then automatically started after a thread is created.

[0051] Figure 1 FIG. 1 is a schematic diagram of the main steps of the service orchestration method according to an embodiment of the present invention. Figure 1 As shown, the service arrangement method of the embodiment of the present invention mainly includes the following steps:

[0052] Step S101: Obtain preset service configuration information based on the interface name and business input parameters in the call request. When a call request sent by a business line is received, the corresponding service configuration information is obtained from the business information based on the business identifier of the business input parameters in the call request and the name of the interface to be called. Among them, the service configuration information is used to customize the configuration of related service mapping information (including packaging, conversion, and filtering of input and output parameters), call chain relationships, etc. according to business needs, and may specifically include service mapping information, service call information, and service interface execution order.

[0053] The service mapping information contains the script address used to integrate the return results of each task node. The service call information contains the interface name, method name, etc. of the service interface; the service interface execution order is the execution order of the service interface. The service call information and the service interface execution order reflect the call chain relationship between services.

[0054] Step S102: According to the script address in the service mapping information, the corresponding service processing script is obtained, and the service interfaces of the service call information are grouped according to the execution order of the service interfaces, and the service interfaces belonging to the same group are used as task nodes to generate a task queue. The service processing script implements the processing logic for result integration, which is pre-written and stored by the developer. After obtaining the service configuration information, the service mapping information of the service configuration information can be parsed to obtain the script address to obtain the service processing script.

[0055] After obtaining the service processing script, it is necessary to process the serial and parallel call relationship between the interfaces. In the embodiment, the service interfaces are sorted according to the execution order of the service interfaces. The service interfaces with the first execution order are sorted first, and the service interfaces with the later execution order are sorted last. The service interfaces with the same execution order form a group. All service interfaces in the same group are a task node, and the service interfaces within the task node are called in parallel, and the task nodes are called serially. All task nodes form a task queue according to the execution order of the service interfaces.

[0056] Step S103: Pull the task node from the task queue according to the service interface execution order of the service interface in the task node, use the thread to execute the service interface of the task node, and obtain a return result. Pull each task node from the task queue in turn according to the service interface execution order of the service interface in each task node.

[0057] When a task node is pulled, the number of threads is determined according to the number of service interfaces of the task node. Then, the corresponding number of threads are used to execute all service interfaces of the task node in parallel. After each service interface of the task node is executed, the execution results of each thread are merged to obtain the return result.

[0058] Step S104: Assemble the return result using the service processing script and return the assembled result. The processing logic of result assembly is relatively personalized, so a service processing script can be written according to business needs, and the script can be used to process the return result of each task node in the task queue, and finally the return result of each task node and the assembled result can be returned to the business line. This embodiment customizes the service mapping relationship and the call chain relationship according to business needs through configuration, and can meet business needs with a little configuration without development.

[0059] Figure 2 FIG. 1 is a timing diagram of a service orchestration method according to an embodiment of the present invention. Figure 2 As shown, the service orchestration method of the embodiment of the present invention is implemented by a service orchestration device, which includes a service mapping module, a service calling module and a service integration module. Among them, the service mapping module is used to define service configuration information for the business line, and after receiving an RPC request from the business line, obtain the service configuration information defined for the business line according to the interface name and business input parameters in the RPC request. The service configuration information defines the interface calling logic, and the calling mode can be serial or parallel.

[0060] The service call module is used to convert the business input parameters into service interface input parameters according to the settings of the service configuration information, and then execute the specific interface call logic to obtain the return result. The service integration module is used to assemble the return results and convert them into the results required by the business through the service mapping module and then return them to the business line. Figure 3-Figure 9 The specific processing procedures of the above three modules are explained in detail.

[0061] It should be noted that Figure 2 1vsN means that one RPC request corresponds to N service interfaces, parallel mapping means that N service interfaces can be executed in parallel, and serial mapping means that N service interfaces are executed in serial. For example, one RPC request needs to query user information, and querying user information requires calling three services: user basic information, user account information, and user level information, and these three services can be processed in parallel, so one RPC request corresponds to three parallel service interfaces.

[0062] Figure 3 FIG. 1 is a schematic diagram of the main flow of the service orchestration method according to an embodiment of the present invention. Figure 3As shown, the service arrangement method of the embodiment of the present invention is implemented by a service arrangement device, and mainly includes the following steps:

[0063] Step S301: The service mapping module obtains preset service configuration information according to the interface name and business input parameters in the call request. The service mapping module includes two major functions: service configuration and service resolution. In the embodiment, service configuration is implemented by the service configuration module, and service resolution is implemented by the service resolution module.

[0064] The service configuration module needs to configure service mapping information, service call information and service interface execution order, which constitute the service configuration information. Service call information includes interface name, method name, method alias, registration center address, etc. Among them, the registration center refers to the registration center of the RPC service, which is used by service providers to register services and service consumers to discover services.

[0065] Since the data types and field names of the service input parameters are different, it is necessary to configure the mapping relationship of the service input parameters in the service mapping information (hereinafter referred to as the first mapping relationship). Table 1 shows the differences of the service input parameters in combination with specific examples.

[0066] Table 1

[0067]

[0068]

[0069] In addition to the first mapping relationship, the service mapping information is also configured with a mapping relationship between the return result and the business processing result (hereinafter referred to as the second mapping relationship), and a mapping relationship between the return result and the task execution order (hereinafter referred to as the third mapping relationship). Among them, the configuration of the second mapping relationship is similar to the first mapping relationship, and the data type and field name also need to be converted, which will not be repeated here.

[0070] The third mapping relationship is saved in the mapping table, and is used to select the corresponding return results according to the task execution order and integrate the results according to business needs. When there are multiple service interface calls in a task node, the return results of multiple service interfaces need to be integrated. For example, querying user information requires calling three services: user basic information, user account information, and user level information. These three services are in one task node. When the parallel interface call is completed, the return results of these three services need to be merged and assembled, and then the next task node is executed or the result is returned.

[0071] In order to improve the flexibility of the service orchestration device, in the embodiment, the first to second mapping relationship and the result integration are all implemented through scripts, namely, the input parameter mapping script, the return result mapping script and the result integration script. The above scripts can be written in languages ​​such as Groovy, Java, Python, JavaScript, etc. The script is uploaded and stored, such as to cloud storage. When persisting data, only the encrypted cloud storage link (the link points to the corresponding script) is stored, which reduces the storage pressure and improves the confidentiality of the data.

[0072] Taking the Groovy script as an example, the configuration of the first mapping relationship shown in Table 1 can be implemented by the following code (the code is the input parameter mapping script):

[0073]

[0074] In the example of querying user information, the configuration of result integration can be implemented through the following Groovy script code (this code is the result integration script):

[0075]

[0076] Among them, UserbaseInfo information is returned by the user basic information interface, UserAmount information is returned by the user account information, and UserRank information is returned by the user level information interface.

[0077] A business line can be configured with multiple mapping services, so the relationship between the business line and the mapping service needs to be maintained in the service configuration module. Figure 4 FIG. 1 is a schematic diagram of the relationship between business lines and mapping services in the service orchestration method according to an embodiment of the present invention. Figure 4 As shown in Table 2, BusinessInfo is business information, ConfigInfo is service configuration information, InterfaceInfo is service interface information, and there is a one-to-one mapping relationship between BusinessInfo and ConfigInfo (indicated by a special arrow with two 1s in the figure), and there is a one-to-many mapping relationship between ConfigInfo and InterfaceInfo (indicated by a special arrow with 1* in the figure). Figure 4 Explanation of the properties of each object involved.

[0078] Table 2

[0079]

[0080]

[0081] After defining the service configuration information in the above manner, when the service mapping module receives a call request sent by the business line, the service parsing module can obtain the service configuration information corresponding to the business line according to the interface name (i.e., targetMethodName in Table 1) and business input parameters in the call request. Among them, the business input parameters include the business identifier and token. When obtaining the service configuration information, the unique corresponding service configuration information can be found by the interface name and business identifier.

[0082] Step S302: The service mapping module parses the service mapping information in the service configuration information to obtain the script content. The service parsing module obtains the input parameter mapping script, the return result mapping script and the result integration script through the URL in the service configuration information, and parses the above scripts into corresponding byte array forms for storage. The parsing here is to parse the script using Java's file IO parsing technology to obtain the actual script value, and then store the actual script value in the form of a byte stream. In the embodiment, the result integration script is parsed first, and then the input parameter mapping script and the return result mapping script are parsed.

[0083] Step S303: The service mapping module sorts and groups all service interfaces with the same interface name as the call request according to the service interface execution order, and generates a task queue. After the service parsing module parses the acquired script into the corresponding script content, it needs to process the serial and parallel call relationship between the interfaces. Specifically, the service parsing module sorts the service interfaces of multiple service interface information according to the sequence field, and then groups the service interfaces according to the sequence field to process the call relationship, and finally generates a task queue for execution by the service call module.

[0084] Figure 5 FIG. 1 is a schematic diagram of a task queue data model in a service orchestration method according to an embodiment of the present invention. Figure 5 As shown in the figure, the ExecuteTaskItem object is similar to the InterfaceInfo object. It is used to pull the corresponding script files through the URLs corresponding to the input parameter mapping script, the return result mapping script, and the result integration script, and parse them into actual script values. The executeTaskItemList attribute in the ExecuteQueue object is the task node in the task queue, which can be a single service interface call or multiple service interface calls; the convertResultScript attribute is used to merge the results after the task node is executed. The following example is used to illustrate.

[0085] Assume that the getOrder identification interface of business line A is currently configured to have 5 service interfaces, and the methods defined in each service interface are: getOrderIdByPin, getAmountByOrderId, getCouponByOrderId, getReduceByOrderId, and convertOrder. Among them, the sequence attribute value of the getOrderIdByPin method is 0, the sequence attribute value of the getAmountByOrderId, getCouponByOrderId, and getReduceByOrderId methods is 1, and the sequence attribute value of the convertOrder method is 2. The methods with the same sequence attribute value are grouped into an ExecuteQueue object, and each method in the ExecuteQueue object is each ExecuteTaskItem object.

[0086] Figure 6 FIG. 1 is a schematic diagram of the arrangement of task nodes in a task queue in a service orchestration method according to an embodiment of the present invention. Figure 6 As shown, the task queue includes three task nodes, the task node corresponding to getOrderIdByPin (hereinafter referred to as the first task node) is executed first, the task nodes corresponding to getAmountByOrderId, getCouponByOrderId and getReduceByOrderId (hereinafter referred to as the second task node) are executed in the middle, and the task node corresponding to convertOrder (hereinafter referred to as the third task node) is executed last. In this embodiment, the convert ResultScript script can be used to merge and assemble the execution results of these three methods after the second task node is executed to obtain the return result for calling the method of the third task node.

[0087] Step S304: The service calling module determines whether there is an unexecuted task node in the task queue. If so, step S305 is executed; otherwise, step S310 is executed. The service calling module sequentially pulls each task node from the task queue for processing. The processing process includes steps S305 to S309.

[0088] For each task node in the task queue, the returned result is obtained through serial processing. For example Figure 6After the first task node is executed, its return result is used as the input for calling the method in the second task node; after the second task node is executed, its return result is used as the input for calling the method in the third task node. For task nodes containing multiple service interfaces (such as the second task node), the return result is obtained through parallel processing. In this way, the control of parallel calls of interface strings is realized.

[0089] Step S305: The service calling module determines whether there is an input parameter mapping script corresponding to the current task node in the script content. If so, execute step S306; otherwise, execute step S307. Some services can directly use business input parameters when calling, without adjusting the data type and field name, so they can be directly handed over to the thread for processing.

[0090] Step S306: The service call module executes the input parameter mapping script to convert the business input parameter into the service interface input parameter, and then executes step S307. The input parameter mapping script implements the processing logic of the input parameter when calling the service through the before method, which is used to convert the business input parameter into the service interface input parameter.

[0091] Step S307: The service call module passes the service interface of the current task node to the thread for processing, merges the execution results of each thread, and obtains the return result. Assuming that the current task node contains n service interfaces, n threads are used to process each service interface in parallel. After all service interfaces are processed, the result integration script can be used to merge the execution results of n threads to obtain the return result. For the specific implementation of this step, see Figure 7 .

[0092] In the embodiment, since it is impossible to obtain the class file or jar package of the server when calling the service, if the calling request is an RPC request, the calling process of the service interface can be executed through a generalized call, and only the interface, method, parameter type, etc. need to be specified. If the calling request is an Http request, the call can be made in the form of Http if the interface service provider provides support.

[0093] Step S308: The service calling module determines whether there is a return result mapping script corresponding to the current task node in the script content. If so, step S309 is executed; otherwise, step S304 is executed. The return results of some services can meet business requirements, and there is no need to adjust the data type and field name, so the processing of the next task node can be directly entered.

[0094] Step S309: The service call module executes the return result mapping script to convert the return result into a business processing result, and executes step S304. The return result mapping script implements the processing logic of the return result after calling the service through the after method, which is used to convert the return result into a business processing result (i.e., the result of the business requirement).

[0095] Step S310: The service integration module executes the result integration script to perform personalized assembly of the return result / business processing result of each task node in the task queue according to business requirements, and returns the assembled result to the business line. The service integration module is used to perform personalized processing on the return result (or business processing result) of each task node in the task queue, and finally the return result (or business processing result) of each task node and the processed result can be returned to the business line. The personalized processing here can include result packaging, combination, and specific personalized business logic.

[0096] In this embodiment, the assembly processing is performed by the result integration script, which improves the flexibility of service arrangement and ensures the personalization of processing logic. In a preferred embodiment, after each task node is executed, the return result of the task node and the task execution order (i.e., the service interface execution order of the service interface in the task node) form a 1vs1 mapping relationship, and the mapping relationship is saved in a mapping table (such as Java's map collection). The result integration script only needs to obtain the corresponding results (return results or business processing results) from the mapping table according to business needs and perform personalized processing (such as result packaging, combination, calculation and other business logic).

[0097] After the business line accesses the service orchestration device and defines the corresponding service configuration information, a unique business identifier (i.e., appId in Table 1) and token will be assigned to the business line for authentication verification of the interface to prevent unauthorized access. Therefore, in another preferred embodiment, the business input parameters can also be verified between step S302 and step S303, that is, the business identifier and token in the business input parameters are verified to ensure the legitimacy of the call request.

[0098] Figure 7 FIG. 1 is a schematic diagram of the service interface execution process of a task node in a service orchestration method according to an embodiment of the present invention. Figure 7 As shown, the service interface execution process of the task node in the embodiment of the present invention (i.e., step S307) includes the following steps:

[0099] Step S701: traverse the service interfaces of the current task node and assign a thread to each service interface. The calling process of the service interface depends on the number of elements in executeTaskItemList. Assuming that executeTaskItemList includes n elements, these n elements can be handed over to n threads for processing. Use the same number of threads as the number of service interfaces in the current task node (the number of threads is controlled by a counter) to execute, ensuring that each service interface is executed by one thread.

[0100] Step S702: Process the service interface call through threads, and after all service interface processes are completed, merge the execution results of each thread to obtain a return result. In the embodiment, the thread barrier technology is used to ensure that all threads have completed execution when obtaining the result.

[0101] Step S703: Save the return result of the current task node.

[0102] It should be noted that if there are many service interfaces in the task node and few idle threads in the thread pool, batch processing can be performed to reduce thread overhead. After the current batch of service interfaces is executed, the next batch will be executed.

[0103] In a preferred embodiment, the parameter conversion of step S306 and step S309 is implemented by parsing the script to achieve a flexible and changeable effect. Figure 8 FIG. 1 is a schematic diagram of the implementation process of script parsing in the service orchestration method according to an embodiment of the present invention. Figure 8 As shown, the implementation process of script parsing in the embodiment of the present invention includes the following steps:

[0104] Step S801: Obtain a script engine according to the script type of the script to be parsed, and initialize the script engine when the class is initialized. The script to be parsed here can be an input parameter mapping script and a return result mapping script. The script type can be a Groovy script, a JavaScript script, a Python script, etc.

[0105] Taking Groovy script as an example, when selecting a script engine, the ScriptEngineManager provided by JDK can be used to obtain the script engine, eliminating the need to introduce a third-party jar package and avoiding jar package conflicts. In this embodiment, the script engine is initialized during class initialization, and the script engine is initialized by the static loading method to improve the execution efficiency of the script engine.

[0106] Step S802: Determine whether the script compilation package of the script to be parsed is saved. If not, execute step S803; otherwise, execute step S804. The script compilation package can be saved in a local cache or a distributed cache. For the script compilation package in the local cache, determine whether the script compilation package of the script to be parsed is saved in the local cache.

[0107] Step S803: Parse the script to be parsed, compile and package the obtained script content, obtain a script compilation package, save the script compilation package, and execute step S804. Use the script engine to parse the script to be parsed to obtain the script content. Since the variability of the script content is not high, the script compilation package can be saved in a local cache manner, saving script compilation time and improving script parsing efficiency.

[0108] Step S804: Execute the script to be parsed according to the script compilation package.

[0109] Step S805: Output the execution result. For the input parameter mapping script, the output is the service interface input parameter; for the return result mapping script, the output is the business processing result.

[0110] Fig. 9 Schematic diagram of the script parsing interface design in the service orchestration method according to an embodiment of the present invention. Fig. 9 As shown, the execStr method in the script parsing interface supports text type script parsing, the execFile method supports file type script parsing, and the script parsing interface can support multiple script language extensions.

[0111] Fig.10 FIG. 1 is a schematic diagram of the main modules of the service orchestration device according to an embodiment of the present invention. Fig.10 As shown, the service orchestration device 1000 of the embodiment of the present invention mainly includes:

[0112] The information acquisition module 1001 is used to obtain preset service configuration information according to the interface name and business input parameter in the call request. When a call request sent by a business line is received, the corresponding service configuration information is obtained from the business information according to the business identifier of the business input parameter in the call request and the interface name to be called. Among them, the service configuration information is used to customize the configuration of related service mapping information, call chain relationship, etc. according to business needs, and may specifically include service mapping information, service call information and service interface execution order.

[0113] The service mapping information includes the script address for integrating the return results of each task node. The service call information includes the interface name, method name, etc. of the service interface; the service interface execution order is the execution order of the service interface. The service call information and the service interface execution order reflect the call chain relationship between services. In the embodiment, the functions implemented by this module can be merged into the service parsing module 1002.

[0114] The service parsing module 1002 is used to obtain the corresponding service processing script according to the script address in the service mapping information, group the service interfaces of the service call information according to the execution order of the service interfaces, and use the service interfaces belonging to the same group as task nodes to generate a task queue. The service processing script implements the processing logic for result integration, which is pre-written and stored by the developer. After obtaining the service configuration information, the service mapping information of the service configuration information can be parsed to obtain the script address to obtain the service processing script.

[0115] After obtaining the service processing script, it is necessary to process the serial and parallel call relationship between the interfaces. In the embodiment, the service interfaces are sorted according to the execution order of the service interfaces. The service interfaces with the first execution order are sorted first, and the service interfaces with the later execution order are sorted last. The service interfaces with the same execution order form a group. All service interfaces in the same group are a task node, and the service interfaces within the task node are called in parallel, and the task nodes are called serially. All task nodes form a task queue according to the execution order of the service interfaces.

[0116] The service calling module 1003 is used to pull the task node from the task queue according to the service interface execution order of the service interface in the task node, use the thread to execute the service interface of the task node, and obtain the return result. According to the service interface execution order of the service interface in each task node, each task node is pulled from the task queue in turn.

[0117] When a task node is pulled, the number of threads is determined according to the number of service interfaces of the task node. Then, the corresponding number of threads are used to execute all service interfaces of the task node in parallel. After each service interface of the task node is executed, the execution results of each thread are merged to obtain the return result.

[0118] The service integration module 1004 is used to assemble the return result using the service processing script and return the assembled result. The processing logic of the result assembly is relatively personalized, so the service processing script can be written according to business needs, and the script can be used to process the return result of each task node in the task queue, and finally the return result of each task node and the assembled result can be returned to the business line. This embodiment customizes the service mapping relationship and the call chain relationship according to business needs through configuration, and can meet business needs with a little configuration without development.

[0119] In addition, the service orchestration device 1000 of the embodiment of the present invention may also include: an input parameter conversion module and an output parameter conversion module ( Fig.10 The input parameter conversion module is used to convert the business input parameter into the service interface input parameter through the input parameter mapping script before using the thread to execute the service interface of the task node. The output parameter conversion module is used to convert the return result into the business processing result through the return result mapping script before using the service processing script to assemble the return result.

[0120] From the above description, it can be seen that by pre-customizing the service mapping information, service call information and service interface execution order in the service configuration information, after receiving the call request, the call request is processed based on the service configuration information, and business needs can be met without development, which increases the flexibility of service calls, reduces development costs, and improves the product update cycle.

[0121] Fig.11 An exemplary system architecture 1100 is shown to which the service orchestration method or service orchestration apparatus according to the embodiments of the present invention can be applied.

[0122] like Fig.11 As shown, system architecture 1100 may include terminal devices 1101, 1102, 1103, a network 1104, and a server 1105. Network 1104 is used to provide a medium for communication links between terminal devices 1101, 1102, 1103 and server 1105. Network 1104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0123] The user can use the terminal devices 1101, 1102, 1103 to interact with the server 1105 through the network 1104 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 1101, 1102, 1103.

[0124] The terminal devices 1101 , 1102 , and 1103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.

[0125] The server 1105 may be a server that provides various services, such as a background management server that an administrator processes call requests sent by the terminal devices 1101, 1102, and 1103. The background management server may obtain service configuration information, process the call request according to the service configuration information, and feed back the processing result (e.g., assembly result) to the terminal device.

[0126] It should be noted that the service orchestration method provided in the embodiment of the present application is generally executed by the server 1105 , and accordingly, the service orchestration device is generally set in the server 1105 .

[0127] It should be understood that Fig.11 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0128] According to an embodiment of the present invention, the present invention also provides an electronic device and a computer-readable medium.

[0129] The electronic device of the present invention comprises: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a service orchestration method of an embodiment of the present invention. The computer-readable medium of the present invention stores a computer program, and when the program is executed by the processor, a service orchestration method of an embodiment of the present invention is implemented.

[0130] Reference below Fig.12 , which shows a schematic diagram of the structure of a computer system 1200 suitable for implementing an electronic device of an embodiment of the present invention. Fig.12 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0131] like Fig.12As shown, the computer system 1200 includes a central processing unit (CPU) 1201, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1202 or a program loaded from a storage part 1208 into a random access memory (RAM) 1203. In the RAM 1203, various programs and data required for the operation of the computer system 1200 are also stored. The CPU 1201, the ROM 1202, and the RAM 1203 are connected to each other via a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.

[0132] The following components are connected to the I / O interface 1205: an input section 1206 including a keyboard, a mouse, etc.; an output section 1207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1208 including a hard disk, etc.; and a communication section 1209 including a network interface card such as a LAN card, a modem, etc. The communication section 1209 performs communication processing via a network such as the Internet. A drive 1210 is also connected to the I / O interface 1205 as needed. A removable medium 1211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1210 as needed, so that a computer program read therefrom is installed into the storage section 1208 as needed.

[0133] In particular, according to the embodiments disclosed in the present invention, the process described in the main step diagram above can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the main step diagram. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1209, and / or installed from the removable medium 1211. When the computer program is executed by the central processing unit (CPU) 1201, the above-mentioned functions defined in the system of the present invention are executed.

[0134] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0135] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0136] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be provided in a processor. For example, they may be described as follows: a processor includes an information acquisition module, a service parsing module, a service calling module, and a service integration module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, the information acquisition module may also be described as a "module for obtaining preset service configuration information according to the interface name and business input parameters in the call request."

[0137] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: obtaining preset service configuration information according to the interface name and business input parameter in the call request; wherein the service configuration information includes service mapping information, service call information and service interface execution order; obtaining the corresponding service processing script according to the script address in the service mapping information, grouping the service interface of the service call information according to the service interface execution order, taking the service interface belonging to the same group as the task node, and generating a task queue; pulling the task node from the task queue according to the service interface execution order of the service interface in the task node, using the thread to execute the service interface of the task node, and obtaining the return result; assembling the return result using the service processing script, and returning the assembled result.

[0138] The above product can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to the method provided by the embodiment of the present invention.

[0139] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A service orchestration method, It is characterized in that include: According to the interface name and business input parameters in the call request, the preset service configuration information is obtained; wherein the service configuration information includes service mapping information, service call information and service interface execution order; the service mapping information is configured with a mapping relationship between the return result and the task execution order, and the service processing script includes a result integration script; According to the script address in the service mapping information, the corresponding service processing script is obtained, and according to the execution order of the service interfaces, the service interfaces of the service call information are grouped, and the service interfaces belonging to the same group are used as task nodes to generate a task queue; wherein the service interfaces with the same execution order of the service interfaces constitute a group; According to the service interface execution order of the service interface in the task node, the task node is pulled from the task queue, and the service interface of the task node is executed by a thread to obtain a return result; Assemble the returned result using the service processing script, and return the assembled result; Assembling the returned result using the service processing script includes: By executing the result integration script, the corresponding returned results are obtained according to the task execution order for personalized assembly.

2. The method according to claim 1, It is characterized in that The service mapping information is also configured with a mapping relationship between the business input and the service interface input, and the service processing script also includes an input parameter mapping script, and the input parameter mapping script is used to implement the mapping between the business input and the service interface input; Before the step of using a thread to execute the service interface of the task node, the method further includes: The business input parameter is converted into the service interface input parameter through the input parameter mapping script.

3. The method according to claim 1 or 2, It is characterized in that The service mapping information is also configured with a mapping relationship between the return result and the business processing result, and the service processing script also includes a return result mapping script, and the return result mapping script is used to realize the mapping between the return result and the business processing result; Before the step of assembling the returned result using the service processing script, the method further includes: Converting the returned result into the business processing result through the returned result mapping script; Assembling the returned result using the service processing script includes: By executing the result integration script, the corresponding business processing results are obtained according to the task execution order for personalized assembly.

4. The method according to claim 1, It is characterized in that Use the thread to execute the service interface of the task node to obtain the return result, including: Traversing the service interface of the task node; In the case where the task node includes a plurality of the service interfaces, the plurality of service interfaces are executed in parallel using the same number of threads as the number of the service interfaces; When the service interface of the task node is executed, the result integration script is used to merge the execution results of the multiple threads to obtain a return result.

5. The method according to claim 2, It is characterized in that Converting the business input parameter into the service interface input parameter by the input parameter mapping script includes: Obtaining a script engine according to the script type of the input parameter mapping script; According to the pre-saved script compilation package of the input parameter mapping script, the input parameter mapping script is executed to output the service interface input parameters.

6. The method according to claim 5, It is characterized in that After the step of obtaining the script engine, the method further includes: Determine whether a script compilation package of the input parameter mapping script is saved; In the case where the script compilation package is not saved, the script engine is used to parse the input parameter mapping script to obtain the script content; The script content is compiled and packaged to generate a script compilation package, and the script compilation package is saved.

7. A service arrangement device, It is characterized in that include: An information acquisition module is used to acquire preset service configuration information according to the interface name and business input parameters in the call request; wherein the service configuration information includes service mapping information, service call information and service interface execution order; the service mapping information is configured with a mapping relationship between the return result and the task execution order, and the service processing script includes a result integration script; A service parsing module, used to obtain the corresponding service processing script according to the script address in the service mapping information, group the service interfaces of the service call information according to the execution order of the service interfaces, and use the service interfaces belonging to the same group as task nodes to generate a task queue; wherein the service interfaces with the same execution order of the service interfaces constitute one group; A service calling module, used to pull the task node from the task queue according to the service interface execution order of the service interface in the task node, use a thread to execute the service interface of the task node, and obtain a return result; A service integration module, used to assemble the returned result using the service processing script and return the assembled result; The service integration module is further used to execute the result integration script to obtain the corresponding return results for personalized assembly according to the task execution order.

8. An electronic device, It is characterized in that include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

9. A computer readable medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Service arrangement and business process processing method and device applied to SaaS

    CN110310034A

  • Business instruction processing method and device, computer equipment and storage medium

    CN110351342A

  • Realtime Middleware apparatus providing an integratedsoftware development frameworks of embedded system andits service method

    KR1020020021237A

  • Generic web service adaptor for performing web service operations for multiple web service providers

    US9098315B1

  • Method, device and apparatus for flow scheduling

    WO2017193715A1

Cited By

  • Service workflow dynamic arrangement method and device based on multi-source medical event flow

    CN122658596A