Task processing method and device, equipment, readable storage medium and program product
By setting the preset dequeue order according to the task schedule processing time and scheduling priority in the task scheduling queue, the problem of poor processing flexibility in traditional task processing methods is solved, and more efficient and safe task processing is achieved.
Patent Information
- Application Number
- CN202411772589.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-03-04
AI Technical Summary
In traditional task processing methods, the task queue processes tasks in a first-in-first-out order, resulting in poor processing flexibility and inability to effectively handle different tasks requirements, such as task failure retry, task priority and timing execution, etc.
By setting a preset dequeuing order in the task scheduling queue according to the scheduled processing time and scheduling priority of the task, task data is obtained and the task to be processed is processed according to the task data and the first processing version identification.
It improves the flexibility of task processing, so that the processing system can flexibly schedule according to different tasks needs, avoids repeated tasks and improves the security of processing.
Smart Images

Figure CN119557102A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a task processing method, apparatus, device, readable storage medium and program product. Background Art
[0002] With the development of computer technology, the amount of data that needs to be processed is increasing. In order to meet the needs of large-scale access, task queues are usually used to schedule tasks.
[0003] In traditional technology, after receiving a task, the task queue will put the task into the queue, and then dequeue the task for processing in the order of first-in-first-out.
[0004] However, the above task processing method has the problem of poor processing flexibility. Summary of the invention
[0005] Based on this, it is necessary to provide a task processing method, device, equipment, readable storage medium and program product that can improve processing flexibility in response to the above technical problems.
[0006] In a first aspect, the present application provides a task processing method, comprising:
[0007] Obtaining task data corresponding to at least one pending task from the task scheduling queue according to a preset dequeueing order corresponding to the task scheduling queue, wherein the preset dequeueing order is related to a planned processing time and a scheduling priority corresponding to each pending task;
[0008] For each task to be processed, obtain a first processing version identifier corresponding to the task to be processed;
[0009] The task to be processed is processed according to the task data and the first processing version identifier.
[0010] In one embodiment, processing the pending task according to the task data and the first processing version identifier includes:
[0011] Determine whether the pending task needs to be processed currently according to the planned processing time included in the task data;
[0012] If the pending task needs to be processed, the pending task is processed according to the second processing version identifier and the first processing version identifier included in the task data.
[0013] In one embodiment, processing the task to be processed according to the second processing version identifier and the first processing version identifier included in the task data includes:
[0014] If the first processing version identifier is consistent with the second processing version identifier, the to-be-processed task is dequeued, and the dequeued to-be-processed task is processed.
[0015] In one embodiment, the method further comprises:
[0016] If the processing result of the task to be processed is successful, the first processing version identifier is updated.
[0017] If the execution result is execution failure, the first processing version identifier is updated, and the to-be-processed task is rewritten into the task scheduling queue.
[0018] In one embodiment, the method further comprises:
[0019] Acquire task data corresponding to the task to be processed, and generate scheduling information corresponding to the task to be processed according to the task data, wherein the scheduling information includes a first processing version identifier;
[0020] According to the task data, the task data and the pending tasks are written into the task scheduling queue, and the scheduling order information is written into the target storage space.
[0021] In one embodiment, writing the task data and the to-be-processed task into the task scheduling queue according to the task data includes:
[0022] Writing the pending tasks and the task data into a task scheduling queue;
[0023] Get the sorting timestamp corresponding to each pending task in the task scheduling queue;
[0024] The sorting order is determined according to each sorting timestamp, and the order of each pending task in the task scheduling queue is adjusted according to the sorting order, and the sorting order is consistent with the preset dequeue order.
[0025] In a second aspect, the present application provides a task processing device, the device comprising:
[0026] A first acquisition module is used to acquire task data corresponding to at least one pending task from the task scheduling queue according to a preset dequeue order corresponding to the task scheduling queue, wherein the preset dequeue order is related to a planned processing time and a scheduling priority corresponding to each pending task;
[0027] A second acquisition module is used to acquire, for each task to be processed, a first processing version identifier corresponding to the task to be processed;
[0028] The processing module is used to process the task to be processed according to the task data and the first processing version identifier.
[0029] In a third aspect, an embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method of the first aspect when executing the computer program.
[0030] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method of the first aspect described above.
[0031] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the method in the first aspect are implemented.
[0032] The above-mentioned task processing method, device, equipment, readable storage medium and program product obtain task data corresponding to at least one pending task from the task scheduling queue according to the preset dequeue order corresponding to the task scheduling queue, and obtain the first processing version identifier corresponding to the pending task for each pending task, so that the pending task can be processed according to the task data and the first processing version identifier, wherein the preset dequeue order is related to the planned processing time and scheduling priority corresponding to each pending task. In this way, by setting the preset dequeue order corresponding to each pending task in the task scheduling queue according to the planned processing time and scheduling priority, and obtaining task data according to the preset dequeue order, the problem of poor processing flexibility existing in processing tasks according to the first-in-first-out order in the traditional technology is avoided. The technical solution provided by the present application can obtain task data based on the planned processing time and scheduling priority in the task scheduling queue, so that the planned processing time and scheduling priority corresponding to the pending task will also be considered when the pending task is processed according to the task data, and the processing flexibility is higher. In addition, when processing the pending task, the pending task will also be processed according to the first processing version identifier, avoiding the repeated processing of the pending task and improving the security of the processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0034] Figure 1 An application environment diagram of a task processing method in an embodiment;
[0035] Figure 2is a flowchart of a task processing method in one embodiment;
[0036] Figure 3 is a schematic flow chart of step 203 in another embodiment;
[0037] Figure 4 A schematic diagram of a process of writing a pending task into a task scheduling queue in another embodiment;
[0038] Figure 5 is a flowchart of an exemplary task processing method in another embodiment;
[0039] Figure 6 is a structural block diagram of a task processing device in one embodiment;
[0040] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0042] With the development of computer technology, the traditional single server architecture is difficult to meet the needs of large-scale, high-concurrency access, and distributed technology has emerged. In related technologies, distributed technology is usually used to distribute tasks and data on multiple computers, and load balancing is achieved through asynchronous scheduling, thereby improving the system's processing power and scalability.
[0043] When tasks are scheduled asynchronously, they are usually scheduled using a task queue. After receiving a task, the task queue will put the task into a queue and then dequeue the task for processing in a first-in-first-out order.
[0044] However, in actual development, tasks have a variety of demand characteristics, such as task failures that require retries, tasks with higher priority that require advance processing, and tasks that need to be executed on a scheduled basis. Therefore, there is a problem of poor flexibility in processing tasks based on task queues in traditional technologies.
[0045] In view of this, the present application provides a task processing method, device, equipment, readable storage medium and program product, according to the preset dequeue order corresponding to the task scheduling queue, the task data corresponding to at least one task to be processed is obtained from the task scheduling queue, and for each task to be processed, the first processing version identifier corresponding to the task to be processed is obtained, and the task to be processed can be processed according to the task data and the first processing version identifier, wherein the preset dequeue order is related to the planned processing time and scheduling priority corresponding to each task to be processed. In this way, by setting the preset dequeue order corresponding to each task to be processed in the task scheduling queue according to the planned processing time and scheduling priority, and obtaining the task data according to the preset dequeue order, the problem of poor processing flexibility in processing tasks according to the first-in-first-out order in the traditional technology is avoided. The technical solution provided by the present application can obtain task data based on the planned processing time and scheduling priority in the task scheduling queue, so that the planned processing time and scheduling priority corresponding to the task to be processed will also be considered when the task to be processed is processed according to the task data, and the processing flexibility is higher. In addition, when processing the task to be processed, the task to be processed will also be processed according to the first processing version identifier, avoiding the repeated processing of the task to be processed and improving the security of processing.
[0046] The task processing method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the data storage system can store the data that the server 101 needs to process. The data storage system can be integrated on the server 101, or it can be placed on the cloud or other network servers. Among them, the server 101 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.
[0047] In an exemplary embodiment, Figure 2 As shown, a task processing method is provided, which is applied to Figure 1 The server 101 in the example is used as an example to illustrate, including the following steps 201 to 203. Among them:
[0048] Step 201 , according to a preset dequeueing order corresponding to the task scheduling queue, obtain task data corresponding to at least one to-be-processed task from the task scheduling queue.
[0049] In an embodiment of the present application, the task scheduling queue may be a queue for sorting tasks to be processed according to a preset dequeue order, wherein the preset dequeue order is related to the planned processing time and scheduling priority corresponding to each task to be processed.
[0050] In a possible implementation, the task scheduling queue may be an ordered queue structure in the form of Redis (Remote Dictionary Server), such as ZSET (ordered list) and the like.
[0051] The server can obtain task data corresponding to at least one to-be-processed task from the task scheduling queue according to a preset dequeue order. Regarding the quantity of task data obtained, optionally, the server can obtain task data according to a preset quantity, which can be determined by the actual throughput.
[0052] The server can directly obtain the task data corresponding to each pending task from the task scheduling queue. Optionally, the server can parse the task structure corresponding to each pending task according to a preset dequeue order to obtain the task data corresponding to each pending task. Optionally, the server can determine multiple target pending tasks according to a preset dequeue order. The server can obtain the task identifier corresponding to each target pending task, and obtain the task data corresponding to each target pending task from the database according to each task identifier.
[0053] The task data is related to the actual business situation of each task to be processed. In an embodiment of the present application, the task data may include attribute information of the task to be processed, such as the task identifier corresponding to the task to be processed, the planned scheduling time, priority, version identifier, etc. The version identifier may be an optimistic lock version number.
[0054] Step 202: For each task to be processed, obtain a first processing version identifier corresponding to the task to be processed.
[0055] The server may also obtain a first processing version identifier corresponding to the task to be processed, and the first version identifier may be an optimistic lock version number.
[0056] In a possible implementation, the server may obtain the first processing version identifier corresponding to the task to be processed according to the task identifier corresponding to the task to be processed.
[0057] In another possible implementation, when the server writes the pending task into the task scheduling queue, it will also generate scheduling order information corresponding to the pending task. The scheduling order information may include task creation time, planned scheduling time, actual scheduling time, scheduling completion time, maximum scheduling times, current scheduling times, scheduling status, scheduling policy type, scheduling rules, execution method, first version identifier, etc. The scheduling order information will be stored in the target storage space. When the server obtains the first processing version identifier corresponding to the pending task, it can first determine the scheduling order information corresponding to the pending task based on the task identifier corresponding to the pending task, and then obtain the first processing version identifier corresponding to the pending task from the scheduling order information.
[0058] Step 203: Process the task to be processed according to the task data and the first processing version identifier.
[0059] After acquiring the task data and the first processing version identifier corresponding to the task to be processed, the server may process the task to be processed according to the task data and the first processing version identifier.
[0060] In one possible implementation, the server can obtain the planned processing time corresponding to the task to be processed based on the task data, and the server can detect whether the current time reaches the planned processing time. Optionally, if it has been reached, the server can perform subsequent processing on the task to be processed; optionally, if it has not been reached, the server can stop scheduling the task to be processed and schedule the next task to be processed.
[0061] In one possible implementation, for pending tasks that have reached the planned processing time, the server can obtain the second processing version identifier included in the task data, and detect whether the second processing version identifier is consistent with the first processing version identifier. If they are consistent, the server can dequeue and execute processing on the pending task. If they are inconsistent, the server can discard the task data, thereby avoiding repeated processing of the pending task.
[0062] In the above embodiment, a preset dequeue order corresponding to each task to be processed is set in the task scheduling queue according to the planned processing time and the scheduling priority, and the task data is obtained according to the preset dequeue order, thereby avoiding the problem of poor processing flexibility in traditional technology of processing tasks in a first-in-first-out order. The technical solution provided in the present application can obtain task data based on the planned processing time and the scheduling priority in the task scheduling queue, so that when the task to be processed is subsequently processed according to the task data, the planned processing time and the scheduling priority corresponding to the task to be processed will also be taken into consideration, and the processing flexibility is higher. In addition, when processing the task to be processed, the task to be processed will also be processed according to the first processing version identifier, thereby avoiding repeated processing of the task to be processed and improving the security of processing.
[0063] In one embodiment, based on the above Figure 2 The embodiment shown, see Figure 3 This embodiment relates to a process of processing a pending task according to task data and a first processing version identifier. Figure 3 As shown, step 203 may include step 301 and step 302 .
[0064] Step 301, determining whether it is necessary to process the pending task currently according to the planned processing time included in the task data.
[0065] Step 302: If the task to be processed needs to be processed, the task to be processed is processed according to the second processing version identifier and the first processing version identifier included in the task data.
[0066] The planned processing time may be the expected processing time set for the task to be processed. In the embodiment of the present application, the server may detect whether the current time reaches the planned processing time, thereby determining whether the task to be processed needs to be processed at present.
[0067] Optionally, if the current time does not reach the planned processing time, the server may determine that the pending task does not need to be processed currently, and may stop processing the pending task and wait for the next round to process it.
[0068] Optionally, if the pending task needs to be processed, the server may process the pending task according to the second processing version identifier and the first processing version identifier included in the task data.
[0069] In the embodiment of the present application, the second process version identifier may be a process version identifier included in the task data, and the process version identifier may be an optimistic lock version identifier.
[0070] In order to avoid the situation where the pending task is a task that has already been processed, the server can process the pending task according to the second processing version identifier and the first processing version identifier included in the task data. In a possible implementation, the server can detect whether the second processing version identifier is consistent with the first processing version identifier. If the first optimistic lock version number is consistent with the second optimistic lock version number, the server can dequeue the pending task and process the dequeued pending task.
[0071] Regarding the process of the server processing the pending tasks, in a possible implementation mode, the server can obtain the scheduling information corresponding to the pending tasks through the task identifier corresponding to the pending tasks, thereby obtaining the execution strategy and input parameter information corresponding to the pending tasks, and send the pending tasks to the message queue according to the execution strategy and input parameter information to wait for the consumer to consume and process them.
[0072] After consuming the task to be processed, the server may obtain the processing result of the task to be processed. Optionally, if the processing result of the task to be processed is successful, the first processing version identifier is updated.
[0073] In one possible implementation, the server can also detect whether the current pending task needs to be processed again. For example, the server can obtain the scheduling type corresponding to the pending task from the scheduling order information, and the scheduling type can include repeated processing, or the server can obtain the current scheduling number and the expected scheduling number of the pending task from the scheduling order information. If the current scheduling number reaches the expected scheduling number, the server can determine that the pending task needs to be processed again. At this time, the server can update the first processing version identifier included in the scheduling order information. At the same time, it can also update the scheduling status included in the scheduling order information to wait for retry processing, and it can also update information such as the planned scheduling time. After the update is completed, the server can add the pending task to the task scheduling queue.
[0074] In another possible implementation, if the server determines that the pending task does not need to be processed any further, the server may directly update the scheduling status included in the scheduling order information to successfully processed.
[0075] Optionally, if the execution result is execution failure, the first processing version identifier is updated, and the to-be-processed task is rewritten into the task scheduling queue.
[0076] In one possible implementation, if the execution result is an execution failure, the server can detect whether it is necessary to retry the pending task. If a retry is required, the server can update the first processing version identifier and update the scheduling status to wait for retry processing. The server can also update the number of retries and the planned scheduling time to the current time. After the update is completed, the server can add the pending task to the task scheduling queue.
[0077] In another possible implementation, if the server determines that there is no need to attempt to process the pending task again, the server may directly update the scheduling status included in the scheduling order information to processing failure.
[0078] In one embodiment, based on the above Figure 2 and 3 The embodiment shown, see Figure 4 , this embodiment involves the process of writing the pending tasks into the task scheduling queue. Figure 4 As shown, the process may include step 401 and step 402 .
[0079] Step 401, obtaining task data corresponding to the task to be processed, and generating scheduling information corresponding to the task to be processed according to the task data.
[0080] The dispatch order information includes a first processing version identifier.
[0081] In an embodiment of the present application, the pending tasks may be tasks waiting to be processed. Optionally, the server may obtain the pending tasks input by the user through an external input device. Optionally, the server may obtain the pending tasks generated by the system.
[0082] When obtaining the task to be processed, the server may also obtain the task data corresponding to the task to be processed. Optionally, the server may directly extract the task data from the task to be processed; optionally, the server may obtain the task data input by the user through an external input device.
[0083] After obtaining the task data, the server can generate the scheduling information corresponding to the task to be processed based on the task data. Optionally, a decorator with preset rules can be deployed. The server can process the task data through the decorator to obtain the scheduling information corresponding to the task to be processed.
[0084] In an embodiment of the present application, the dispatch order information may include a first processing version identifier.
[0085] Step 402, writing the task data and the pending tasks into the task scheduling queue according to the task data, and writing the scheduling list information into the target storage space.
[0086] After acquiring the dispatch order information, the server may write the dispatch order information into a target storage space, and the target storage space may belong to a database.
[0087] The server can also write task data and pending tasks into the task scheduling queue. In an embodiment of the present application, the server can write the pending tasks and the task data into the task scheduling queue, and obtain the sorting timestamps corresponding to each pending task in the task scheduling queue, and then determine the sorting order according to each sorting timestamp, and adjust the order of each pending task in the task scheduling queue according to the sorting order, wherein the sorting order is consistent with the preset dequeue order.
[0088] Optionally, the server may write the task data and the pending tasks in association with each other into the task scheduling queue; optionally, the server may generate a corresponding task structure according to the task data and the pending tasks, and write the task structure into the task scheduling queue.
[0089] In one embodiment, referring to Figure 5 , provides an exemplary task processing method, which can be applied to Figure 1 In the implementation environment shown.
[0090] Step 501, obtaining task data corresponding to the task to be processed, and generating scheduling information corresponding to the task to be processed according to the task data.
[0091] The dispatch order information includes a first processing version identifier.
[0092] Step 502: write the to-be-processed task and the task data into a task scheduling queue.
[0093] Step 503, obtaining the sorting timestamp corresponding to each to-be-processed task in the task scheduling queue.
[0094] Step 504: determine the sorting order according to each sorting timestamp, and adjust the order of each to-be-processed task in the task scheduling queue according to the sorting order.
[0095] Among them, the sorting order is consistent with the preset queue order.
[0096] Step 505, writing the dispatch order information into the target storage space.
[0097] Step 506: Obtain task data corresponding to at least one to-be-processed task from the task scheduling queue according to a preset dequeueing order corresponding to the task scheduling queue.
[0098] The preset dequeue order is related to the planned processing time and scheduling priority of each task to be processed.
[0099] Step 507: For each task to be processed, obtain a first processing version identifier corresponding to the task to be processed.
[0100] Step 508: Determine whether the pending task needs to be processed currently according to the planned processing time included in the task data.
[0101] Step 509: if the pending task needs to be processed, then if the first processing version identifier is consistent with the second processing version identifier, the pending task is dequeued, and the dequeued pending task is processed.
[0102] Step 510: If the processing result of the task to be processed is successful, the first processing version identifier is updated.
[0103] Step 511: If the execution result is execution failure, the first processing version identifier is updated, and the task to be processed is rewritten into the task scheduling queue.
[0104] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0105] Based on the same inventive concept, the embodiment of the present application also provides a task processing device for implementing the task processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more task processing device embodiments provided below can refer to the limitations on the task processing method above, and will not be repeated here.
[0106] In an exemplary embodiment, Figure 6 As shown, a task processing device is provided, including: a first acquisition module 601, a second acquisition module 60 and a processing module 603, wherein:
[0107] A first acquisition module 601 is used to acquire task data corresponding to at least one pending task from the task scheduling queue according to a preset dequeueing order corresponding to the task scheduling queue, wherein the preset dequeueing order is related to a planned processing time and a scheduling priority corresponding to each pending task;
[0108] A second acquisition module 602 is used to acquire, for each of the tasks to be processed, a first processing version identifier corresponding to the task to be processed;
[0109] The processing module 603 is used to process the to-be-processed task according to the task data and the first processing version identifier.
[0110] In one embodiment, the processing module 603 includes:
[0111] A judgment unit, used for determining whether the pending task needs to be processed currently according to the planned processing time included in the task data;
[0112] The task processing unit is used to process the task to be processed according to the second processing version identifier and the first processing version identifier included in the task data if the task to be processed needs to be processed.
[0113] In one embodiment, the task processing unit is specifically configured to perform the following steps:
[0114] If the first processing version identifier is consistent with the second processing version identifier, the pending task is dequeued, and the pending task is processed after being dequeued.
[0115] In one embodiment, the processing module 603 further includes:
[0116] The processing success unit is used to update the first processing version identifier if the processing result of the task to be processed is successful.
[0117] The processing failure unit is used to update the first processing version identifier and rewrite the to-be-processed task into the task scheduling queue if the execution result is an execution failure.
[0118] In one embodiment, the apparatus further comprises:
[0119] a third acquisition module, configured to acquire the task data corresponding to the task to be processed, and generate scheduling information corresponding to the task to be processed according to the task data, wherein the scheduling information includes the first processing version identifier;
[0120] The writing module is used to write the task data and the pending tasks into the task scheduling queue according to the task data, and write the scheduling order information into the target storage space.
[0121] In one embodiment, the write module includes:
[0122] A task writing unit, writing the to-be-processed task into the task scheduling queue;
[0123] A timestamp acquisition unit, used to acquire a sorting timestamp corresponding to each to-be-processed task in the task scheduling queue;
[0124] A sorting unit is used to determine a sorting order according to each of the sorting timestamps, and adjust the order of each of the to-be-processed tasks in the task scheduling queue according to the sorting order, wherein the sorting order is consistent with the preset dequeueing order.
[0125] Each module in the above task processing device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0126] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 7 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store task processing data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a task processing method is implemented.
[0127] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0128] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0129] Obtaining task data corresponding to at least one to-be-processed task from the task scheduling queue according to a preset dequeueing order corresponding to the task scheduling queue, wherein the preset dequeueing order is related to the planned processing time and scheduling priority corresponding to each of the to-be-processed tasks;
[0130] For each of the tasks to be processed, obtaining a first processing version identifier corresponding to the task to be processed;
[0131] The to-be-processed task is processed according to the task data and the first processing version identifier.
[0132] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0133] Determining whether the pending task needs to be processed currently according to the planned processing time included in the task data;
[0134] If the pending task needs to be processed, the pending task is processed according to the second processing version identifier and the first processing version identifier included in the task data.
[0135] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0136] If the first processing version identifier is consistent with the second processing version identifier, the pending task is dequeued, and the pending task is processed after being dequeued.
[0137] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0138] If the processing result of the task to be processed is successful, the first processing version identifier is updated.
[0139] If the execution result is execution failure, the first processing version identifier is updated, and the to-be-processed task is rewritten into the task scheduling queue.
[0140] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0141] Acquire the task data corresponding to the task to be processed, and generate scheduling information corresponding to the task to be processed according to the task data, wherein the scheduling information includes the first processing version identifier;
[0142] The task data and the pending tasks are written into the task scheduling queue according to the task data, and the scheduling list information is written into the target storage space.
[0143] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0144] Writing the pending task and the task data into the task scheduling queue;
[0145] Obtaining the sorting timestamp corresponding to each pending task in the task scheduling queue;
[0146] A sorting order is determined according to each of the sorting timestamps, and the order of each of the to-be-processed tasks in the task scheduling queue is adjusted according to the sorting order, and the sorting order is consistent with the preset dequeueing order.
[0147] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0148] Obtaining task data corresponding to at least one to-be-processed task from the task scheduling queue according to a preset dequeueing order corresponding to the task scheduling queue, wherein the preset dequeueing order is related to the planned processing time and scheduling priority corresponding to each of the to-be-processed tasks;
[0149] For each of the tasks to be processed, obtaining a first processing version identifier corresponding to the task to be processed;
[0150] The to-be-processed task is processed according to the task data and the first processing version identifier.
[0151] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0152] Determining whether the pending task needs to be processed currently according to the planned processing time included in the task data;
[0153] If the pending task needs to be processed, the pending task is processed according to the second processing version identifier and the first processing version identifier included in the task data.
[0154] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0155] If the first processing version identifier is consistent with the second processing version identifier, the pending task is dequeued, and the pending task is processed after being dequeued.
[0156] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0157] If the processing result of the task to be processed is successful, the first processing version identifier is updated.
[0158] If the execution result is execution failure, the first processing version identifier is updated, and the to-be-processed task is rewritten into the task scheduling queue.
[0159] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0160] Acquire the task data corresponding to the task to be processed, and generate scheduling information corresponding to the task to be processed according to the task data, wherein the scheduling information includes the first processing version identifier;
[0161] The task data and the pending tasks are written into the task scheduling queue according to the task data, and the scheduling list information is written into the target storage space.
[0162] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0163] Writing the pending task and the task data into the task scheduling queue;
[0164] Obtaining the sorting timestamp corresponding to each pending task in the task scheduling queue;
[0165] A sorting order is determined according to each of the sorting timestamps, and the order of each of the to-be-processed tasks in the task scheduling queue is adjusted according to the sorting order, and the sorting order is consistent with the preset dequeueing order.
[0166] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0167] Obtaining task data corresponding to at least one to-be-processed task from the task scheduling queue according to a preset dequeueing order corresponding to the task scheduling queue, wherein the preset dequeueing order is related to the planned processing time and scheduling priority corresponding to each of the to-be-processed tasks;
[0168] For each of the tasks to be processed, obtaining a first processing version identifier corresponding to the task to be processed;
[0169] The to-be-processed task is processed according to the task data and the first processing version identifier.
[0170] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0171] Determining whether the pending task needs to be processed currently according to the planned processing time included in the task data;
[0172] If the pending task needs to be processed, the pending task is processed according to the second processing version identifier and the first processing version identifier included in the task data.
[0173] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0174] If the first processing version identifier is consistent with the second processing version identifier, the pending task is dequeued, and the pending task is processed after being dequeued.
[0175] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0176] If the processing result of the task to be processed is successful, the first processing version identifier is updated.
[0177] If the execution result is execution failure, the first processing version identifier is updated, and the to-be-processed task is rewritten into the task scheduling queue.
[0178] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0179] Acquire the task data corresponding to the task to be processed, and generate scheduling information corresponding to the task to be processed according to the task data, wherein the scheduling information includes the first processing version identifier;
[0180] The task data and the pending tasks are written into the task scheduling queue according to the task data, and the scheduling list information is written into the target storage space.
[0181] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0182] Writing the pending task and the task data into the task scheduling queue;
[0183] Obtaining the sorting timestamp corresponding to each pending task in the task scheduling queue;
[0184] A sorting order is determined according to each of the sorting timestamps, and the order of each of the to-be-processed tasks in the task scheduling queue is adjusted according to the sorting order, and the sorting order is consistent with the preset dequeueing order.
[0185] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0186] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0187] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0188] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A task processing method, characterized in that: The method comprises: Obtaining task data corresponding to at least one to-be-processed task from the task scheduling queue according to a preset dequeueing order corresponding to the task scheduling queue, wherein the preset dequeueing order is related to the planned processing time and scheduling priority corresponding to each of the to-be-processed tasks; For each of the tasks to be processed, obtaining a first processing version identifier corresponding to the task to be processed; The to-be-processed task is processed according to the task data and the first processing version identifier.
2. The method according to claim 1, characterized in that The processing of the to-be-processed task according to the task data and the first processing version identifier includes: Determining whether the pending task needs to be processed currently according to the planned processing time included in the task data; If the pending task needs to be processed, the pending task is processed according to the second processing version identifier and the first processing version identifier included in the task data.
3. The method according to claim 2, characterized in that The processing of the to-be-processed task according to the second processing version identifier and the first processing version identifier included in the task data includes: If the first processing version identifier is consistent with the second processing version identifier, the pending task is dequeued, and the pending task is processed after being dequeued.
4. The method according to claim 2, characterized in that: The method further comprises: If the processing result of the task to be processed is successful, updating the first processing version identifier; If the execution result is execution failure, the first processing version identifier is updated, and the to-be-processed task is rewritten into the task scheduling queue.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Acquire the task data corresponding to the task to be processed, and generate scheduling information corresponding to the task to be processed according to the task data, wherein the scheduling information includes the first processing version identifier; The task data and the pending tasks are written into the task scheduling queue according to the task data, and the scheduling list information is written into the target storage space.
6. The method according to claim 5, characterized in that Writing the task data and the to-be-processed task into the task scheduling queue according to the task data includes: Writing the pending task and the task data into the task scheduling queue; Obtaining the sorting timestamp corresponding to each pending task in the task scheduling queue; A sorting order is determined according to each of the sorting timestamps, and the order of each of the to-be-processed tasks in the task scheduling queue is adjusted according to the sorting order, and the sorting order is consistent with the preset dequeueing order.
7. A task processing device, characterized in that: The device comprises: A first acquisition module is used to acquire task data corresponding to at least one pending task from the task scheduling queue according to a preset dequeueing order corresponding to the task scheduling queue, wherein the preset dequeueing order is related to a planned processing time and a scheduling priority corresponding to each pending task; A second acquisition module is used to acquire, for each of the tasks to be processed, a first processing version identifier corresponding to the task to be processed; A processing module is used to process the to-be-processed task according to the task data and the first processing version identifier.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.