Disclosure of Invention
In view of the foregoing, the present application provides a service request processing method and apparatus, and a service request processing system.
In order to achieve the above purpose, the technical scheme provided by the application is as follows:
according to a first aspect of the present application, a service request processing method is provided, including:
the method comprises the steps that a flow engine receives a service request carrying a request parameter value sent by a request end;
the flow engine determines a target flow template which comprises at least one flow object and corresponds to a request parameter value carried in the data request according to a flow template file, wherein the flow template file comprises a predetermined corresponding relation between the flow template and the request parameter value;
the process engine acquires and loads service codes corresponding to each process object in the target process template from a code component container, wherein the code component container stores pre-extracted universal code components and personalized code components, and codes in the code component container are updated in a dynamic deployment mode;
and the flow engine sequentially executes the service codes according to the sequence of the flow objects in the target flow template, obtains an execution result and returns the execution result to the request end.
According to a second aspect of the present application, a service request processing device is provided, which is applied to a flow engine, and the device includes a request receiving unit, a flow template determining unit, a code obtaining unit, and a code executing unit, wherein:
the request receiving unit receives a service request carrying a request parameter value sent by a request end;
the flow template determining unit determines a target flow template which comprises at least one flow object and corresponds to a request parameter value carried in the data request according to a flow template file, wherein the flow template file comprises a corresponding relation between a predetermined flow template and the request parameter value;
the code acquisition unit acquires and loads service codes corresponding to all flow objects in the target flow template from a code component container, wherein the code component container stores pre-extracted universal code components and personalized code components, and codes in the code component container are updated in a dynamic deployment mode;
and the code executing unit sequentially executes the service codes according to the sequence of the flow objects in the target flow template, obtains an executing result and returns the executing result to the request end.
According to a third aspect of the present application, a service request processing system is provided, including a flow engine, a code update server, a static component container, and a dynamic component container;
the static component container stores universal code components, and the dynamic component container stores personalized code components;
the code updating server is used for updating codes in the dynamic component container in a dynamic deployment mode;
the flow engine comprises a request receiving unit, a flow template determining unit, a code obtaining unit and a code executing unit, wherein:
the request receiving unit receives a service request carrying a request parameter value sent by a request end;
the flow template determining unit determines a target flow template which comprises at least one flow object and corresponds to a request parameter value carried in the data request according to a flow template file, wherein the flow template file comprises a corresponding relation between a predetermined flow template and the request parameter value;
the code acquisition unit acquires service codes corresponding to each flow object in the target flow template from a static component container and a dynamic component container and loads the service codes;
and the code executing unit sequentially executes the service codes according to the sequence of the flow objects in the target flow template, obtains an executing result and returns the executing result to the request end.
According to the technical scheme, codes (universal code components) which can be used in different business scenes and personalized code components which cannot be used in all business scenes are abstracted, and the code components are stored in a code component container. In the process of processing the service request, a target flow template corresponding to the service request and containing at least one flow object can be determined according to the request parameter value carried in the service request, then a required service code is obtained from the code component container and loaded, and finally the service codes are sequentially executed according to the sequence of the flow objects in the target flow template, so that an execution result is obtained and returned to the request end. The embodiment of the application can effectively promote maintainability and expandability of the flow engine. In addition, in the embodiment of the application, the code in the code component container can be updated in a dynamic deployment mode, so that the flexibility of code deployment is improved by combining a flow engine technology and a dynamic deployment technology, the update and upgrade of new realization logic are completed under the condition of not restarting an application server, and the code development cost is reduced.
Detailed Description
FIG. 1 is a system architecture, shown in accordance with an exemplary embodiment, that may include: application server, code update server, static component container and dynamic component container. The application server is provided with a flow engine, the static component container and the dynamic component container can be persisted in a specific Database (Database), and the code update server is provided with a background management program for updating code components stored in the Database, wherein the Database can be accessed through SQL sentences to realize operations of adding, deleting, modifying and searching. The application server is used for receiving the service request sent by the request end, executing corresponding processing actions and returning corresponding processing results. For example, the request end may be an external system or a client device used by a user. The application server needs to meet the requirements of different service scenarios, and can be implemented by service requests containing different request parameter values for different service scenarios. In general, the business processes that the process engine needs to process are also different for different business scenarios. This determines the code that the flow engine needs to execute in different traffic scenarios. For this reason, in the embodiment of the present application, code components that can be used in common for at least two different service scenarios (referred to as "common code components") and code components that cannot be used in common for different service scenarios (referred to as "personalized code components") may be abstracted in advance, so that, for convenience in code management, the static component container may be used to store the common code components, and the dynamic component container may be used to store the personalized code components. After receiving the service request, the flow engine can obtain and execute the required code components from the static component container and the dynamic component container respectively. The implementation will be described in detail below in conjunction with fig. 2.
As shown in fig. 2, the method may be applied to a process engine, which may be deployed on an application server, for example, which may function to provide data services to the outside. In one embodiment, the method includes the following steps 101-104, wherein:
in step 101, a service request carrying a request parameter value sent by a requesting end is received.
For example, the request parameters in each service request from the requesting end are as follows:
"serviceType", "tradeType" and "sceneType";
where "serviceType" may represent a service type, "tradeType" may represent a transaction type, and "sceneType" may represent a scene type.
Each service request needs to include a value corresponding to each request parameter, for example, "serviceType" = "trans_in", "tradeType" = "pkg_ BUY", "sceneType" = "QIANBAO01".
In step 102, a target flow template including at least one flow object corresponding to the request parameter value carried in the data request is determined according to a flow template file, where the flow template file includes a predetermined correspondence between the flow template and the request parameter value.
Since different service scenarios correspond to different service flows, it is necessary to implement by different service requests. In the embodiment of the application, the business processes (including which processes, the order among the processes, etc.) that need to be executed by a certain business scenario may be described by a process template including at least one process object. Therefore, the corresponding relation between the flow template and the request parameter value needs to be determined in advance, so that the target flow template corresponding to the business request can be determined quickly after the business request is received.
For example, the code content in one exemplary flow template file describing the correspondence of flow templates and request parameter values is as follows:
through the code content, when the values of the request parameters "serviceType", "tradeType" and "sceneType" IN the service request are "trans_in", "pkg_ BUY" and "QIANBAO01", respectively, the matched target flow template is composed of the following flow objects (according to the sequence):
"PRO-TRANS-IN-PKG-BUY-INIT" (scheme one);
"PRO-TRANS-IN-PKG-BUY-PRECHECK" (scheme II);
"PRO-TRANS-IN-PKG-BUY-APPLY" (scheme III);
"PRO-TRANS-IN-PKG-BUY-CONFIRM" (scheme IV);
"PRO-TRANS-IN-SUCCESS-RESULT-RETURN" or
"PRO-TRANS-IN-FAIL-RESULT-RETURN" (scheme five).
After step 102, the flow engine needs to instantiate the flow objects contained in the target flow template. In object-oriented programming, the process of creating objects with classes is often referred to as instantiation.
The above exemplary code only enumerates a flow template under one service scenario, in the actual operation process, a developer may set corresponding flow templates for other service scenarios according to actual requirements in advance, and add the corresponding flow templates to the flow template file in the form of code, which is not specifically enumerated here. It should be noted that, according to the development of the service, the developer may dynamically adjust the correspondence in the flow template file, where dynamic adjustment refers to adjustment without restarting the application server. The developer can upload the modified flow template file to a database accessible by the flow engine, and when the flow engine senses the change, the flow engine can route the business flow according to the changed flow template file.
In step 103, service codes corresponding to the flow objects in the target flow template are obtained from a code component container and loaded, wherein the code component container stores pre-extracted universal code components and personalized code components, and codes in the code component container are updated in a dynamic deployment mode.
In an alternative embodiment, the code component container may include a static component container storing generic code components and a dynamic component container storing personalized code components; the codes in the dynamic component container are updated in a dynamic deployment mode. The dynamic deployment can also be called as hot deployment (hotstart), and the hot deployment can automatically detect the change of a code file and update the behavior of a running code on the premise of not restarting a service server. In the embodiment of the application, compared with a static component container, due to the fact that the code in the dynamic component container needs to be changed frequently, the later maintenance cost of the dynamic component container is high along with the increase of service complexity, and expansibility is also general. Therefore, in the embodiment of the application, by combining the static component container and the dynamic component container, certain code components in the dynamic component container, which can be multiplexed by at least two business scenes, are transferred to the static component container for persistent storage periodically or irregularly, so that the code components stored in the dynamic component container are reduced as much as possible, the code components for loading by a flow engine are stored in the static component container as much as possible, and the maintenance cost is reduced. In other embodiments, when an object code component has not changed for a longer period of time, the object code may also be transferred from the dynamic component container to the static component container. For some newly added service scenes or personalized codes for realizing logic, the newly added service scenes or personalized codes for realizing logic can be stored in the dynamic component container in a dynamic deployment mode, so that restarting of an application server is avoided, and uninterrupted service operation is ensured. In an embodiment, the generic code component is packed JAVA code (compiled JAVA code), and the personalized code component is JAVA class and/or dynamic script (e.g. a grovy script) and/or EL expression, etc. that need to be loaded dynamically.
Based on the above, in an alternative embodiment, step 103 may specifically include:
step 1031: the flow engine determines a universal code component and a personalized code component required by realizing the target flow template according to each flow object contained in the target flow template;
step 1032: a flow engine acquires the universal code component from the static component container;
step 1033: a flow engine obtains the personalized code component from the dynamic component container.
For example, the specific implementation code of each flow object in the target flow template is as follows:
wherein, the various process objects can be realized by one or more 'actions'. The implementation code of each "action" may be written in JAVA statements, and/or EL (Expression Language) expressions, and/or groovy scripts, etc. Taking the foregoing "action" as an example, the "action" can be divided into "action" (i.e. a generic component) that can be used by different service scenarios, and "action" (i.e. a personalized component) that cannot be used by different service scenarios. The developer may define in advance a corresponding tag for each code component that is abstracted to indicate whether it belongs to a generic component or a personalized component.
In the embodiment of the application, after the required universal component and the required personalized component are respectively acquired from the static component container and the dynamic component container, the acquired service codes can be loaded. The process of reading the code from the database into the memory of the application server is the loading process.
In step 104, the service codes are executed in sequence according to the sequence of the flow objects in the target flow template, and an execution result is obtained and returned to the request end.
The loaded service codes can be circularly executed according to the actual service requirement until the required execution result is obtained. Of course, if the execution result (execution exception) cannot be obtained, the corresponding exception information may be returned to the requesting end.
By the service request processing method, the codes which can be used universally and the personalized codes which cannot be used universally in different service scenes are abstracted and are respectively persisted into the static component container and the dynamic component container, so that maintainability and expandability of the flow engine can be effectively improved, maintenance cost is effectively reduced, and execution efficiency of the flow engine is improved to a certain extent. In addition, the code components in the dynamic component container can be updated in a dynamic deployment mode, so that the flexibility of code deployment is improved by combining a flow engine technology and a dynamic deployment technology, the update and upgrade of new realization logic are completed under the condition of not restarting an application server, and the code development cost is reduced.
Fig. 3 is a hardware structure of an electronic device, which is shown according to an exemplary embodiment. Referring to fig. 3, at a hardware level, the electronic device may be an application server deployed with a flow engine, where the application server may include a processor, an internal bus, a network interface, a memory (including a memory and a nonvolatile memory), and may include hardware required by other services. Wherein, the memory can store related logic (i.e. computer program) for implementing the service request processing method, and the processor can read the corresponding computer program from the nonvolatile memory into the memory and then run the corresponding computer program. Of course, other implementations, such as logic devices or combinations of hardware and software, are not excluded from the present application, that is, the execution subject of the following processing flows is not limited to each logic unit, but may be hardware or logic devices.
As shown in fig. 4, in an embodiment, a service request processing apparatus 200 may be applied to a flow engine, where the apparatus 200 may include a request receiving unit 201, a flow template determining unit 202, a code obtaining unit 203, and a code executing unit 204, where:
the request receiving unit 201 receives a service request carrying a request parameter value sent by a request end.
The flow template determining unit 202 determines a target flow template corresponding to the request parameter value carried in the data request and including at least one flow object according to a flow template file, where the flow template file includes a predetermined correspondence between the flow template and the request parameter value.
The code obtaining unit 203 obtains and loads service codes corresponding to each flow object in the target flow template from a code component container, where the code component container stores pre-extracted universal code components and personalized code components, and the codes in the code component container are updated in a dynamic deployment manner.
The code executing unit 204 executes the service codes sequentially according to the sequence of the flow objects in the target flow template, and obtains an execution result and returns the execution result to the request end.
In an alternative embodiment, the code component container includes a static component container storing generic code components and a dynamic component container storing personalized code components.
The code obtaining unit 203 may specifically include:
a determining subunit, configured to determine, according to each flow object included in the target flow template, a universal code component and a personalized code component required for implementing the target flow template;
a first obtaining subunit, configured to obtain the generic code component from the static component container;
and the second acquisition subunit acquires the personalized code component from the dynamic component container.
In an alternative embodiment, the code in the dynamic component container may be updated by dynamic deployment.
In an alternative embodiment, the apparatus further comprises:
and the code transfer unit is used for transferring the target code from the dynamic component container to the static component container when the target code in the dynamic component container is multiplexed by at least two business scenes.
In an alternative embodiment, the apparatus further comprises:
and the instantiation unit instantiates each flow object contained in the target flow template.
In an alternative embodiment, the generic code component is packed JAVA code and the personalized code component is JAVA class, and/or dynamic script, and/or EL expression, which need to be dynamically loaded.
The steps implemented when the above computer program is executed by the processor may refer to the description of the method embodiment above, and, on the premise of no conflict, the content of the apparatus embodiment above and the content of the method embodiment above may be complementary, which will not be described in detail.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being functionally divided into various units, respectively. Of course, the functions of each element may be implemented in one or more software and/or hardware elements when implemented in the present application.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash memory (flashRAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transshipment) such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.