Process asynchronous processing method and device, computer device and storage medium
Patent Information
- Application Number
- CN202310301595.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-17
- Publication Date
- 2026-08-18
- Estimated Expiration
- 2043-03-17
AI Technical Summary
[0004]可见,现有技术对整个流程进行串行化处理,导致流程中的各个子流程耦合性都很强,如果某个子流程运行出现异常,本不相关的子流程都会运行失败
[0017] This application provides a method, apparatus, computer device, and storage medium for asynchronous process processing. The method includes: acquiring a trigger instruction for a target process; responding to the trigger instruction, determining multiple target sub-process groups from a preset set of sub-process groups, wherein the multiple target sub-process groups are independent sub-process groups obtained by splitting the target process; determining a target thread pool identifier corresponding to each target sub-process group based on a preset correspondence between sub-process groups and thread pool identifiers; determining a target thread pool corresponding to each target sub-process group based on the target thread pool identifier; and asynchronously executing each target sub-process group through the corresponding target thread pool. On one hand, this application pre-divides the target process into multiple independent target sub-process groups. When the target process is triggered, a corresponding target thread pool is automatically allocated to each target sub-process group, and each target sub-process group is executed asynchronously through its respective target thread pool. If a sub-thread group experiences an error, it will not affect other sub-process groups, reducing coupling between sub-process groups. On the other hand, asynchronous execution of each target sub-process group can fully utilize the CPU, improving CPU utilization.
Smart Images

Figure CN116302434B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a method, apparatus, computer equipment, and storage medium for asynchronous process processing. Background Technology
[0002] With the development of information technology, the complexity of software application processes has gradually increased.
[0003] Spring (an open-source design-level framework) provides an event mechanism based on the ApplicationEvent class and ApplicationListener. An event includes event registration, event listening, and event triggering. The entire event lifecycle is managed by the Spring container, and the entire event flow is executed in a serialized manner.
[0004] It is evident that existing technologies serialize the entire process, resulting in strong coupling between the various sub-processes. If a sub-process malfunctions, unrelated sub-processes will also fail. Summary of the Invention
[0005] This application provides a method, apparatus, computer device, and storage medium for asynchronous process processing, which can reduce the coupling between subprocess groups.
[0006] In a first aspect, embodiments of this application provide an asynchronous process processing method, which includes:
[0007] Obtain the trigger command for the target process;
[0008] In response to the triggering command, multiple target sub-process groups are determined from a preset set of multiple sub-process groups, wherein the multiple target sub-process groups are multiple independent sub-process groups obtained by splitting the target process.
[0009] Based on the preset correspondence between sub-process groups and thread pool identifiers, determine the target thread pool identifier corresponding to each target sub-process group;
[0010] The target thread pool corresponding to each target sub-process group is determined based on the target thread pool identifier.
[0011] Each of the target sub-process groups is executed asynchronously through the corresponding target thread pool.
[0012] Secondly, embodiments of this application also provide an asynchronous processing apparatus, comprising:
[0013] The transceiver unit is used to obtain trigger instructions for the target process;
[0014] The processing unit is configured to, in response to the triggering instruction, determine multiple target sub-process groups from a preset set of multiple sub-process groups, wherein the multiple target sub-process groups are multiple independent sub-process groups obtained by splitting the target process; determine the target thread pool identifier corresponding to each target sub-process group according to a preset correspondence between sub-process groups and thread pool identifiers; determine the target thread pool corresponding to each target sub-process group according to the target thread pool identifier; and asynchronously execute each target sub-process group through the corresponding target thread pool.
[0015] Thirdly, embodiments of this application also provide a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-described method.
[0016] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor, can implement the above-described method.
[0017] This application provides a method, apparatus, computer device, and storage medium for asynchronous process processing. The method includes: acquiring a trigger instruction for a target process; responding to the trigger instruction, determining multiple target sub-process groups from a preset set of sub-process groups, wherein the multiple target sub-process groups are independent sub-process groups obtained by splitting the target process; determining a target thread pool identifier corresponding to each target sub-process group based on a preset correspondence between sub-process groups and thread pool identifiers; determining a target thread pool corresponding to each target sub-process group based on the target thread pool identifier; and asynchronously executing each target sub-process group through the corresponding target thread pool. On one hand, this application pre-divides the target process into multiple independent target sub-process groups. When the target process is triggered, a corresponding target thread pool is automatically allocated to each target sub-process group, and each target sub-process group is executed asynchronously through its respective target thread pool. If a sub-thread group experiences an error, it will not affect other sub-process groups, reducing coupling between sub-process groups. On the other hand, asynchronous execution of each target sub-process group can fully utilize the CPU, improving CPU utilization. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1A flowchart illustrating the asynchronous processing method provided in this application embodiment;
[0020] Figure 2 A schematic diagram of the overall process of the asynchronous processing method provided in the embodiments of this application;
[0021] Figure 3 A schematic block diagram of an asynchronous processing apparatus provided in the embodiments of this application;
[0022] Figure 4 A schematic block diagram of a computer device provided in an embodiment of this application. Detailed Implementation
[0023] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0024] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0025] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0026] It should also be further understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0027] This application provides an asynchronous process processing method, apparatus, computer device, and storage medium.
[0028] The execution subject of this asynchronous processing method can be the asynchronous processing device provided in the embodiments of this application, or a computer device that integrates the asynchronous processing device. The asynchronous processing device can be implemented in hardware or software, and the computer device can be a terminal or a server. The terminal can be a smartphone, tablet computer, handheld computer, or laptop computer, etc.
[0029] The following section uses the terminal as the execution subject as an example to provide a detailed explanation of the asynchronous process processing method provided in this application.
[0030] It should be noted that, in some embodiments, before executing the asynchronous process processing method provided in this application embodiment, this embodiment first needs to obtain and store multiple target sub-process groups corresponding to the target process, and initialize the correspondence between the sub-process groups and thread pool identifiers. Specifically, a context service class, a sub-process group event listener, and a thread pool design are established. The context service class stores the correspondence between the sub-process groups and the listeners, and the listeners store the correspondence between the sub-process groups and the thread pool identifiers.
[0031] For example, firstly, the complex manual process is simplified by breaking it down into multiple individual sub-processes. Based on the ACID principles (atomicity, consistency, isolation, and durability), the sub-processes are grouped and set. The grouped sub-processes are independent of each other and have no relation to each other, thus achieving high cohesion and low coupling, and adapting to changing business needs. In this embodiment, each sub-process group includes multiple sub-processes.
[0032] Then, based on the grouping, event interfaces and data transfer objects (DTOs) are defined in the asynchronous process processing device. Each group implements the event interface, completes the logical function of the sub-process group, and executes it asynchronously through the thread pool group. The group is bound to the event. During service initialization, the events (groups) are aggregated to form an event context (at this time, the event context is equivalent to a set of events (sub-process groups)). The correspondence between sub-process groups and listeners is established in the event context class. The sub-process groups are indirectly managed through the event context class. When a complex process is executed, an event (sub-process group) is published when it reaches a sub-process node. The event context class listens to, analyzes, and matches the published event to find the target sub-process executor to execute the sub-process asynchronously. The original serial method is transformed into the execution of multiple parallel sub-processes, making full use of the machine's CPU and improving the system's business processing capabilities.
[0033] The specific implementation method is as follows:
[0034] 1. First, based on ACID principles, the target process is manually grouped. The grouping logic includes:
[0035] a. Split according to the parts with independent key outputs;
[0036] b. Break it down according to the pre-event, during-event, and post-event processes;
[0037] c. Combine sub-processes that are strongly related or have many repetitions;
[0038] d. Sub-processes that are split or combined can run independently without being affected by other processes.
[0039] 2. Define a custom asynchronous annotation @Async(thread pool identifier), and define the attribute field group(identifier value);
[0040] 3. Thread pool design:
[0041] The thread pool context management class is manually defined. The thread pool is dynamically created later by obtaining the group value of the @Async annotation. The thread pool is created by the constructor and stored in the cache structure ConcurrentHashMap in key-value pairs, with the key being @Async and the value being the thread pool.
[0042] 4. Construct the context service class and listeners:
[0043] a. Define event entities in the split sub-process groups according to step 1;
[0044] b. Define the generic interface for event listeners in each sub-process group;
[0045] c. Define a context service class. This class defines a cache structure ConcurrentHashMap, where the key is the parameter corresponding to the sub-process group and the value is the listener corresponding to the sub-process group. This class defines a method to publish the sub-process group. This method calls the thread pool in step 3 for execution. This class defines a method to register event listeners. This method binds the relationship between the sub-process group and the listener. The result is stored in the cache structure ConcurrentHashMap.
[0046] d. Define listeners for each subprocess group, implement the subprocess generic interface and InitializingBean, with the subprocess group as the parameter, and add the @Async annotation to each listener. The service startup listener registers to the event by calling the register listener method, stores the listener in the cache structure ConcurrentHashMap, and establishes the mapping relationship between the subprocess group and the listener in the cache structure.
[0047] Through the above steps, multiple sub-process groups corresponding to the target process can be stored in the asynchronous process processing device, and the correspondence between the sub-process groups and thread pool identifiers can be established (specifically including the correspondence between the sub-process groups in the context service class and the listeners, and the correspondence between the sub-process groups in the listeners and the thread pool identifiers).
[0048] Figure 1This is a flowchart illustrating the asynchronous processing method provided in an embodiment of this application. Figure 1 As shown, the method includes the following steps S110-S150.
[0049] S110, Obtain the trigger command for the target process.
[0050] In this embodiment, when a user needs to use the target process, the trigger command of the target process will be triggered.
[0051] S120. In response to the trigger command, determine multiple target sub-process groups from a preset set of multiple sub-process groups.
[0052] Among them, the multiple target sub-process groups are multiple independent sub-process groups obtained by splitting the target process.
[0053] Specifically, after the asynchronous process processing device receives the trigger instruction, it will determine multiple target sub-process groups from a set of multiple sub-process groups. The asynchronous process processing device stores multiple sub-process groups of the target process and / or stores multiple sub-process groups corresponding to each process.
[0054] When the asynchronous processing device stores multiple sub-process groups of the target process, the triggering instruction specifically includes a triggering instruction for the target sub-process group (i.e., the target sub-process group is part of the sub-process group, and the device only executes part of the function in the target process). Then, in response to the triggering instruction, the device determines the target sub-process group corresponding to the triggering instruction from the multiple preset sub-process groups.
[0055] When the asynchronous processing device stores multiple sub-process groups corresponding to each process, the triggering instruction includes the triggering instruction of the target process. In response to the triggering instruction, the device determines the target sub-process group corresponding to the target process from the multiple sub-process groups.
[0056] S130. Based on the preset correspondence between sub-process groups and thread pool identifiers, determine the target thread pool identifier corresponding to each target sub-process group.
[0057] In this embodiment, since the correspondence between sub-process groups and thread pool identifiers is pre-set in the device, once the target sub-process group is determined, the target thread pool identifier of each target sub-process group can be determined according to the correspondence.
[0058] Specifically, in some embodiments, it is necessary to determine the target thread pool identifier corresponding to each target sub-process group by means of the preset correspondence between sub-process groups and thread pool identifiers in the corresponding listener. In this case, before executing step S130, it is first necessary to determine the target listener corresponding to each target sub-process group. That is, before step S130, the target listener corresponding to each target sub-process group is determined according to the preset correspondence between sub-process groups and listeners. The target listener stores the corresponding correspondence between sub-process groups and thread pool identifiers.
[0059] At this time, step S130 includes: determining the target thread pool identifier corresponding to each target sub-process group according to the target listener corresponding to each target sub-process group.
[0060] S140. Determine the target thread pool corresponding to each target sub-process group based on the target thread pool identifier.
[0061] In this embodiment, target sub-process groups within multiple target sub-process groups can share a single thread pool or use different thread pools. Whether they can share a thread pool is determined by the thread pool identifier corresponding to the sub-process group. If the thread pool identifiers of the sub-process groups are the same, it means that the sub-process groups share a single thread pool; if they are different, it means that the sub-process groups use different thread pools.
[0062] In some embodiments, since the number of thread pools to be used is uncertain before executing the sub-process group, in order to make reasonable use of thread pool resources, this embodiment dynamically constructs the thread pool after obtaining the target thread pool identifier.
[0063] Specifically, step S140 includes: creating at least one thread pool based on the target thread pool identifier; and determining the target thread pool corresponding to each target sub-process group from the at least one thread pool.
[0064] Furthermore, the step of creating at least one thread pool based on the target thread pool identifier includes: determining the number of types of the target thread pool identifier based on the identifier value of the target thread pool identifier; and creating at least one thread pool based on the number of types.
[0065] For example, there are 5 target thread pools, and the target thread pool identifier values of each target thread pool are 3, 4, 3, 5, and 5 respectively. In this case, there are 3 types of identifier values, that is, the number of types of target thread pool identifiers is 3. In this case, 3 thread pools are dynamically constructed. Among them, the two target thread pools with an identifier value of 3 share one thread pool, the two target thread pools with an identifier value of 5 share one thread pool, and the target thread pool with an identifier value of 4 uses a separate thread pool.
[0066] S150. Execute each of the target sub-process groups asynchronously through the corresponding target thread pool.
[0067] Specifically, after each target thread pool is allocated a corresponding target thread pool, the corresponding target thread pool will be called to asynchronously execute each target subprocess group.
[0068] In this embodiment, the target sub-thread group includes at least one target sub-thread. In this embodiment, each target sub-process group is executed asynchronously and in parallel, and each target sub-thread is executed sequentially in each target sub-process group.
[0069] It should be noted that after step S150, the method further includes: obtaining the running results corresponding to each target sub-process group to obtain multiple running results; and outputting the target running result based on the multiple running results.
[0070] In this embodiment, after asynchronously executing each target sub-process group through the corresponding target thread pool, the method further includes: monitoring the running status of each target sub-process group through a preset exception monitoring mechanism; if it is determined from the running status that there is an abnormal sub-process group in the target sub-process group, then stopping the running of the abnormal sub-process group or issuing an exception alarm for the abnormal sub-process group.
[0071] As can be seen, this embodiment can also monitor abnormal situations during operation, making it convenient to handle abnormal situations during operation.
[0072] For ease of understanding, the following detailed description uses a specific embodiment:
[0073] For example, when the target process is the process corresponding to the China Securities Depository and Clearing Corporation (CSDC) query application, when a user needs to perform a CSDC query, they need to click on the CSDC query application through the user interface provided by the terminal. This causes the asynchronous process processing device in the terminal to obtain a trigger command for the target process. Then, in response to the trigger command, the device determines multiple target sub-process groups from a set of pre-set sub-process groups. These target sub-process groups are the registration document query process group, receipt query process group, attachment query process group, and certificate query process group. At this time, according to the pre-set correspondence between sub-process groups and thread pool identifiers, it can be seen that the registration document query process group corresponds to thread pool identifier 1, the receipt query process group corresponds to thread pool identifier 2, the attachment query process group corresponds to thread pool identifier 3, and the certificate query process group corresponds to thread pool identifier 4. It is known that there are a total of 4 thread pool identifiers. At this time, 4 thread pools are dynamically created, and one thread pool is allocated to each of the query process group, receipt query group, attachment query process group, and certificate query process group. Finally, the allocated thread pools are used to execute each target sub-thread group asynchronously and in parallel.
[0074] Please see Figure 2 , Figure 2 This is a schematic diagram of the overall process in this embodiment. The target process is divided into multiple sub-process groups for processing. Then, the event context class in the asynchronous process processing device listens for the publication of the sub-process groups through the listeners corresponding to each sub-process group. When the publication of a sub-process group is heard, a thread group is sent for the listened-to sub-process group.
[0075] In summary, this embodiment obtains a trigger instruction for a target process; in response to the trigger instruction, it determines multiple target sub-process groups from a preset set of sub-process groups, wherein the multiple target sub-process groups are independent sub-process groups obtained by splitting the target process; based on a preset correspondence between sub-process groups and thread pool identifiers, it determines the target thread pool identifier corresponding to each target sub-process group; based on the target thread pool identifier, it determines the target thread pool corresponding to each target sub-process group; and it asynchronously executes each target sub-process group through the corresponding target thread pool. On the one hand, this application pre-splits the target process into multiple independent target sub-process groups. When the target process is triggered, a corresponding target thread pool is automatically allocated to each target sub-process group, and each target sub-process group is executed asynchronously through each target thread pool. If a sub-thread group experiences an abnormality, it will not affect other sub-process groups, reducing the coupling between sub-process groups. On the other hand, asynchronous execution of each target sub-process group can fully utilize the CPU and improve CPU utilization.
[0076] Furthermore, this embodiment can support a larger concurrency at the same time. When business changes, only the corresponding logical sub-process needs to be modified without affecting other processes, adapting to the variability of business. In terms of events, it implements event context management, which is more scalable and flexible.
[0077] Figure 3 This is a schematic block diagram of an asynchronous process processing device provided in an embodiment of this application. Figure 3 As shown, corresponding to the above-described asynchronous process processing method, this application also provides an asynchronous process processing apparatus. This apparatus includes a unit for executing the above-described asynchronous process processing method, and can be configured in a desktop computer, tablet computer, laptop computer, or other terminal. Specifically, please refer to... Figure 3 The asynchronous processing device 300 includes a transceiver unit 301 and a processing unit 302, wherein:
[0078] The transceiver unit 301 is used to acquire trigger instructions for the target process;
[0079] Processing unit 302 is configured to, in response to the triggering instruction, determine multiple target sub-process groups from a preset set of multiple sub-process groups, wherein the multiple target sub-process groups are multiple independent sub-process groups obtained by splitting the target process; determine the target thread pool identifier corresponding to each target sub-process group according to a preset correspondence between sub-process groups and thread pool identifiers; determine the target thread pool corresponding to each target sub-process group according to the target thread pool identifiers; and asynchronously execute each target sub-process group through the corresponding target thread pool.
[0080] In some embodiments, when the processing unit 302 performs the step of determining the target thread pool corresponding to each of the target sub-process groups based on the target thread pool identifier, it is specifically used for:
[0081] Create at least one thread pool based on the target thread pool identifier;
[0082] The target thread pool corresponding to each target subprocess group is determined from at least one of the thread pools.
[0083] In some embodiments, when the processing unit 302 performs the step of creating at least one thread pool based on the target thread pool identifier, it is specifically used for:
[0084] The number of types of target thread pool identifiers is determined based on the identifier value of the target thread pool identifier;
[0085] Create at least one of the aforementioned thread pools based on the number of the aforementioned types.
[0086] In some embodiments, before performing the step of determining the target thread pool identifier corresponding to each target sub-process group according to the preset correspondence between sub-process groups and thread pool identifiers, the processing unit 302 is further configured to:
[0087] The target listener corresponding to each target sub-process group is determined according to the preset correspondence between sub-process groups and listeners. The target listener stores the correspondence between the corresponding sub-process group and the thread pool identifier.
[0088] In some embodiments, when the processing unit 302 performs the step of determining the target thread pool identifier corresponding to each target sub-process group according to the preset correspondence between sub-process groups and thread pool identifiers, it is specifically used for:
[0089] Based on the target listener corresponding to each target sub-process group, the target thread pool identifier corresponding to each target sub-process group is determined.
[0090] In some embodiments, after executing the step of asynchronously executing each of the target sub-process groups through the corresponding target thread pool, the processing unit 302 is further configured to:
[0091] The operation of each target sub-process group is monitored through a preset anomaly monitoring mechanism;
[0092] If, based on the operational status, it is determined that there is an abnormal sub-process group within the target sub-process group, then the abnormal sub-process group is stopped from running or an abnormal alarm for the abnormal sub-process group is issued.
[0093] In some embodiments, before the transceiver unit 301 executes the step of obtaining the trigger instruction for the target process, it is further configured to:
[0094] The processing unit 302 acquires and stores multiple target sub-process groups and establishes a correspondence between the sub-process groups and thread pool identifiers.
[0095] In some embodiments, after executing the step of asynchronously executing each of the target sub-process groups through the corresponding target thread pool, the processing unit 302 is further configured to:
[0096] Obtain the execution results corresponding to each target sub-process group, resulting in multiple execution results;
[0097] The target execution result is output based on the multiple execution results described.
[0098] In summary, on the one hand, the asynchronous processing device 300 in this application pre-divides the target process into multiple independent target sub-process groups. When the target process is triggered, it automatically allocates a corresponding target thread pool to each target sub-process group and executes each target sub-process group asynchronously through each target thread pool. If a sub-thread group encounters an abnormality, it will not affect other sub-process groups, thus reducing the coupling between sub-process groups. On the other hand, asynchronous execution of each target sub-process group can make full use of the CPU and improve CPU utilization.
[0099] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned asynchronous processing device and each unit can be referred to the corresponding description in the foregoing method embodiments. For the sake of convenience and brevity, it will not be repeated here.
[0100] The aforementioned asynchronous processing device can be implemented as a computer program, which can, for example... Figure 4 It runs on the computer device shown.
[0101] Please see Figure 4 , Figure 4This is a schematic block diagram of a computer device provided in an embodiment of this application. The computer device 400 can be a terminal or a server. The terminal can be an electronic device with communication functions, such as a smartphone, tablet, laptop, desktop computer, personal digital assistant, or wearable device. The server can be a standalone server or a server cluster composed of multiple servers.
[0102] See Figure 4 The computer device 400 includes a processor 402, a memory, and a network interface 405 connected via a system bus 401. The memory may include a non-volatile storage medium 403 and internal memory 404.
[0103] The non-volatile storage medium 403 may store an operating system 4031 and a computer program 4032. The computer program 4032 includes program instructions that, when executed, cause the processor 402 to perform an asynchronous processing method.
[0104] The processor 402 provides computing and control capabilities to support the operation of the entire computer device 400.
[0105] The internal memory 404 provides an environment for the execution of the computer program 4032 in the non-volatile storage medium 403. When the computer program 4032 is executed by the processor 402, the processor 402 can perform an asynchronous processing method.
[0106] This network interface 405 is used for network communication with other devices. Those skilled in the art will understand that... Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device 400 to which the present application is applied. The specific computer device 400 may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0107] The processor 402 is used to run a computer program 4032 stored in the memory to perform the following steps:
[0108] Obtain the trigger command for the target process;
[0109] In response to the triggering command, multiple target sub-process groups are determined from a preset set of multiple sub-process groups, wherein the multiple target sub-process groups are multiple independent sub-process groups obtained by splitting the target process.
[0110] Based on the preset correspondence between sub-process groups and thread pool identifiers, determine the target thread pool identifier corresponding to each target sub-process group;
[0111] The target thread pool corresponding to each target sub-process group is determined based on the target thread pool identifier.
[0112] Each of the target sub-process groups is executed asynchronously through the corresponding target thread pool.
[0113] In some embodiments, when the processor 402 implements the step of determining the target thread pool corresponding to each of the target sub-process groups based on the target thread pool identifier, the following steps are specifically implemented:
[0114] Create at least one thread pool based on the target thread pool identifier;
[0115] The target thread pool corresponding to each target subprocess group is determined from at least one of the thread pools.
[0116] In some embodiments, when implementing the step of creating at least one thread pool based on the target thread pool identifier, the processor 402 specifically implements the following steps:
[0117] The number of types of target thread pool identifiers is determined based on the identifier value of the target thread pool identifier;
[0118] Create at least one of the aforementioned thread pools based on the number of the aforementioned types.
[0119] In some embodiments, before implementing the step of determining the target thread pool identifier corresponding to each target sub-process group according to the preset correspondence between sub-process groups and thread pool identifiers, the processor 402 further implements the following steps:
[0120] The target listener corresponding to each target sub-process group is determined according to the preset correspondence between sub-process groups and listeners. The target listener stores the correspondence between the corresponding sub-process group and the thread pool identifier.
[0121] In some embodiments, when the processor 402 determines the target thread pool identifier corresponding to each target sub-process group based on a preset correspondence between sub-process groups and thread pool identifiers, the processor 402 specifically implements the following steps:
[0122] Based on the target listener corresponding to each target sub-process group, the target thread pool identifier corresponding to each target sub-process group is determined.
[0123] In some embodiments, after implementing the step of asynchronously executing each of the target sub-process groups through the corresponding target thread pool, the processor 402 further implements the following steps:
[0124] The operation of each target sub-process group is monitored through a preset anomaly monitoring mechanism;
[0125] If, based on the operational status, it is determined that there is an abnormal sub-process group within the target sub-process group, then the abnormal sub-process group is stopped from running or an abnormal alarm for the abnormal sub-process group is issued.
[0126] In some embodiments, before implementing the step of obtaining the trigger instruction for the target process, the processor 402 further implements the following steps:
[0127] Acquire and store multiple target sub-process groups, and establish a correspondence between the sub-process groups and thread pool identifiers.
[0128] In some embodiments, after implementing the step of obtaining the trigger instruction for the target process, the processor 402 further implements the following steps:
[0129] Obtain the execution results corresponding to each target sub-process group, resulting in multiple execution results;
[0130] The target execution result is output based on the multiple execution results described.
[0131] It should be understood that in the embodiments of this application, the processor 402 may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0132] It will be understood by those skilled in the art that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program includes program instructions and can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.
[0133] Therefore, this application also provides a storage medium. This storage medium can be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. When executed by a processor, the program instructions cause the processor to perform the following steps:
[0134] Obtain the trigger command for the target process;
[0135] In response to the triggering command, multiple target sub-process groups are determined from a preset set of multiple sub-process groups, wherein the multiple target sub-process groups are multiple independent sub-process groups obtained by splitting the target process.
[0136] Based on the preset correspondence between sub-process groups and thread pool identifiers, determine the target thread pool identifier corresponding to each target sub-process group;
[0137] The target thread pool corresponding to each target sub-process group is determined based on the target thread pool identifier.
[0138] Each of the target sub-process groups is executed asynchronously through the corresponding target thread pool.
[0139] The storage medium can be any computer-readable storage medium capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), magnetic disk, or optical disk.
[0140] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0141] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of each unit is merely a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0142] The steps in the methods of this application embodiment can be adjusted, merged, or deleted according to actual needs. The units in the apparatus of this application embodiment can be merged, divided, or deleted according to actual needs. Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0143] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0144] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for process asynchronous processing, characterized in that, include: Obtain the trigger command for the target process; In response to the triggering command, multiple target sub-process groups are determined from a preset set of multiple sub-process groups. The multiple target sub-process groups are multiple independent sub-process groups obtained by grouping and aggregating multiple sub-processes obtained by splitting the target process based on the principles of atomicity, consistency, isolation and durability. Based on the preset correspondence between sub-process groups and thread pool identifiers, determine the target thread pool identifier corresponding to each target sub-process group; The target thread pool corresponding to each target sub-process group is determined based on the target thread pool identifier. Each of the target sub-process groups is executed asynchronously through the corresponding target thread pool; Before determining the target thread pool identifier corresponding to each target sub-process group based on the preset correspondence between sub-process groups and thread pool identifiers, the method further includes: The target listener corresponding to each target sub-process group is determined according to the preset correspondence between sub-process groups and listeners. The target listener stores the correspondence between the corresponding sub-process group and the thread pool identifier. The step of determining the target thread pool identifier corresponding to each target sub-process group based on the preset correspondence between sub-process groups and thread pool identifiers includes: Based on the target listener corresponding to each target sub-process group, determine the target thread pool identifier corresponding to each target sub-process group; The step of determining the target thread pool corresponding to each target sub-process group based on the target thread pool identifier includes: Create at least one thread pool based on the target thread pool identifier; Determine the target thread pool corresponding to each target sub-process group from at least one of the thread pools; Creating at least one thread pool based on the target thread pool identifier includes: The number of types of target thread pool identifiers is determined based on the identifier value of the target thread pool identifier; Create at least one of the aforementioned thread pools based on the number of the aforementioned types.
2. The method according to claim 1, characterized in that, After asynchronously executing each of the target sub-process groups through the corresponding target thread pool, the method further includes: The operation of each target sub-process group is monitored through a preset anomaly monitoring mechanism; If, based on the operational status, it is determined that there is an abnormal sub-process group within the target sub-process group, then the abnormal sub-process group is stopped from running or an abnormal alarm for the abnormal sub-process group is issued.
3. The method according to any one of claims 1 to 2, characterized in that, Before obtaining the trigger instruction for the target process, the method further includes: Acquire and store multiple sub-process groups, and establish a correspondence between the sub-process groups and thread pool identifiers.
4. The method according to any one of claims 1 to 2, characterized in that, After asynchronously executing each of the target sub-process groups through the corresponding target thread pool, the method further includes: Obtain the execution results corresponding to each target sub-process group, resulting in multiple execution results; The target execution result is output based on the multiple execution results described.
5. An asynchronous process processing device, characterized in that, include: The transceiver unit is used to obtain trigger instructions for the target process; The processing unit is configured to, in response to the triggering instruction, determine multiple target sub-process groups from a preset set of sub-process groups, wherein the multiple target sub-process groups are independent sub-process groups obtained by grouping and aggregating multiple sub-processes obtained by splitting the target process based on the principles of atomicity, consistency, isolation, and durability; determine the target thread pool identifier corresponding to each target sub-process group according to a preset correspondence between sub-process groups and thread pool identifiers; determine the target thread pool corresponding to each target sub-process group according to the target thread pool identifiers; and asynchronously execute each target sub-process group through the corresponding target thread pool. Before the processing unit performs the step of determining the target thread pool identifier corresponding to each target sub-process group according to the preset correspondence between sub-process groups and thread pool identifiers, it is further configured to: The target listener corresponding to each target sub-process group is determined according to the preset correspondence between sub-process groups and listeners. The target listener stores the correspondence between the corresponding sub-process group and the thread pool identifier. When the processing unit executes the step of determining the target thread pool identifier corresponding to each target sub-process group based on the preset correspondence between sub-process groups and thread pool identifiers, it is specifically used for: Based on the target listener corresponding to each target sub-process group, determine the target thread pool identifier corresponding to each target sub-process group; When the processing unit executes the step of determining the target thread pool corresponding to each target sub-process group based on the target thread pool identifier, it is specifically used for: Create at least one thread pool based on the target thread pool identifier; Determine the target thread pool corresponding to each target sub-process group from at least one of the thread pools; When the processing unit performs the step of creating at least one thread pool based on the target thread pool identifier, it is specifically used for: The number of types of target thread pool identifiers is determined based on the identifier value of the target thread pool identifier; Create at least one of the aforementioned thread pools based on the number of the aforementioned types.
6. A computer device, characterized in that, The computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method as described in any one of claims 1-4.
7. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which includes program instructions that, when executed by a processor, can implement the method as described in any one of claims 1-4.
Citation Information
Patent Citations
Data query method and device, server and storage medium
CN114969119A