Asynchronous task processing method, device, equipment and computer-readable storage medium

By dynamically selecting the asynchronous task processing method and assembling task parameters, the problems of waste of resources and low efficiency caused by the single asynchronous task processing method are solved, and more efficient asynchronous task processing is achieved.

CN111240864BActive Publication Date: 2025-04-11CHINA PING AN PROPERTY INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010033028.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-01-13
Publication Date
2025-04-11
Estimated Expiration
2040-01-13

AI Technical Summary

Technical Problem

In the prior art, the asynchronous task processing method is single, and the most suitable processing method cannot be selected according to the change of conditions, resulting in waste of resources and low processing efficiency.

Method used

Provides an asynchronous task processing method, by receiving asynchronous task requests, determining task information according to the task type, including asynchronous task processing method, task processing timeliness and number of tasks, dynamically selecting task parameters and assembly templates, assembling tasks to be executed, and executing tasks based on asynchronous task processing method.

Benefits of technology

It realizes the selection of appropriate asynchronous task processing methods based on actual scenario needs, avoids resource waste, improves the efficiency of asynchronous task processing, and balances system resource utilization, processing time and processing throughput.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111240864B_ABST
    Figure CN111240864B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of scaffold operation and maintenance, and discloses an asynchronous task processing method, comprising the following steps: receiving an asynchronous task request, wherein the asynchronous task request includes a task type of an asynchronous task; determining task information corresponding to the asynchronous task request according to the task type; determining a task parameter assembly template according to the task information; assembling the task parameters to be assembled through the task parameter assembly template to obtain a task to be executed; executing the task to be executed based on the task parameters to be assembled and the asynchronous task processing method, wherein the asynchronous task processing method includes: specifying an asynchronous task processing method and a default asynchronous task processing method. The present invention also discloses an asynchronous task processing device, equipment, and computer-readable storage medium. The asynchronous task processing method provided by the present invention improves the processing efficiency of asynchronous tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of base frame operation and maintenance technology, and in particular to an asynchronous task processing method, device, equipment and computer-readable storage medium. Background Art

[0002] At present, a type of task can generally only choose one asynchronous task processing method, so it is impossible to choose the most appropriate processing method according to the changing conditions. For example, when the processing time requirement increases or decreases, or the number of tasks increases or decreases suddenly, if the processing method cannot be changed in time, it may cause a waste of resources. Therefore, how to choose the appropriate asynchronous task processing method according to the needs of the actual scenario to improve the processing efficiency of asynchronous tasks is a technical problem that needs to be solved urgently in this field. Summary of the invention

[0003] The main purpose of the present invention is to provide an asynchronous task processing method, device, equipment and computer-readable storage medium, aiming to solve the technical problem of low asynchronous task processing efficiency caused by a single asynchronous task processing method.

[0004] To achieve the above object, the present invention provides an asynchronous task processing method, which comprises the following steps:

[0005] An asynchronous task processing method, characterized in that the asynchronous task processing method comprises the following steps:

[0006] receiving an asynchronous task request, wherein the asynchronous task request includes a task type of the asynchronous task;

[0007] Determine task information corresponding to the asynchronous task request according to the task type, wherein the task information includes: an asynchronous task processing mode, a task processing time limit, and a task quantity, and the asynchronous task processing mode is a specified asynchronous task processing mode or a default asynchronous task processing mode;

[0008] Determine a task parameter assembly template according to the task information;

[0009] Assembling the task parameters to be assembled through the task parameter assembly template to obtain the task to be executed, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed;

[0010] The task to be executed is executed based on the task parameters to be assembled and the asynchronous task processing method.

[0011] Optionally, determining the task information corresponding to the asynchronous task request according to the task type, wherein the task information includes: an asynchronous task processing mode, a task processing time limit, and a task quantity, and the asynchronous task processing mode is a specified asynchronous task processing mode or a default asynchronous task processing mode, comprises the following steps:

[0012] Querying task information corresponding to the asynchronous task request in a preset asynchronous task processing mode configuration table by polling, wherein the task information includes: asynchronous task processing mode, task processing time limit and task quantity, and the asynchronous task processing mode is a specified asynchronous task processing mode or a default asynchronous task processing mode;

[0013] According to the task information, determining whether a preset asynchronous task processing mode switch is turned on;

[0014] If the preset specified asynchronous task processing mode switch is turned on, the specified asynchronous task processing mode is obtained;

[0015] If the preset asynchronous task processing mode switch is turned off, the default asynchronous task processing mode is obtained.

[0016] Optionally, if the preset specified asynchronous task processing mode switch is turned on, obtaining the specified asynchronous task processing mode includes the following steps:

[0017] Monitor CPU usage and memory usage through pre-set monitoring programs;

[0018] Determine whether the CPU occupancy rate is less than or equal to a first preset threshold;

[0019] If the CPU occupancy rate is less than or equal to the first preset threshold, determining whether the memory usage rate is greater than a second preset threshold;

[0020] If the memory usage rate is greater than the second preset threshold, it is determined that the preset specified asynchronous task processing mode switch is turned on, and the specified asynchronous task processing mode is obtained.

[0021] Optionally, executing the task to be executed based on the task parameters to be assembled and the asynchronous task processing method comprises the following steps:

[0022] According to the priority of the preset asynchronous task processing method in the preset asynchronous task processing method configuration table, the asynchronous task processing method with the highest priority is obtained;

[0023] Determine task step data according to the asynchronous task processing mode, and use the task step data as part of the task parameters to be assembled, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed;

[0024] The task to be executed is executed based on the task parameters to be assembled and the asynchronous task processing method.

[0025] Optionally, executing the task to be executed based on the task parameters to be assembled and the asynchronous task processing method comprises the following steps:

[0026] Determining whether the task step data includes multiple steps;

[0027] If the task step data includes multiple steps, determining whether the multiple steps meet the conditions for concurrent processing;

[0028] If the multiple steps meet the conditions for concurrent processing, based on the task parameters to be assembled and the asynchronous task processing method, the multiple steps are used to execute the tasks to be executed in a concurrent manner;

[0029] If the multiple steps do not meet the conditions for concurrent processing, the tasks to be executed are executed in a preset order of the multiple steps based on the task parameters to be assembled and the asynchronous task processing method.

[0030] Optionally, determining the task step data according to the asynchronous task processing mode and using the task step data as part of the task parameters to be assembled, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed, including the following steps:

[0031] Traversing the asynchronous task processing methods, determining whether the asynchronous task processing methods include at least one of an open source task schedule management system, a message queue, and asynchronous multithreading;

[0032] If the asynchronous task processing method includes at least one of an open source task schedule management system, a message queue, and asynchronous multithreading, then the task step data corresponding to the asynchronous task processing method is obtained, and the task step data is used as part of the task parameters to be assembled, wherein the task parameters to be assembled include: task step data, task timeliness data, and task type data to be executed.

[0033] Optionally, the task parameters to be assembled are assembled through the task parameter assembly template to obtain the task to be executed, and the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed include:

[0034] A matching relationship between the task parameter assembly template and the task parameters to be assembled is established through a hash algorithm;

[0035] Based on the matching relationship, the task parameters to be assembled are assembled through the task parameter assembly template to obtain the task to be executed. The task parameters to be assembled include: task step data, task timeliness data and task type data to be executed.

[0036] Furthermore, to achieve the above object, the present invention also provides an asynchronous task processing device, the asynchronous task processing device comprising the following modules:

[0037] A receiving module, used for receiving an asynchronous task request, wherein the asynchronous task request includes a task type of the asynchronous task;

[0038] A task information selection module, used to determine the task information corresponding to the asynchronous task request according to the task type, wherein the task information includes: an asynchronous task processing mode, a task processing time limit and a task quantity, and the asynchronous task processing mode is a specified asynchronous task processing mode or a default asynchronous task processing mode;

[0039] A task parameter assembly template selection module, used to determine a task parameter assembly template according to the task information;

[0040] An assembly module, used for assembling the task parameters to be assembled through the task parameter assembly template to obtain the task to be executed, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed;

[0041] An execution module is used to execute the task to be executed based on the task parameters to be assembled and the asynchronous task processing method.

[0042] Optionally, the task information selection module includes the following units:

[0043] A query unit, used for querying the task information corresponding to the asynchronous task request in a preset asynchronous task processing mode configuration table by polling, wherein the task information includes: asynchronous task processing mode, task processing time limit and task quantity, and the asynchronous task processing mode is a specified asynchronous task processing mode or a default asynchronous task processing mode;

[0044] A preset designated asynchronous task processing mode switch judgment unit is used to judge whether the preset designated asynchronous task processing mode switch is turned on according to the task information;

[0045] A specified asynchronous task processing mode selection unit is used to obtain the specified asynchronous task processing mode if the preset specified asynchronous task processing mode switch is turned on;

[0046] The default asynchronous task processing mode selection unit is used to obtain the default asynchronous task processing mode if the preset specified asynchronous task processing mode switch is turned off.

[0047] Optionally, the designated asynchronous task processing mode selection unit is used to:

[0048] Monitor CPU usage and memory usage through pre-set monitoring programs;

[0049] Determine whether the CPU occupancy rate is less than or equal to a first preset threshold;

[0050] If the CPU occupancy rate is less than or equal to the first preset threshold, determining whether the memory usage rate is greater than a second preset threshold;

[0051] If the memory usage rate is greater than the second preset threshold, it is determined that the preset specified asynchronous task processing mode switch is turned on, and the specified asynchronous task processing mode is obtained.

[0052] Optionally, the execution module includes the following units:

[0053] An asynchronous task processing mode acquisition unit, used to obtain the asynchronous task processing mode with the highest priority according to the priority of the preset asynchronous task processing modes in the preset asynchronous task processing mode configuration table;

[0054] A task step data selection unit, used to determine the task step data according to the asynchronous task processing mode, and use the task step data as part of the task parameters to be assembled, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed;

[0055] The asynchronous task processing mode execution unit is used to execute the task to be executed based on the task parameters to be assembled and the asynchronous task processing mode.

[0056] Optionally, the asynchronous task processing execution unit is used to:

[0057] Determining whether the task step data includes multiple steps;

[0058] If the task step data includes multiple steps, determining whether the multiple steps meet the conditions for concurrent processing;

[0059] If the multiple steps meet the conditions for concurrent processing, based on the task parameters to be assembled and the asynchronous task processing method, the multiple steps are used to execute the tasks to be executed in a concurrent manner;

[0060] If the multiple steps do not meet the conditions for concurrent processing, the tasks to be executed are executed in a preset order of the multiple steps based on the task parameters to be assembled and the asynchronous task processing method.

[0061] Optionally, the task step data selection unit is used to:

[0062] Traversing the asynchronous task processing methods, determining whether the asynchronous task processing methods include at least one of an open source task schedule management system, a message queue, and asynchronous multithreading;

[0063] If the asynchronous task processing method includes at least one of an open source task schedule management system, a message queue, and asynchronous multithreading, then the task step data corresponding to the asynchronous task processing method is obtained, and the task step data is used as part of the task parameters to be assembled, wherein the task parameters to be assembled include: task step data, task timeliness data, and task type data to be executed.

[0064] Optionally, the assembly module includes the following units:

[0065] A matching relationship building unit, used to establish a matching relationship between a task parameter assembly template and task parameters to be assembled through a hash algorithm;

[0066] The task parameter assembly unit is used to assemble the current task parameters to be assembled through the task parameter assembly template based on the matching relationship to obtain the task to be executed. The task parameters to be assembled include: task step data, task timeliness data and task type data to be executed.

[0067] Furthermore, to achieve the above-mentioned purpose, the present invention also provides an asynchronous task processing device, which includes a memory, a processor, and an asynchronous task processing program stored in the memory and executable on the processor, and the asynchronous task processing program, when executed by the processor, implements the steps of the asynchronous task processing method as described in any one of the above items.

[0068] Furthermore, to achieve the above objectives, the present invention also provides a computer-readable storage medium, on which an asynchronous task processing program is stored, and when the asynchronous task processing program is executed by a processor, the steps of the asynchronous task processing method as described in any one of the above items are implemented.

[0069] Different asynchronous task processing methods are brought together, and the corresponding asynchronous task processing methods are obtained according to the asynchronous task requests in the actual scenario. This can avoid the waste of resources caused by a single asynchronous task processing method to the greatest extent, and can effectively combine the advantages of different asynchronous task processing methods. This balances system resource utilization, processing timeliness, and processing throughput. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] Figure 1It is a schematic diagram of the structure of the asynchronous task processing device operating environment involved in the embodiment of the present invention;

[0071] Figure 2 It is a flowchart of the first embodiment of the asynchronous task processing method of the present invention;

[0072] Figure 3 for Figure 2 A detailed flow chart of step S20 in an embodiment;

[0073] Figure 4 for Figure 3 A detailed flow chart of step S203 in an embodiment;

[0074] Figure 5 for Figure 2 A detailed flow chart of step S50 in an embodiment;

[0075] Figure 6 for Figure 5 A detailed flow chart of step S503 in an embodiment;

[0076] Figure 7 for Figure 5 A detailed flow chart of step S502 in an embodiment;

[0077] Figure 8 This is a flow chart of a second embodiment of the asynchronous task processing method of the present invention;

[0078] Fig. 9 Schematic diagram of functional modules of an asynchronous task processing device according to an embodiment of the present invention.

[0079] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0080] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0081] The invention provides an asynchronous task processing device.

[0082] Reference Figure 1 , Figure 1 It is a schematic diagram of the structure of the asynchronous task processing device operating environment involved in the embodiment of the present invention.

[0083] like Figure 1As shown, the asynchronous task processing device includes: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the network interface 1004 may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface). The memory 1005 can be a high-speed RAM memory, or it can be a stable memory (non-volatile memory), such as a disk memory. The memory 1005 can also be a storage device independent of the aforementioned processor 1001.

[0084] Those skilled in the art will understand that Figure 1 The hardware structure of the asynchronous task processing device shown in the figure does not constitute a limitation on the asynchronous task processing device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0085] like Figure 1 As shown, the memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and an asynchronous task processing program. Among them, the operating system is a program that manages and controls asynchronous task processing equipment and software resources, and supports the operation of the asynchronous task processing program and other software and / or programs.

[0086] exist Figure 1 In the hardware structure of the asynchronous task processing device shown, the network interface 1004 is mainly used to access the network; the user interface 1003 is mainly used to detect confirmation instructions and editing instructions, etc. The processor 1001 can be used to call the asynchronous task processing program stored in the memory 1005 and perform the operations of the following embodiments of the asynchronous task processing method.

[0087] Based on the above hardware structure of the asynchronous task processing device, various embodiments of the asynchronous task processing method of the present invention are proposed.

[0088] Reference Figure 2 , Figure 2 1 is a flow chart of the first embodiment of the asynchronous task processing method of the present invention. In this embodiment, the asynchronous task processing method includes the following steps:

[0089] Step S10, receiving an asynchronous task request, where the asynchronous task request includes a task type of the asynchronous task;

[0090] In this embodiment, the asynchronous task request is received by the receiving end, and the asynchronous task request can cover the following scenarios: 1. Sending the premium change data generated by the revision to the financial platform; 2. Uploading the latest policy data to the traffic management platform; 3. Uploading the latest policy data to the insurance trust platform. Common asynchronous task processing methods include: quartz task scheduling, message queue, and asynchronous multithreading. The asynchronous task request contains the task type of each task. For example, the task type can be uploading the latest policy data to the insurance trust platform.

[0091] Step S20, determining task information corresponding to the asynchronous task request according to the task type, wherein the task information includes: asynchronous task processing mode, task processing time limit and task quantity, and the asynchronous task processing mode is a specified asynchronous task processing mode or a default asynchronous task processing mode;

[0092] In this embodiment, after receiving an asynchronous task request, the asynchronous task request contains the task type of each task, and task information corresponding to the asynchronous task request is obtained according to the task type, and the task information includes: a preset asynchronous task processing mode configuration table containing each asynchronous task processing mode, and task steps corresponding to each task. From the preset asynchronous task processing mode configuration table, the asynchronous task processing mode corresponding to each task type and the task steps corresponding to each task can be queried.

[0093] The asynchronous task processing method that matches the asynchronous task type can be queried in the preset asynchronous task processing method configuration table by polling, where the asynchronous task processing method includes: specified asynchronous task processing method and default asynchronous task processing method. The asynchronous task processing method can be quartz task scheduling, message queue, asynchronous multithreading, and the relationship between asynchronous task processing methods includes sequential relationship and parallel relationship.

[0094] Since the asynchronous task processing method that matches the task type has been pre-set in the preset asynchronous task processing method configuration table, the asynchronous task processing method that matches the task type can be obtained according to the current task type through polling. In order to apply the asynchronous task processing method that suits the current scenario to a greater extent, the asynchronous task processing method can also be pre-divided into a specified asynchronous task processing method and a default asynchronous task processing method. Among them, the default asynchronous task processing method refers to the processing method that is preferentially selected in normal scenarios, and it can also be the processing method that needs to be selected when the preset specified asynchronous task processing method switch is turned off. For example, the asynchronous task processing methods that match the first type of task are the first specified asynchronous task processing method and the first default asynchronous task processing method. Since the priority of the default asynchronous task processing method is higher than that of the specified asynchronous task processing method, the first default asynchronous task processing method is used preferentially in the current scenario. If the task volume suddenly surges or the processing timeliness is required to be increased or decreased, it is necessary to switch to the specified asynchronous task processing method.

[0095] The reason for distinguishing different asynchronous task processing methods is to facilitate the selection of the most appropriate asynchronous task processing method according to the needs of the actual scenario, for example, one or more of quartz task scheduling, message queues or asynchronous multithreading. Quartz task scheduling and message queues are generally handled by other schedulers or message consumer programs. The processing time efficiency of quartz task scheduling is affected by the scheduling frequency, and the processing time efficiency of message queues is affected by network latency and message processing capabilities. Asynchronous multithreading is generally faster than quartz task scheduling and message queue processing in the original program, but the original program consumes more server resources. The relationship between asynchronous task processing methods includes precedence and parallel relationships. The precedence relationship refers to when there are two or more asynchronous task processing methods, if the asynchronous task processing methods are pre-set with priority levels, they are in a precedence relationship according to the priority levels.

[0096] Before step S20, it also includes establishing a mapping relationship between the asynchronous task type and the task information through a hash algorithm, inputting the asynchronous task type into the hash algorithm, and obtaining a unique numerical value after calculation by the hash algorithm, wherein each asynchronous task type has a mapping relationship with both the specified asynchronous task processing mode and the default asynchronous task processing mode, there is a first preset priority relationship between the specified asynchronous task processing mode and the default asynchronous task processing mode, there is a second preset priority relationship between different specified asynchronous task processing modes, and there is a third preset priority relationship between different default asynchronous task processing modes.

[0097] Each asynchronous task type has a mapping relationship with both the specified asynchronous task processing mode and the default asynchronous task processing mode. There is a first preset priority relationship between the specified asynchronous task processing mode and the default asynchronous task processing mode, a second preset priority relationship between different specified asynchronous task processing modes, and a third preset priority relationship between different default asynchronous task processing modes.

[0098] The task information that has a mapping relationship with the asynchronous task type is stored in the preset asynchronous task processing mode configuration table according to the preset priority relationship.

[0099] In this embodiment, the task information that has a mapping relationship with the asynchronous task type is stored in the preset asynchronous task processing mode configuration table according to the preset priority relationship. The preset priority relationship may include a first preset priority relationship, a second preset priority relationship, and a third preset priority relationship. The preset priority relationship means that the default asynchronous task processing mode is specified to take precedence over the asynchronous task processing mode. The task information includes: asynchronous task processing mode, task processing time limit, and task quantity.

[0100] Different asynchronous task processing methods are brought together, and the corresponding asynchronous task processing methods are obtained according to the asynchronous task requests in the actual scenario. This can avoid the waste of resources caused by a single asynchronous task processing method to the greatest extent, and can effectively combine the advantages of asynchronous task processing methods.

[0101] Step S30, determining a task parameter assembly template according to the task information;

[0102] In this embodiment, the task information includes an asynchronous task processing method, and the task parameter assembly template can be determined according to the mapping relationship between the pre-established asynchronous task processing method and the task parameter assembly template. The task parameter assembly template refers to a template that assembles different task parameters together by calling a preset function, and the task to be executed can be generated through the task parameter assembly template and the task parameters.

[0103] Step S40, assembling the task parameters to be assembled through the task parameter assembly template to obtain the task to be executed, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed;

[0104] In this embodiment, after an asynchronous task request is received, the task parameters to be assembled are assembled through the task parameter assembly template. The task parameters to be assembled are used to generate tasks to be executed through the task parameter assembly template. Different task parameters to be assembled will generate different types of tasks to be executed. The task execution order and task processing time limit of each task to be executed can be controlled based on the task parameters to be assembled.

[0105] Step S50, executing the task to be executed based on the task parameters to be assembled and the asynchronous task processing method.

[0106] In this embodiment, since different tasks to be executed can be generated through different task parameters to be assembled, and the task execution order and task processing time limit of each task to be executed can be controlled, and since the asynchronous task processing method is obtained in advance, the tasks to be executed can be executed according to the task parameters and the asynchronous task processing method. The task parameters to be assembled determine the task steps, task time limit and type of tasks to be executed. For example, it is stipulated that tasks to be executed within 5 minutes are valid and can be executed. If they exceed 5 minutes, they are invalid and cannot be executed. The asynchronous task processing method determines whether to use the specified asynchronous task processing method or the default asynchronous task processing method when executing the tasks to be executed.

[0107] By combining multiple asynchronous task processing methods, such as Quartz task scheduling, message queues, and asynchronous multithreading, the types of asynchronous task processing methods are increased and the processing efficiency of asynchronous tasks is improved.

[0108] Reference Figure 3 , Figure 3 for Figure 2 In this embodiment, step S20 determines the task information corresponding to the asynchronous task request according to the task type, wherein the task information includes: asynchronous task processing mode, task processing time limit and task quantity, and the asynchronous task processing mode is a specified asynchronous task processing mode or a default asynchronous task processing mode, and includes the following steps:

[0109] Step S201, querying the task information corresponding to the asynchronous task request in the preset asynchronous task processing mode configuration table by polling, wherein the task information includes: asynchronous task processing mode, task processing time limit and task quantity, and the asynchronous task processing mode is a specified asynchronous task processing mode or a default asynchronous task processing mode;

[0110] In this embodiment, a mapping relationship between an asynchronous task type and an asynchronous task processing method can be established in advance, and a specified asynchronous task processing method or a default asynchronous task processing method that matches the asynchronous task type can be queried from a preset asynchronous task processing method configuration table by polling.

[0111] Step S202, judging whether the preset asynchronous task processing mode switch is turned on according to the task information;

[0112] In this embodiment, it is possible to determine whether the preset asynchronous task processing mode switch is in the on state based on the parameters pre-configured in the preset asynchronous task processing mode configuration table. For example, if the parameter contains "TRUE", it indicates that it is in the on state, and if the parameter contains "FALSE", it indicates that it is in the off state.

[0113] Step S203, if the preset specified asynchronous task processing mode switch is turned on, the specified asynchronous task processing mode is obtained;

[0114] Step S204: If the preset asynchronous task processing mode switch is turned off, a default asynchronous task processing mode is obtained.

[0115] In this embodiment, according to the correspondence between pre-configured parameters and various asynchronous task processing modes, when the preset specified asynchronous task processing mode switch is turned on, it can switch to the specified asynchronous task processing mode, and when the switch is turned off, it can switch to the default asynchronous task processing mode.

[0116] Reference Figure 4 , Figure 4 for Figure 3 In this embodiment, in step S203, if the preset asynchronous task processing mode switch is turned on, obtaining the specified asynchronous task processing mode includes the following steps:

[0117] Step S2031, monitoring CPU occupancy and memory usage through a preset monitoring program;

[0118] In this embodiment, the CPU occupancy rate and the memory usage rate are monitored and obtained through a preset monitoring program, the purpose of which is to provide a basis for selecting a suitable asynchronous task processing method after receiving an asynchronous task request.

[0119] In some scenarios, it is not appropriate to use the default asynchronous task processing method. For example, in scenarios where the processing time requirement increases or decreases, or the number of tasks increases or decreases suddenly, you need to use a specified asynchronous task processing method. To facilitate switching, the CPU usage and memory usage are used as the basis for switching the asynchronous task processing method.

[0120] Step S2032, determining whether the CPU occupancy rate is less than or equal to a first preset threshold;

[0121] In this embodiment, a first preset threshold is set in advance, and the value is not limited, for example, the CPU occupancy rate is 50% and the memory usage rate is 40%. Since the actual CPU occupancy rate and the actual memory usage rate in the actual scenario have been monitored, it can be determined whether the CPU occupancy rate is less than or equal to the first preset threshold value.

[0122] Step S2033, if the CPU occupancy rate is less than or equal to the first preset threshold, determine whether the memory usage rate is greater than the second preset threshold;

[0123] Step S2034: if the memory usage rate is greater than the second preset threshold, it is determined that the preset specified asynchronous task processing mode switch is turned on, and the specified asynchronous task processing mode is obtained.

[0124] In this embodiment, if the CPU occupancy rate is less than or equal to the first preset threshold, it is determined whether the memory usage rate is greater than the second preset threshold. Since the default asynchronous task processing method and the specified asynchronous task processing method are combined, different asynchronous task processing methods can be flexibly selected according to the needs of the actual scenario.

[0125] Reference Figure 5 , Figure 5 for Figure 2 In this embodiment, step S50, executing the task to be executed based on the task parameters and the asynchronous task processing method, includes the following steps:

[0126] Step S501, obtaining the asynchronous task processing method with the highest priority according to the priorities of the preset asynchronous task processing methods in the preset asynchronous task processing method configuration table;

[0127] In this embodiment, the asynchronous task processing method with the highest priority is obtained according to the priority of the preset processing method in the preset asynchronous task processing method configuration table. For example, the priority of Quartz task scheduling is higher than that of message queue, and the priority of message queue is higher than that of asynchronous multithreading. In this case, Quartz task scheduling is used preferentially when using it. Quartz is an open source task schedule management system.

[0128] Step S502, determining task step data according to the asynchronous task processing mode, and using the task step data as part of the task parameters to be assembled, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed;

[0129] In this embodiment, task step data corresponding to each task can be obtained according to the asynchronous task processing method. For example, if the current asynchronous task processing method is the quartz task, the task step data of the quartz task is first used as part of the task parameters to be assembled. The task step data can also be written into the task scheduling table, and the task is executed after the task record is captured.

[0130] Step S503: executing the task to be executed based on the task parameters to be assembled and the asynchronous task processing method.

[0131] In this embodiment, since different tasks to be executed can be generated through different task parameters to be assembled, and the task execution order and task processing time limit of each task to be executed can be controlled, and since the asynchronous task processing method is obtained in advance, the tasks to be executed can be executed according to the task parameters to be assembled and the asynchronous task processing method.

[0132] Reference Figure 6 , Figure 6 for Figure 5 In this embodiment, step S503, executing the task to be executed based on the task parameters to be assembled and the asynchronous task processing method includes the following steps:

[0133] Step S5031, determining whether the task step data includes multiple steps;

[0134] In this embodiment, the purpose of determining whether multiple steps are included is that in certain high-concurrency scenarios, multiple steps can be processed concurrently. Compared with the sequential execution method, the concurrent processing method can save a certain amount of time.

[0135] Step S5032: if the task step data includes multiple steps, determine whether the multiple steps meet the conditions for concurrent processing;

[0136] In this embodiment, the conditions for triggering concurrent processing are preset, and if the task step includes multiple steps, the steps of concurrent processing are executed.

[0137] Step S5033: if multiple steps meet the conditions for concurrent processing, then based on the task parameters to be assembled and the asynchronous task processing method, multiple steps are used to execute the tasks to be executed in a concurrent manner;

[0138] In this embodiment, the concurrent processing instruction is triggered only when the concurrent processing conditions are met, and time can be saved by processing tasks in a concurrent manner.

[0139] Step S5034: if the multiple steps do not meet the conditions for concurrent processing, the tasks to be executed are executed in a preset order of the multiple steps based on the task parameters to be assembled and the asynchronous task processing method.

[0140] In this embodiment, when the conditions for concurrent processing are not met, the tasks are processed according to a preset order of multiple steps.

[0141] Reference Figure 7 , Figure 7 for Figure 5Detailed flow chart of step S502 in an embodiment. In this embodiment, step S502 determines the task step data according to the asynchronous task processing method, and uses the task step data as part of the task parameters to be assembled, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed, including the following steps:

[0142] Step S5021, traverse the asynchronous task processing mode, and determine whether the asynchronous task processing mode includes at least one of an open source task schedule management system, a message queue, and an asynchronous multithreading;

[0143] In this embodiment, if the asynchronous task processing method includes at least one of quartz tasks, message queues and asynchronous multi-threading, the task steps are determined according to the current asynchronous task processing method, wherein the quartz task is used to: write task records into a task scheduling table, capture task records and execute tasks; the message queue is used to: the message consumer end pulls new messages from the message middleware, wherein the message of the message middleware comes from pushing task parameters to the message middleware in the form of a message body, and the message consumer end parses the message body and executes tasks; asynchronous multi-threading is used to: obtain available threads from the thread pool and execute tasks according to the available threads.

[0144] The asynchronous task processing methods may be traversed in sequence to determine whether the asynchronous task processing methods include at least one of an open source task schedule management system, a message queue, and asynchronous multithreading.

[0145] Step S5022, if the asynchronous task processing method includes at least one of an open source task schedule management system, a message queue, and asynchronous multithreading, then the task step data corresponding to the asynchronous task processing method is obtained, and the task step data is used as part of the task parameters to be assembled, wherein the task parameters to be assembled include: task step data, task timeliness data, and task type data to be executed.

[0146] In this embodiment, each asynchronous task processing method has corresponding task step data, and the task step data will only be obtained when the asynchronous task processing method includes at least one of an open source task schedule management system, a message queue, and asynchronous multithreading.

[0147] Reference Figure 8 , Figure 8 for Figure 2 In this embodiment, in step S40, the task parameters to be assembled are assembled through the task parameter assembly template to obtain the task to be executed, and the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed include:

[0148] Step S401, establishing a matching relationship between a task parameter assembly template and task parameters to be assembled by using a hash algorithm;

[0149] Step S402, based on the matching relationship, assemble the current task parameters to be assembled through the task parameter assembly template to obtain the task to be executed, and the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed.

[0150] In this embodiment, a matching relationship between a task parameter assembly template and the task parameters to be assembled is established through a hash algorithm, and this matching relationship is constructed in the form of a key-value pair. When an asynchronous task request is received, the specified task parameters to be assembled are assembled into the task parameter assembly template according to the pre-established matching relationship, thereby obtaining a task to be executed.

[0151] Reference Fig. 9 , Fig. 9 This is a functional module diagram of an embodiment of an asynchronous task processing device of the present invention. In this embodiment, the asynchronous task processing device includes the following modules:

[0152] The receiving module 10 is used to receive an asynchronous task request, where the asynchronous task request includes a task type of the asynchronous task;

[0153] The task information selection module 20 is used to determine the task information corresponding to the asynchronous task request according to the task type, wherein the task information includes: asynchronous task processing mode, task processing time limit and task quantity, wherein the asynchronous task processing mode is a specified asynchronous task processing mode or a default asynchronous task processing mode;

[0154] A task parameter assembly template selection module 30 is used to determine a task parameter assembly template according to task information;

[0155] An assembly module 40 is used to assemble the task parameters to be assembled through the task parameter assembly template to obtain the task to be executed, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed;

[0156] The execution module 50 is used to execute the task to be executed based on the task parameters to be assembled and the asynchronous task processing method.

[0157] In this embodiment, the asynchronous task processing method, task processing timeliness and task quantity can be determined through the task information selection module in this device, thereby achieving the purpose of more flexibly selecting the asynchronous task processing method and improving the efficiency of asynchronous task processing.

[0158] The present invention also provides a computer-readable storage medium.

[0159] In this embodiment, an asynchronous task processing program is stored on the computer-readable storage medium, and when the asynchronous task processing program is executed by the processor, the steps of the asynchronous task processing method described in any of the above embodiments are implemented.

[0160] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM) and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0161] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the enlightenment of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims. All equivalent structures or equivalent process changes made using the contents of the specification and drawings of the present invention, or directly or indirectly used in other related technical fields, are protected by the present invention.

Claims

1. An asynchronous task processing method, characterized in that: The asynchronous task processing method comprises the following steps: receiving an asynchronous task request, wherein the asynchronous task request includes a task type of the asynchronous task; Determine task information corresponding to the asynchronous task request according to the task type, wherein the task information includes: an asynchronous task processing mode, a task processing time limit, and a task quantity, and the asynchronous task processing mode is a specified asynchronous task processing mode or a default asynchronous task processing mode; Determine a task parameter assembly template according to the task information; Assembling the task parameters to be assembled through the task parameter assembly template to obtain the task to be executed, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed; Execute the task to be executed based on the task parameters to be assembled and the asynchronous task processing method; The execution of the task to be executed based on the task parameters to be assembled and the asynchronous task processing method includes the following steps: obtaining the asynchronous task processing method with the highest priority according to the priority of the preset asynchronous task processing method in the preset asynchronous task processing method configuration table; determining the task step data according to the asynchronous task processing method, and using the task step data as part of the task parameters to be assembled, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed; executing the task to be executed based on the task parameters to be assembled and the asynchronous task processing method; The execution of the task to be executed based on the task parameters to be assembled and the asynchronous task processing method includes the following steps: determining whether the task step data includes multiple steps; if the task step data includes multiple steps, determining whether the multiple steps meet the conditions for concurrent processing; if the multiple steps meet the conditions for concurrent processing, executing the task to be executed in a concurrent manner using the multiple steps based on the task parameters to be assembled and the asynchronous task processing method; if the multiple steps do not meet the conditions for concurrent processing, executing the task to be executed in a preset order of the multiple steps based on the task parameters to be assembled and the asynchronous task processing method; The method of determining task step data according to the asynchronous task processing method and using the task step data as part of the task parameters to be assembled, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed, includes the following steps: traversing the asynchronous task processing method, and determining whether the asynchronous task processing method includes at least one of an open source task schedule management system, a message queue and asynchronous multithreading; if the asynchronous task processing method includes at least one of an open source task schedule management system, a message queue and asynchronous multithreading, then obtaining the task step data corresponding to the asynchronous task processing method, and using the task step data as part of the task parameters to be assembled, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed.

2. The asynchronous task processing method according to claim 1, characterized in that: The step of determining task information corresponding to the asynchronous task request according to the task type, wherein the task information includes: an asynchronous task processing mode, a task processing time limit, and a task quantity, and the asynchronous task processing mode is a specified asynchronous task processing mode or a default asynchronous task processing mode, comprises the following steps: Querying task information corresponding to the asynchronous task request in a preset asynchronous task processing mode configuration table by polling, wherein the task information includes: asynchronous task processing mode, task processing time limit and task quantity, and the asynchronous task processing mode is a specified asynchronous task processing mode or a default asynchronous task processing mode; According to the task information, determining whether a preset asynchronous task processing mode switch is turned on; If the preset specified asynchronous task processing mode switch is turned on, the specified asynchronous task processing mode is obtained; If the preset asynchronous task processing mode switch is turned off, the default asynchronous task processing mode is obtained.

3. The asynchronous task processing method according to claim 2, characterized in that: If the preset specified asynchronous task processing mode switch is turned on, obtaining the specified asynchronous task processing mode includes the following steps: Monitor CPU usage and memory usage through pre-set monitoring programs; Determine whether the CPU occupancy rate is less than or equal to a first preset threshold; If the CPU occupancy rate is less than or equal to the first preset threshold, determining whether the memory usage rate is greater than a second preset threshold; If the memory usage rate is greater than the second preset threshold, it is determined that the preset specified asynchronous task processing mode switch is turned on, and the specified asynchronous task processing mode is obtained.

4. The asynchronous task processing method according to any one of claims 1 to 3, characterized in that: The task parameters to be assembled are assembled through the task parameter assembly template to obtain the task to be executed, and the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed include: A matching relationship between the task parameter assembly template and the task parameters to be assembled is established through a hash algorithm; Based on the matching relationship, the task parameters to be assembled are assembled through the task parameter assembly template to obtain the task to be executed. The task parameters to be assembled include: task step data, task timeliness data and task type data to be executed.

5. An asynchronous task processing device, characterized in that: The asynchronous task processing device comprises the following modules: A receiving module, used for receiving an asynchronous task request, wherein the asynchronous task request includes a task type of the asynchronous task; A task information selection module, used to determine the task information corresponding to the asynchronous task request according to the task type, wherein the task information includes: an asynchronous task processing mode, a task processing time limit and a task quantity, and the asynchronous task processing mode is a specified asynchronous task processing mode or a default asynchronous task processing mode; A task parameter assembly template selection module, used to determine a task parameter assembly template according to the task information; An assembly module, used for assembling the task parameters to be assembled through the task parameter assembly template to obtain the task to be executed, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed; An execution module, used for executing the task to be executed based on the task parameters to be assembled and the asynchronous task processing method; The execution of the task to be executed based on the task parameters to be assembled and the asynchronous task processing method includes the following steps: obtaining the asynchronous task processing method with the highest priority according to the priority of the preset asynchronous task processing method in the preset asynchronous task processing method configuration table; determining the task step data according to the asynchronous task processing method, and using the task step data as part of the task parameters to be assembled, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed; executing the task to be executed based on the task parameters to be assembled and the asynchronous task processing method; The execution of the task to be executed based on the task parameters to be assembled and the asynchronous task processing method includes the following steps: determining whether the task step data includes multiple steps; if the task step data includes multiple steps, determining whether the multiple steps meet the conditions for concurrent processing; if the multiple steps meet the conditions for concurrent processing, executing the task to be executed in a concurrent manner using the multiple steps based on the task parameters to be assembled and the asynchronous task processing method; if the multiple steps do not meet the conditions for concurrent processing, executing the task to be executed in a preset order of the multiple steps based on the task parameters to be assembled and the asynchronous task processing method; The method of determining task step data according to the asynchronous task processing method and using the task step data as part of the task parameters to be assembled, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed, includes the following steps: traversing the asynchronous task processing method, and determining whether the asynchronous task processing method includes at least one of an open source task schedule management system, a message queue and asynchronous multithreading; if the asynchronous task processing method includes at least one of an open source task schedule management system, a message queue and asynchronous multithreading, then obtaining the task step data corresponding to the asynchronous task processing method, and using the task step data as part of the task parameters to be assembled, wherein the task parameters to be assembled include: task step data, task timeliness data and task type data to be executed.

6. An asynchronous task processing device, characterized in that: The asynchronous task processing device includes a memory, a processor, and an asynchronous task processing program stored in the memory and executable on the processor. When the asynchronous task processing program is executed by the processor, the steps of the asynchronous task processing method according to any one of claims 1 to 4 are implemented.

7. A computer-readable storage medium, characterized in that: An asynchronous task processing program is stored on the computer-readable storage medium, and when the asynchronous task processing program is executed by the processor, the steps of the asynchronous task processing method according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Asynchronous batch processing method and system

    CN106126354A

  • Multi-GPU-based graph data processing system and method

    CN107122244A