CN110597607B - Execution method and device of asynchronous application program, storage medium and electronic equipment - Google Patents
Execution method and device of asynchronous application program, storage medium and electronic equipment Download PDFInfo
- Publication number
- CN110597607B CN110597607B CN201910792504.4A CN201910792504A CN110597607B CN 110597607 B CN110597607 B CN 110597607B CN 201910792504 A CN201910792504 A CN 201910792504A CN 110597607 B CN110597607 B CN 110597607B
- Authority
- CN
- China
- Prior art keywords
- node
- target
- branch
- concurrent
- asynchronous
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Stored Programmes (AREA)
Abstract
The present disclosure relates to an execution method, an execution device, a storage medium, and an electronic device for an asynchronous application, which are applied to a concurrency body, and may determine a target branch from a plurality of concurrent branches in the concurrency body, where the target branch is a concurrent branch executed to a last node in the concurrency body, and the last node is a concurrent branch of an asynchronous automatic node; the asynchronous automatic node is an automatic node for mounting an asynchronous application program; acquiring the number of the target branches; if the number of the target branches is larger than or equal to a preset number threshold, acquiring a preset execution priority of the asynchronous application program executed by the tail node of each target branch; determining an execution sequence of executing the corresponding asynchronous application program by the tail node of each target branch according to the preset execution priority; and sequentially executing the asynchronous application programs respectively corresponding to the tail nodes of the target branches according to the execution sequence.
Description
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to an execution method and apparatus for an asynchronous application, a storage medium, and an electronic device.
Background
At present, a flow chart is widely applied to various business fields, and in general, each business process is composed of a set of process nodes representing a start step, an end step and an intermediate step, in order to improve the efficiency of business process execution, a concurrency body execution mode is mostly adopted to perform the operation of the process, that is, a process set composed of a plurality of business processes (each business process can be regarded as a concurrency branch in the concurrency body) which need to be executed simultaneously is executed as one concurrency body, the concurrency body is used as an execution whole in the process operation process, and the operation of the process is continued only after all the execution of the concurrency branches in the concurrency body is completed.
In the related art, a pessimistic lock mechanism may be adopted, after each concurrent branch is executed, the remaining number of branches of the concurrent entity is read from the database each time, but when the concurrency amount is large, the database is frequently accessed, which results in too long time for accessing the database, high performance cost of the database, and poor concurrency.
Disclosure of Invention
The invention aims to provide an execution method, an execution device, a storage medium and an electronic device of an asynchronous application program.
In a first aspect, a method for executing an asynchronous application program is provided, which is applied to a concurrency body, and the method includes: determining a target branch from a plurality of concurrent branches within the concurrency body, the target branch being a concurrent branch executed to a last node within the concurrency body, and the last node being a concurrent branch of an asynchronous automatic node; the asynchronous automatic node is an automatic node for mounting an asynchronous application program; acquiring the number of the target branches; if the number of the target branches is larger than or equal to a preset number threshold, acquiring a preset execution priority of the asynchronous application program executed by the tail node of each target branch; determining an execution sequence of executing the corresponding asynchronous application program by the tail node of each target branch according to the preset execution priority; and sequentially executing the asynchronous application programs respectively corresponding to the tail nodes of the target branches according to the execution sequence.
Optionally, the determining a target branch from a plurality of concurrent branches within the concurrency body comprises: determining whether a target node to be executed currently is a tail node or not for each of the plurality of concurrent branches; if the target node to be executed currently is the end node, determining whether the end node of the concurrent branch is the asynchronous automatic node; and if the tail node of the concurrent branch is the asynchronous automatic node, determining the concurrent branch as the target branch.
Optionally, the determining whether the target node to be executed currently is a tail node includes: acquiring node attribute information of a next node of the target node, wherein the next node is a node directly pointed by the target node in the flow node corresponding to the concurrent branch; determining whether the next node is a preset concurrency body end node or not according to the node attribute information of the next node; and if the next node is the concurrency end node, determining that the current target node to be executed is the end node.
Optionally, after the executing the asynchronous application programs respectively corresponding to the end nodes of each of the target branches in sequence according to the execution order, the method further includes: determining whether the execution of the corresponding asynchronous application by the end node of each target branch is successful; and deleting the preset execution priority corresponding to the end node which successfully executes the asynchronous application program from the execution sequence.
In a second aspect, an apparatus for executing an asynchronous application, applied to a concurrency object, includes: a first determining module, configured to determine a target branch from multiple concurrent branches within the concurrency body, where the target branch is a concurrent branch executed to a last node within the concurrency body, and the last node is an asynchronous automatic node; the asynchronous automatic node is an automatic node for mounting an asynchronous application program; the first acquisition module is used for acquiring the number of the target branches; a second obtaining module, configured to obtain a preset execution priority for executing the asynchronous application program by a tail node of each target branch if the number of the target branches is greater than or equal to a preset number threshold; a second determining module, configured to determine, according to the preset execution priority, an execution sequence in which a last node of each target branch executes a corresponding asynchronous application program; and the program execution module is used for sequentially executing the asynchronous application programs corresponding to the tail nodes of the target branches according to the execution sequence.
Optionally, the first determining module is configured to determine, for each of the multiple concurrent branches, whether a target node to be currently executed is a tail node; if the target node to be executed currently is the end node, determining whether the end node of the concurrent branch is the asynchronous automatic node; and if the tail node of the concurrent branch is the asynchronous automatic node, determining the concurrent branch as the target branch.
Optionally, the first determining module is configured to obtain node attribute information of a next node of the target node, where the next node is a node to which the target node directly points in the flow node corresponding to the concurrent branch; determining whether the next node is a preset concurrency body end node or not according to the node attribute information of the next node; and if the next node is the concurrency end node, determining that the current target node to be executed is the end node.
Optionally, the apparatus further comprises: a third determining module, configured to determine whether execution of the corresponding asynchronous application by a last node of each of the target branches is successful; and the deleting module is used for deleting the preset execution priority corresponding to the end node which successfully executes the asynchronous application program from the execution sequence.
In a third aspect, a computer readable storage medium is provided, on which a computer program is stored, which program, when being executed by a processor, carries out the steps of the method according to the first aspect of the disclosure.
In a fourth aspect, an electronic device is provided, comprising: a memory having a computer program stored thereon; a processor for executing said computer program in said memory to implement the steps of the method of the first aspect of the present public card.
By the technical scheme, a target branch can be determined from a plurality of concurrent branches in a concurrent body, wherein the target branch is a concurrent branch executed to a tail node in the concurrent body, and the tail node is an asynchronous automatic node; the asynchronous automatic node is an automatic node for mounting an asynchronous application program; acquiring the number of the target branches; if the number of the target branches is larger than or equal to a preset number threshold, acquiring a preset execution priority of the asynchronous application program executed by the tail node of each target branch; determining an execution sequence of executing the corresponding asynchronous application program by the tail node of each target branch according to the preset execution priority; and sequentially executing the asynchronous application programs corresponding to the tail nodes of all the target branches according to the execution sequence, so that the asynchronous application programs corresponding to the tail nodes of all the target branches in the concurrency body can be sequentially executed in the same thread according to the execution sequence, the problem that the updating of the concurrency information (such as the residual number of the unexecuted concurrent branches) fails due to the fact that a plurality of threads compete for messages is solved, the times of accessing the database under high concurrency are reduced, and the performance overhead of the database is saved.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
FIG. 1 is a flow diagram illustrating a method performed by a first asynchronous application in accordance with an illustrative embodiment;
FIG. 2 is a flow diagram illustrating a method performed by a second type of asynchronous application in accordance with an illustrative embodiment;
FIG. 3 is a diagram illustrating a concurrency body composed of a telecommunication service composition flow, according to an exemplary embodiment;
FIG. 4 is a block diagram illustrating an apparatus for asynchronous application execution of a first type in accordance with an illustrative embodiment;
FIG. 5 is a block diagram illustrating an apparatus for execution of a second type of asynchronous application in accordance with an illustrative embodiment;
fig. 6 is a block diagram illustrating a structure of an electronic device according to an example embodiment.
Detailed Description
The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.
First, an application scenario of the present disclosure is introduced, where the present disclosure is mainly applied to a scenario in which, during concurrent execution of each concurrent branch in a concurrency body, an asynchronous application installed on a last node of the concurrent branch of the concurrency body is scheduled, the concurrency body generally refers to a branch set composed of multiple concurrent branches that need to be executed simultaneously, and each concurrent branch can be regarded as an individual service flow, and the concurrency body serves as an execution whole in a flow operation process, and after all the concurrent branches in the concurrency body are executed, the flow operation will be continued, and when an application installed on the last node of multiple concurrent branches in the concurrency body is an asynchronous application, a problem of multi-thread message contention will occur by using an existing multi-thread parallel execution method, and update failure of concurrent information (such as the remaining number of unexecuted concurrent branches) is easily caused, in the related art, a mechanism of pessimistic lock may be adopted, only one concurrent branch is executed each time in the execution process of the concurrency body, and the other concurrent branches are in a locked state, and after the execution of the one concurrent branch is completed, the number of the remaining branches that are not executed in the concurrency body is read from the database, that is, the scheme of pessimistic lock reads the number of the remaining branches of the concurrency body from the database each time after the execution of each concurrent branch is completed, but when the concurrency amount is large, the database is frequently accessed, so that the time for accessing the database is too long, the performance overhead of the database is large, and the concurrency is not good.
In order to solve the existing problems, the present disclosure provides an execution method, an execution apparatus, a storage medium, and an electronic device for an asynchronous application, which may first determine, from a plurality of concurrent branches in a concurrent body, that the concurrent body is executed to a last node (the last node refers to a last node of the concurrent branch), and the last node is a target branch of an asynchronous automatic node on which the asynchronous application is mounted, and then obtain the number of the target branch, if the number of the target branch is greater than or equal to a preset number threshold, during the execution of the asynchronous application by the last node of the target branch of the concurrent body, if an existing multi-thread parallel execution method is adopted, a problem of multi-thread message contention may occur, thereby causing a problem that the update of the concurrent information (e.g., the remaining number of the unexecuted concurrent branches) fails, and in order to avoid the problem, if the number of the target branch is greater than or equal to the preset number threshold, the method can obtain the preset execution priority of the asynchronous application program executed by the tail node of each target branch, and then determine the execution sequence of the asynchronous application program corresponding to the execution of the tail node of each target branch according to the preset execution priority, so that the asynchronous application program corresponding to the tail node of each target branch can be sequentially executed according to the execution sequence, the asynchronous application program is sequentially executed in the same thread according to the execution sequence, the problem that updating of concurrent information (such as the residual number of unexecuted concurrent branches) fails due to message contention of multiple threads is solved, meanwhile, the number of times of accessing the database under high concurrency is reduced, and the performance overhead of the database is saved.
Fig. 1 is a flow chart illustrating a method of execution of an asynchronous application, applied to a concurrency body, according to an example embodiment, the method comprising the steps of:
in step 101, a target branch is determined from a plurality of concurrent branches within a concurrency body.
The concurrent body generally refers to a branch set composed of multiple concurrent branches that need to be executed simultaneously, each concurrent branch can be regarded as a separate business process, the concurrent body serves as an execution whole in the process of process operation, and the process operation is continued only after all the concurrent branches in the concurrent body are executed; the target branch is executed in the concurrency body to a tail node, and the tail node is a concurrent branch of the asynchronous automatic node; the asynchronous automatic node is an automatic node for mounting an asynchronous application program, and it should be noted that the end nodes in the present disclosure all refer to the end nodes of a certain concurrent branch in the concurrency.
In this step, it may be determined, for each of a plurality of the concurrent branches, whether a target node to be currently executed is a tail node; if the target node to be executed currently is the end node, determining whether the end node of the concurrent branch is the asynchronous automatic node; and if the tail node of the concurrent branch is the asynchronous automatic node, determining the concurrent branch as the target branch.
In addition, in the process of determining whether the current target node to be executed is the end node, the node attribute information of the next node of the target node can be acquired, and the next node is the node directly pointed by the target node in the flow nodes corresponding to the concurrent branches; determining whether the next node is a preset concurrency body end node or not according to the node attribute information of the next node; and if the next node is the concurrency end node, determining that the target node to be executed currently is the end node.
The node attribute information may include a node type of the corresponding node, for example, any one of a plurality of node types such as a manual node, an automatic node, a sub-process node, a concurrence start node, and a concurrence end node, and information such as a program type of an application (e.g., a synchronous application or an asynchronous application) mounted on the corresponding node.
In step 102, the number of target branches is obtained.
In step 103, if the number of the target branches is greater than or equal to the preset number threshold, a preset execution priority for executing the asynchronous application program by the end node of each of the target branches is obtained.
The preset number threshold is generally set to a value greater than or equal to 2, the preset execution priority is used to indicate an execution sequence of the asynchronous application executed by the corresponding end node, and the preset execution priority may be preset according to different service requirements, for example, the preset execution priority may be set according to a level (e.g., VIP user) or a credit of a service user corresponding to the target branch, and the higher the level of the service user is (or the higher the credit of the service user is), the higher the preset execution priority is for the asynchronous application executed by the end node of the corresponding target branch, which is merely an example and is not limited by the present disclosure.
In addition, when the preset execution priority of the asynchronous application program executed by the tail node of the target branch is obtained, the program identification information of the asynchronous application program mounted by the tail node of the target branch and the node execution information such as the instance identification information of the instance created at the tail node can be obtained, so that the corresponding tail node can conveniently call and execute the program according to the program identification information and the instance identification information.
In step 104, an execution sequence of the asynchronous application executed by the end node of each target branch is determined according to the preset execution priority.
In this step, the node execution information corresponding to the end node of each of the obtained target branches may be merged to obtain an execution policy corresponding to the end node of each of the target branches of the concurrency, where the node execution information includes the preset execution priority, and the preset execution priority is used to indicate an execution order in which the corresponding end node executes the asynchronous application program, so that the execution order may be determined according to the preset execution priority corresponding to the end node of the target branch in the merged execution policy, for example, the execution order may be obtained according to an order from high to low of the preset execution priority.
In step 105, the asynchronous applications respectively corresponding to the end nodes of each target branch are sequentially executed according to the execution order.
After the step is executed, the asynchronous application program can be sequentially executed in the same thread according to the execution sequence, and the problem that updating of concurrent information (such as the residual number of unexecuted concurrent branches) fails due to the fact that a plurality of threads contend for messages is solved.
By adopting the method, the asynchronous application programs corresponding to the tail nodes of all target branches in the concurrency body are arranged, so that the asynchronous application programs can be sequentially executed in the same thread according to the execution sequence, the problem that updating of concurrent information (such as the residual number of unexecuted concurrent branches) fails due to the fact that a plurality of threads compete for messages is solved, meanwhile, the times of accessing the database under high concurrency are reduced, and the performance expense of the database is saved.
Fig. 2 is a flow chart illustrating a method of execution of an asynchronous application, applied to a concurrency body, according to an example embodiment, the method comprising the steps of, as shown in fig. 2:
in step 201, node attribute information of a node next to the target node is obtained for each of a plurality of concurrent branches within the concurrent body.
Wherein the concurrency body generally refers to a branch set composed of multiple concurrent branches that need to be executed simultaneously, and each concurrent branch can be regarded as a separate service flow, and the concurrency body serves as an execution whole in the process operation process, and after all the concurrent branches in the concurrency body are executed, the operation of the process is continued, the target node refers to a node currently to be executed in each concurrent branch, and the next node is a node directly pointed to by the target node in the process nodes corresponding to the concurrent branches, for example, assuming that one of the concurrent branches is a service flow composed of three nodes, node 1, node 2 and node 3, and node 1 points to node 2, node 2 points to node 3, if the service flow is being executed, and node 1 is executed at the current time, the service flow flows to node 2, the node 2 is the target node to be executed currently, and the node 3 is the next node of the target node, which is only an example and is not limited by the present disclosure, and the node attribute information may include a node type of the corresponding node, for example, any node type of multiple node types such as a manual node, an automatic node, a subprocess node, a concurrence start node, and a concurrence end node, and information such as a program type of an application (e.g., a synchronous application or an asynchronous application) hung by the corresponding node.
It should be noted that, before executing this step, the concurrency body needs to be formed according to actual service requirements, in an actual application scenario, a plurality of dynamic branches forming the concurrency body are defined in a flow template, and generally, services corresponding to different dynamic branches are different, so that the corresponding dynamic branches can be allocated according to actual service types (such as mobile network service, IPTV (Internet Protocol Television) service, home broadband service, and the like), and then the number of the concurrent branches formed by each dynamic branch is determined according to the actual service volume of each service.
Illustratively, fig. 3 is a schematic diagram of a concurrency body composed of a telecommunication service combination flow shown in fig. 3, where the combination flow includes a mobile Network sub-flow, an IPTV sub-flow, a home broadband sub-flow, a LAN (Local Area Network) sub-flow, a PSTN (Public Switched Telephone Network) service sub-flow, and an NGN (Next Generation Network) service sub-flow, in an actual service process, in order to improve the service processing efficiency, the service may be processed in batches, for example, in an actual service process, 5 mobile phone number services are processed in real time, 3 Network television services are processed in real time, then the dynamic branch of the "mobile Network sub-flow" shown in fig. 3 may create 5 concurrent branches at the same time, the dynamic branch of the "IPTV sub-flow" may create 3 concurrent branches at the same time, and the other branches not participating in the service processing are not created, that is, a total of 8 concurrent branches are created inside the concurrent body, and at this time, a concurrent body composed of the 8 concurrent branches is formed, and the above example is only an example, and the disclosure does not limit this.
In step 202, it is determined whether the target node to be executed currently is the end node of the concurrent branch according to the node attribute information of the next node.
In general, a parallel body includes a preset parallel body start node and a parallel body end node (as shown in fig. 3), a first node of each parallel branch in the parallel body is directly connected to the parallel body start node, and a last node of each parallel branch in the parallel body (i.e. a last node of the parallel branch) is connected to the parallel body end node, so that in this step, it can be determined whether the next node is a preset parallel body end node according to the node attribute information of the next node; and if the next node is the concurrency end node, determining that the target node to be executed currently is the last node.
In a possible implementation manner, different node types may be represented by different type identifier information, so that the type identifier information of the next node may be directly obtained from the node attribute information of the next node, and then, according to the type identifier information, it is determined whether the next node is the concurrency body end node by querying a corresponding relationship between the type identifier information and a node type, for example, the node type of the node in the concurrency body includes five types, which are a manual node, an automatic node, a sub-process node, a concurrency body start node, and a concurrency body end node, assuming that the manual node is represented by 8, the automatic node is represented by 9, the sub-process node is represented by 11, the concurrency body start node is represented by 15, and the concurrency body end node is represented by 16, at this time, when the type identifier information of the next node is obtained as 16, it may be determined that the next node is the concurrency body end node, it may further be determined that the target node is the end node of the concurrent branch, otherwise, the target node is not the end node of the concurrent branch, which is only an example and is not limited by the present disclosure.
If it is determined that the target node to be executed currently is the end node of the concurrent branch, execute step 204;
if it is determined that the target node to be executed currently is not the end node of the concurrent branch, step 203 is executed.
In step 203, after the target node completes its execution, it is continuously determined whether the next node of the target node is the end node of the concurrent branch.
In this step, the target node may call and execute the application program corresponding to the target node according to the existing method, and after the target node is executed, continue to determine whether the next node of the target node is the end node of the concurrent branch according to the method described in step 202 until the end node of the concurrent branch is determined.
In step 204, it is determined whether the end node of the concurrent branch is an asynchronous automation node.
In an actual application scenario, each process node needs to complete a corresponding node function (such as a request for approval, a business work order generation, and the like) by calling a mounted application program, the functions completed by each process node are different, the mounted application programs are also different, the application programs generally include two types, namely a synchronous application program and an asynchronous application program, and the asynchronous automatic node is an automatic node for mounting the asynchronous application program.
In a possible implementation manner, node attribute information of a last node of the concurrent branch may be obtained, and then, whether the last node is an automatic node is determined according to the node attribute of the last node recorded in the node attribute information (refer to the specific implementation manner in step 202), if it is determined that the last node is the automatic node, it may be further determined whether an application program mounted by the last node is an asynchronous application program according to the program type of the application program mounted by the last node recorded in the node attribute information, and if it is determined that the application program mounted by the last node is an asynchronous application program, it may be determined that the last node is the asynchronous automatic node.
It should be further noted that, in the process of determining whether the end node of the concurrent branch is an asynchronous automatic node, if it is determined that the end node is not an automatic node but a sub-flow node, because each sub-flow node is a complete flow composed of a series of flow sub-nodes, if it is determined that the end node is the sub-flow node, it may continue to determine the end node of the complete flow corresponding to the sub-flow node according to the specific implementation manner of step 202, regard the end node of the complete flow as the end node of the concurrent branch, and then further determine whether the end node of the complete flow is the asynchronous automatic node according to the specific implementation manner of step 203.
If it is determined that the end node of the concurrent branch is not the asynchronous automatic node, go to step 205;
if the end node of the concurrent branch is determined to be the asynchronous automatic node, go from step 206 to step 212;
in step 205, it is determined that the concurrent branch is not the target branch.
In step 206, the concurrent branch is determined to be the target branch.
Wherein the target branch is a concurrent branch executed within the concurrency body to a last node, and the last node is a concurrent branch of the asynchronous automatic node.
In step 207, the number of the target branches in the concurrency is obtained.
Considering an actual application scenario, if the number of the target branches is 0, it may be determined that end nodes of all concurrent branches in the concurrence body are not the asynchronous automatic node; if the number of the target branches is 1, it may be determined that the last node of only one concurrent branch exists in the parallel entity is the asynchronous automatic node, in the two cases, in the process of parallel execution of the concurrent branches of the parallel entity, when the last node of each concurrent branch executes the corresponding application program, there is no problem of message contention, that is, there is no problem that updating of the concurrent information (for example, the remaining number of the unexecuted concurrent branches) fails, and when the number of the target branches is greater than or equal to 2, it is determined that the last node of two or more concurrent branches exists in the parallel entity is the asynchronous automatic node, and at this time, if the arrangement of the asynchronous application program is not performed (the arrangement may be understood as defining the execution sequence of the asynchronous application program executed by the last node of each target branch), a plurality of thread contention messages may be caused, and results in the problem of failure of concurrent information update, in this embodiment, the asynchronous applications corresponding to the end nodes of the target branch may be scheduled by executing step 208 to step 209, and then the scheduled asynchronous applications are scheduled by executing step 210.
In step 208, if the number of the target branches is greater than or equal to the predetermined number threshold, a predetermined execution priority for the end node of each of the target branches to execute the asynchronous application is obtained.
The preset number threshold is generally set to a value greater than or equal to 2, the preset execution priority is used to indicate an execution sequence of the asynchronous application executed by the corresponding end node, and the preset execution priority may be set in advance according to different service requirements, for example, the preset execution priority may be set according to a level (such as a VIP user) or a credit of a service user corresponding to the target branch, where the higher the level of the service user is (or the higher the credit of the service user is), the higher the preset execution priority is for the asynchronous application executed by the end node corresponding to the target branch, which is only by way of example and is not limited by the present disclosure.
In addition, when the preset execution priority of the asynchronous application program executed by the tail node of the target branch is obtained, the program identification information of the asynchronous application program mounted by the tail node of the target branch and the node execution information such as the instance identification information of the instance created at the tail node can be obtained, so that the corresponding tail node can conveniently call and execute the program according to the program identification information and the instance identification information.
In a possible implementation manner, node execution information, such as a preset execution priority for the corresponding end node to execute the asynchronous application, program identification information of the asynchronous application mounted by the end node, and instance identification information of an instance created at the end node, may be obtained from node attribute information respectively corresponding to the end nodes of each target branch.
In step 209, the execution order of the asynchronous application executed by the end node of each target branch is determined according to the preset execution priority.
In this step, the node execution information corresponding to the end node of each of the obtained target branches may be merged to obtain an execution policy corresponding to the end node of each of the target branches of the concurrency, where the node execution information includes the preset execution priority, and the preset execution priority is used to indicate an execution order in which the corresponding end node executes the asynchronous application program, so that the execution order may be determined according to the preset execution priority corresponding to the end node of the target branch in the merged execution policy, for example, the execution order may be obtained according to an order from high to low of the preset execution priority.
It should be noted that after the step 208 is executed, although the preset execution priority of the asynchronous application corresponding to the end node of each target branch is already obtained, the preset execution priority only indicates the execution sequence of the asynchronous application mounted by the corresponding end node, and cannot determine whether the end nodes of other target branches whose execution sequences are prior to the end node have already been executed, that is, cannot determine whether the end nodes can start executing the mounted asynchronous application, so in this step, the preset execution priorities corresponding to the end nodes of all target branches may be merged to obtain the execution sequence, so as to implement that the end nodes of the corresponding target branches execute the asynchronous application in sequence according to the execution sequence in the same thread.
In addition, because the concurrent body is taken as the whole of the execution of one flow, the operation of the flow is continued after all the concurrent branches of the concurrent body are executed, therefore, in order to ensure that the asynchronous application program mounted on the tail node of all target branches in the concurrency is arranged, the above-mentioned node execution information (including the preset execution priority, the program identification information and the instance identification information) of the asynchronous application program executed by the end nodes of all target branches can be recorded in the same branch instance array (branchActInstArray), and each time the node execution information corresponding to the end node of one target branch is recorded, the number of the target branches is reduced by 1, so that, when the number of target branches after being reduced by 1 is determined to be 0, it may be determined that the node execution information recording that the end nodes of all the target branches have executed the corresponding asynchronous application is completed.
For example, assuming that the preset number threshold is 2 and the number of the obtained target branches is 3 after step 207 is executed, at this time, it may be determined that the number of the target branches is greater than the preset number threshold, at this time, asynchronous applications corresponding to end nodes of the three target branches need to be scheduled, and for convenience of description, actinstId may be used for the purpose of descriptioniExample identification information corresponding to the end node representing the i (i ═ 1,2,3) th target branch is denoted by appIdiThe priority is used to indicate the program identification information of the asynchronous application program mounted on the last node of the ith target branchiThe preset execution priority of the asynchronous application corresponding to the end node execution of the ith target branch is shown, so that the node execution information corresponding to the end node which acquires the target branch 1 after the step 208 is assumed to be [ actinstId1,appId1,priority1]The node execution information corresponding to the acquired end node of the target branch 1 may be recorded in the branch instance array branchactantsarray, where branchactantsarray { [ actinstId { [ action inst } { (a)1,appId1,priority1]And subtracting 1 from 3, namely the number of the target branches is 2, and similarly, the node execution information corresponding to the end node where the target branch 2 is obtained is [ actiontid ]2,appId2,priority2]Then, the node execution information corresponding to the acquired end node of the target branch 2 may be continuously recorded in the branch instance array branchactantsarray, where branchactantsarray { [ actinstId ])1,appId1,priority1];[actinstId2,appId2,priority2]And subtracting 1 from the number 2 of the target branches, wherein the number of the target branches is 1, and the node execution information corresponding to the end node acquiring the target branch 3 is [ actiontid ]3,appId3,priority3]Then, the node execution information corresponding to the acquired end node of the target branch 3 may be continuously recorded in the branch instance array branchactantsarray, where branchactantsarray { [ actinstId ])1,appId1,priority1];[actinstId2,appId2,priority2];[actinstId3,appId3,priority3]And subtracting 1 from the number of the target branches, where the number of the target branches is 0, and since the number of the target branches subtracted by 1 at this time is 0, it may be determined that all the node execution information of the asynchronous application executed by the last node of the three target branches is completely recorded, so as to obtain the execution information { [ actionid ] recorded in the branch instance array branchact instraray after merging1,appId1,priority1];[actinstId2,appId2,priority2];[actinstId3,appId3,priority3]The foregoing examples are illustrative only, and the disclosure is not limited thereto.
In step 210, the asynchronous applications respectively corresponding to the end nodes of each target branch are sequentially executed according to the execution order.
For example, it is assumed that after the step 209 is executed, it may be determined that the execution sequence of executing the corresponding asynchronous application program by the end node of the 3 target branches is that the corresponding asynchronous application program is executed by the end node of the target branch 3 first, then the corresponding asynchronous application program is executed by the end node of the target branch 1, and finally the corresponding asynchronous application program is executed by the end node of the target branch 2, so in this step, the asynchronous application programs may be executed by the end nodes of the corresponding target branches in sequence according to the execution sequence in the same thread.
In step 211, it is determined whether the end node of each of the target branches successfully executes the corresponding asynchronous application.
In a possible implementation manner, an execution result of the asynchronous application executed by the end node of each target branch may be obtained, where the execution result includes an execution success or an execution failure, and then it is determined whether the asynchronous application executed by the end node of each target branch is successful according to the execution result.
In step 212, the default execution priority corresponding to the end node that successfully executed the asynchronous application is removed from the execution order.
In this step, if the end node of each target branch in the concurrency body successfully executes the corresponding asynchronous application program, all the node execution information (the node execution information mentioned in the present disclosure includes the preset execution priority, the program identification information, and the instance identification information) recorded in the branch instance array may be deleted, and if there are one or more target branches whose end nodes have not successfully executed the corresponding asynchronous application programs, the node execution information of the end node that has not successfully executed the corresponding asynchronous application programs may be retained, and the number of the remaining target branches that have not successfully executed may be updated, so that the relevant end node may re-execute the corresponding asynchronous application programs.
By adopting the method, the asynchronous application programs corresponding to the end nodes of all target branches in the concurrency body are arranged, so that the asynchronous application programs can be sequentially executed in the same thread according to the execution sequence, the problem that the updating of the concurrency information (such as the residual number of the unexecuted concurrent branches) fails due to the fact that a plurality of threads compete for messages is solved, meanwhile, the times of accessing the database under high concurrency are reduced, and the performance expense of the database is saved.
Fig. 4 is a block diagram illustrating an apparatus for executing an asynchronous application, applied to a concurrency body, according to an exemplary embodiment, and includes:
a first determining module 401, configured to determine a target branch from multiple concurrent branches in the concurrency body, where the target branch is a concurrent branch executed to a last node in the concurrency body, and the last node is a concurrent branch of an asynchronous automatic node; the asynchronous automatic node is an automatic node for mounting an asynchronous application program;
a first obtaining module 402, configured to obtain the number of the target branches;
a second obtaining module 403, configured to obtain a preset execution priority for executing the asynchronous application program by a last node of each target branch if the number of the target branches is greater than or equal to a preset number threshold;
a second determining module 404, configured to determine, according to the preset execution priority, an execution sequence in which a last node of each target branch executes a corresponding asynchronous application;
a program executing module 405, configured to sequentially execute the asynchronous applications corresponding to the end nodes of each target branch according to the execution order.
Optionally, the first determining module 401 is configured to determine, for each of a plurality of the concurrent branches, whether a target node to be currently executed is a tail node; if the target node to be executed currently is the end node, determining whether the end node of the concurrent branch is the asynchronous automatic node; and if the tail node of the concurrent branch is the asynchronous automatic node, determining the concurrent branch as the target branch.
Optionally, the first determining module 401 is configured to obtain node attribute information of a next node of the target node, where the next node is a node to which the target node directly points in the flow node corresponding to the concurrent branch; determining whether the next node is a preset concurrency body end node or not according to the node attribute information of the next node; and if the next node is the concurrency end node, determining that the target node to be executed currently is the end node.
Optionally, fig. 5 is a block diagram of an execution apparatus of an asynchronous application according to the embodiment shown in fig. 4, and as shown in fig. 5, the apparatus further includes:
a third determining module 406, configured to determine whether the execution of the corresponding asynchronous application by the end node of each target branch is successful;
a deleting module 407, configured to delete the preset execution priority corresponding to the end node that successfully executes the asynchronous application from the execution sequence.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
By adopting the device, the asynchronous application programs corresponding to the end nodes of all target branches in the concurrency body are arranged, so that the asynchronous application programs can be sequentially executed in the same thread according to the execution sequence, the problem that the updating of the concurrency information (such as the residual number of the unexecuted concurrent branches) fails due to the fact that a plurality of threads compete for messages is solved, meanwhile, the times of accessing the database under high concurrency are reduced, and the performance expense of the database is saved.
Fig. 6 is a block diagram illustrating an electronic device 600 according to an example embodiment. For example, the electronic device 600 may be provided as a server. Referring to fig. 6, the electronic device 600 includes a processor 622, which may be one or more in number, and a memory 632 for storing computer programs executable by the processor 622. The computer program stored in memory 632 may include one or more modules that each correspond to a set of instructions. Further, the processor 622 may be configured to execute the computer program to perform the execution method of the asynchronous application program described above.
Additionally, electronic device 600 may also include a power component 626 that may be configured to perform power management of electronic device 600 and a communication component 650 that may be configured to enable communication, e.g., wired or wireless communication, of electronic device 600. The electronic device 600 may also include input/output (I/O) interfaces 658. The electronic device 600 may operate based on an operating system stored in the memory 632, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, and so on.
In another exemplary embodiment, there is also provided a computer readable storage medium comprising program instructions which, when executed by a processor, implement the steps of the execution method of the asynchronous application described above. For example, the computer readable storage medium may be the memory 632 described above that includes program instructions that are executable by the processor 622 of the electronic device 600 to perform the method of execution of the asynchronous application described above.
In another exemplary embodiment, a computer program product is also provided, which comprises a computer program executable by a programmable apparatus, the computer program having code portions for performing the execution method of the asynchronous application program described above when executed by the programmable apparatus.
The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea of the present disclosure, and these simple modifications all belong to the protection scope of the present disclosure.
It should be noted that, in the foregoing embodiments, various features described in the above embodiments may be combined in any suitable manner, and in order to avoid unnecessary repetition, various combinations that are possible in the present disclosure are not described again.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.
Claims (10)
1. An execution method of an asynchronous application program, which is applied to a concurrency body, the method comprising:
determining a target branch from a plurality of concurrent branches within the concurrency body, the target branch being a concurrent branch executed to a last node within the concurrency body, and the last node being a concurrent branch of an asynchronous automatic node; the asynchronous automatic node is an automatic node for mounting an asynchronous application program;
acquiring the number of the target branches;
if the number of the target branches is greater than or equal to a preset number threshold, acquiring a preset execution priority of the end node of each target branch executing the asynchronous application program, wherein the preset number threshold is a numerical value greater than or equal to 2;
determining an execution sequence of executing the corresponding asynchronous application program by the tail node of each target branch according to the preset execution priority;
and sequentially executing the asynchronous application program corresponding to the tail node of each target branch according to the execution sequence.
2. The method of claim 1, wherein determining a target branch from among a plurality of concurrent branches within the concurrency body comprises:
determining whether a target node to be executed currently is a tail node or not for each of the plurality of concurrent branches;
if the target node to be executed currently is the end node, determining whether the end node of the concurrent branch is the asynchronous automatic node;
and if the tail node of the concurrent branch is the asynchronous automatic node, determining the concurrent branch as the target branch.
3. The method of claim 2, wherein determining whether the target node currently to be executed is a tail node comprises:
acquiring node attribute information of a next node of the target node, wherein the next node is a node directly pointed by the target node in the flow node corresponding to the concurrent branch;
determining whether the next node is a preset concurrency body end node or not according to the node attribute information of the next node;
and if the next node is the concurrency end node, determining that the current target node to be executed is the end node.
4. The method of claim 1, wherein after the executing the asynchronous application corresponding to the end node of each of the target branches in turn in the execution order, the method further comprises:
determining whether the execution of the corresponding asynchronous application by the end node of each target branch is successful;
and deleting the preset execution priority corresponding to the end node which successfully executes the asynchronous application program from the execution sequence.
5. An apparatus for executing an asynchronous application, the apparatus being applied to a concurrency object, the apparatus comprising:
a first determining module, configured to determine a target branch from multiple concurrent branches within the concurrency body, where the target branch is a concurrent branch executed to a last node within the concurrency body, and the last node is an asynchronous automatic node; the asynchronous automatic node is an automatic node for mounting an asynchronous application program;
the first acquisition module is used for acquiring the number of the target branches;
a second obtaining module, configured to obtain a preset execution priority for executing the asynchronous application program by a last node of each target branch if the number of the target branches is greater than or equal to a preset number threshold, where the preset number threshold is a numerical value greater than or equal to 2;
a second determining module, configured to determine, according to the preset execution priority, an execution sequence in which a last node of each target branch executes a corresponding asynchronous application program;
and the program execution module is used for sequentially executing the asynchronous application program corresponding to the tail node of each target branch according to the execution sequence.
6. The apparatus of claim 5, wherein the first determining module is configured to determine, for each of a plurality of the concurrent branches, whether a target node to be currently executed is a tail node; if the target node to be executed currently is the end node, determining whether the end node of the concurrent branch is the asynchronous automatic node; and if the tail node of the concurrent branch is the asynchronous automatic node, determining the concurrent branch as the target branch.
7. The apparatus according to claim 6, wherein the first determining module is configured to obtain node attribute information of a next node of the target node, where the next node is a node directly pointed to by the target node in the flow node corresponding to the concurrent branch; determining whether the next node is a preset concurrency body end node or not according to the node attribute information of the next node; and if the next node is the concurrency end node, determining that the current target node to be executed is the end node.
8. The apparatus of claim 5, further comprising:
a third determining module, configured to determine whether execution of the corresponding asynchronous application by a last node of each of the target branches is successful;
and the deleting module is used for deleting the preset execution priority corresponding to the last node which successfully executes the asynchronous application program from the execution sequence.
9. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 4.
10. An electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of any one of claims 1 to 4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910792504.4A CN110597607B (en) | 2019-08-26 | 2019-08-26 | Execution method and device of asynchronous application program, storage medium and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910792504.4A CN110597607B (en) | 2019-08-26 | 2019-08-26 | Execution method and device of asynchronous application program, storage medium and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110597607A CN110597607A (en) | 2019-12-20 |
CN110597607B true CN110597607B (en) | 2022-05-17 |
Family
ID=68855734
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910792504.4A Active CN110597607B (en) | 2019-08-26 | 2019-08-26 | Execution method and device of asynchronous application program, storage medium and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110597607B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102043669A (en) * | 2010-12-22 | 2011-05-04 | 中国农业银行股份有限公司 | Workflow concurrency mode control method and device |
CN102150151A (en) * | 2008-09-15 | 2011-08-10 | 微软公司 | Asynchronous queued messaging for Web applications |
CN103577255A (en) * | 2013-10-29 | 2014-02-12 | 汉柏科技有限公司 | Method and system for controlling asynchronous progresses among plurality of services based on Zookeeper |
CN106951304A (en) * | 2017-03-06 | 2017-07-14 | 王铭鑫 | Concurrent invocation method and device |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8301593B2 (en) * | 2008-06-12 | 2012-10-30 | Gravic, Inc. | Mixed mode synchronous and asynchronous replication system |
US9152468B2 (en) * | 2010-10-25 | 2015-10-06 | Samsung Electronics Co., Ltd. | NUMA aware system task management |
-
2019
- 2019-08-26 CN CN201910792504.4A patent/CN110597607B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102150151A (en) * | 2008-09-15 | 2011-08-10 | 微软公司 | Asynchronous queued messaging for Web applications |
CN102043669A (en) * | 2010-12-22 | 2011-05-04 | 中国农业银行股份有限公司 | Workflow concurrency mode control method and device |
CN103577255A (en) * | 2013-10-29 | 2014-02-12 | 汉柏科技有限公司 | Method and system for controlling asynchronous progresses among plurality of services based on Zookeeper |
CN106951304A (en) * | 2017-03-06 | 2017-07-14 | 王铭鑫 | Concurrent invocation method and device |
Also Published As
Publication number | Publication date |
---|---|
CN110597607A (en) | 2019-12-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110445828B (en) | Data distributed processing method based on Redis and related equipment thereof | |
CN110677462B (en) | Access processing method, system, device and storage medium for multi-block chain network | |
CN115567388B (en) | Network slicing configuration automatic update method, system, device and storage medium | |
CN117857223B (en) | Method, device, equipment and medium for realizing black-and-white list based on FTTR master-slave management | |
CN105653556B (en) | Data aging method and device | |
CN112650449B (en) | Method and system for releasing cache space, electronic device and storage medium | |
CN113626217A (en) | Asynchronous message processing method and device, electronic equipment and storage medium | |
CN112395339A (en) | Method and device for checking data access between systems, computer equipment and storage medium | |
CN108536541B (en) | Process engine object processing method and device | |
CN109327472B (en) | Method, system, terminal and storage medium for dynamically planning firewall policy insertion | |
CN110597607B (en) | Execution method and device of asynchronous application program, storage medium and electronic equipment | |
CN113687882A (en) | Process rollback method, device and storage medium based on activiti | |
CN116208942A (en) | Near field communication relay node discovery method and related equipment | |
CN108509263A (en) | A kind of background process management method and system | |
CN111080250B (en) | Flow backspacing compensation method and device, storage medium and electronic equipment | |
CN113268327A (en) | Transaction request processing method and device and electronic equipment | |
EP4485874A1 (en) | Asset information collection method, electronic device and computer-readable storage medium | |
CN114780217B (en) | Task scheduling method, device, computer equipment and medium | |
CN117762439A (en) | Interface version upgrading method, system, electronic equipment and storage medium | |
CN115729961A (en) | Data query method, device, equipment and computer readable storage medium | |
CN114610413A (en) | Method, device, equipment and storage medium for executing synchronous and asynchronous tasks based on Java | |
CN113467913A (en) | Task execution method and device, storage medium and electronic device | |
CN112235842A (en) | Communication method and device of Internet of things equipment | |
CN113360219B (en) | Call line access method, device, equipment and readable storage medium | |
CN113038570B (en) | Access control method, device, equipment and storage medium of user node |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |