Task processing method, apparatus, device, and computer-readable storage medium
Patent Information
- Application Number
- CN202311040529.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-17
- Publication Date
- 2026-09-29
- Estimated Expiration
- 2043-08-17
AI Technical Summary
[0003]本申请的主要目的在于提供一种任务处理方法、装置、设备及计算机可读存储介质,旨在解决如何提高处理任务的执行成功率的技术问题
[0014]本申请中多任务通道系统接收任务处理指令时,确定各所述创建日期中是否存在与所述当前处理日期匹配的第一目标创建日期,确定所述第一目标创建日期对应的目标任务通道,从所述目标任务通道中取出待处理的多个处理任务,并执行各所述处理任务,并将执行失败的第一处理任务,将所述第一处理任务放入到所述目标任务通道内,以使能够从所述目标任务通道内再次取出执行失败的所述第一处理任务并执行。如此,可以避免现有技术中系统因为网络波动、服务器宕机、系统不稳定等原因而导致处理任务执行失败,而导致处理任务执行成功率低的现象发生,本申请实施例中,通过设置多个任务通道,并将执行失败的处理任务再次放入到任务通道中,使得能够对执行失败的处理任务再次执行直至执行成功,从而提高了处理任务的执行成功率。
Smart Images

Figure CN117112166B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a task processing method, apparatus, device, and computer-readable storage medium. Background Technology
[0002] As the business grows, the system typically handles a large number of processing tasks, such as data synchronization, data acquisition, data output, and data analysis. However, when the system executes these tasks, it is easily affected by network fluctuations, server crashes, system instability, and other factors, resulting in task execution failures and a low success rate. Summary of the Invention
[0003] The main objective of this application is to provide a task processing method, apparatus, device, and computer-readable storage medium, which aims to solve the technical problem of how to improve the success rate of task processing.
[0004] To achieve the above objectives, this application provides a task processing method applied to a multi-task channel system. The multi-task channel system includes multiple task channels, each task channel having a creation date. Different task channels have different creation dates. The task processing method includes the following steps: Upon receiving a task processing instruction, retrieve the current processing date from the preset storage area; Determine the first target creation date that matches the current processing date from among the creation dates, and determine the target task channel corresponding to the first target creation date; Take out multiple processing tasks to be processed from the target task channel, execute each processing task, and check whether each processing task is executed successfully; If there is a first processing task that fails to execute among the processing tasks, the first processing task is placed into the target task channel so that the multi-task channel system can retrieve the first processing task that failed to execute from the target task channel and execute it again.
[0005] Optionally, before the step of determining a first target creation date that matches the current processing date among the creation dates, the method further includes: Determine the current date included in the task processing instruction, and detect whether there is a second target creation date that matches the current date among the creation dates; If a second target creation date exists, then the step of determining a first target creation date that matches the current processing date among the creation dates is performed; If the second target creation date does not exist, create a new task channel, set the current date as the creation date of the new task channel, and create a pending queue, a queue of non-excessive delay error counts, and a queue of excessive delay error counts within the new task channel after setting the creation date.
[0006] Optionally, after the step of creating a pending queue, a queue for delaying non-excessive error counts, and a queue for exceeding error counts within the new task channel after setting the creation date, the method further includes: Retrieve preprocessing tasks from a pre-defined database and detect the number of preprocessing tasks retrieved. If the number of tasks is zero, subtract one from the current date to get the new current processing date, store the new current processing date in the preset storage area, and return to the step of retrieving the current processing date from the preset storage area when the task processing instruction is received; If the number of tasks is greater than zero, the obtained preprocessed tasks are added to the pending queue of the new task channel as pending processing tasks, the current date is used as the new current processing date, the new current processing date is stored in the preset storage area, and the process returns to the step of obtaining the current processing date from the preset storage area when the task processing instruction is received.
[0007] Optionally, the step of retrieving multiple processing tasks to be processed from the target task channel includes: The target task includes a target queue to be processed, multiple processing tasks to be processed are taken out from the target queue to be processed, and it is detected whether the processing tasks are successfully obtained. If the processing task fails to be obtained, check whether the current processing date is consistent with the current date. If the current processing date is inconsistent with the current date, the current processing date is adjusted in a preset manner. The preset manner includes subtracting one from the current processing date, storing the adjusted current processing date in a preset storage area, and returning to the step of retrieving the current processing date from the preset storage area when the task processing instruction is received.
[0008] Optionally, the step of placing the first processing task into the target task channel includes: Obtain the first failure count of the first processing task, and increment the first failure count by one to obtain the updated first failure count; If the updated first failure count is greater than the preset maximum error count, determine the target excessive error count queue included in the target task channel; The first processing task is added to the target error count queue so that the processing tasks in the target error count queue are processed after all the pending processing tasks in the target pending processing queue have been processed.
[0009] Optionally, after the step of adding one to the first failure count to obtain the updated first failure count, the method further includes: If the updated first failure count is less than or equal to the preset maximum error count, the target task channel is determined to include a target delay non-excess error count queue. Obtain the current earliest execution time of the first processing task, and adjust the current earliest execution time by the first number of failures to obtain the adjusted current earliest execution time; Set the adjusted current earliest execution time as the earliest execution time of the first processing task, and add the first processing task with the set earliest execution time to the target delay non-exceeding error count queue.
[0010] Optionally, after the step of adding the first processing task after setting the earliest execution time to the target delay non-exceedance error count queue, the method further includes: Obtain the current time and the earliest execution time of each processing task in the queue of non-exceeding error counts for the target delay; Determine the first earliest execution time that is greater than or equal to the current time among the earliest execution times, determine the second processing task corresponding to the first earliest execution time, and add the second processing task to the target pending processing queue for processing.
[0011] Furthermore, to achieve the above objectives, this application also provides a task processing apparatus, which includes a multi-task channel system. The multi-task channel system includes multiple task channels, each task channel having a creation date. Different task channels have different creation dates. The task processing apparatus further includes: The receiving module is used to retrieve the current processing date from the preset storage area when it receives a task processing instruction; The determination module is used to determine the target task channel corresponding to the first target creation date that matches the current processing date among the creation dates. An execution module is used to retrieve multiple processing tasks to be processed from the target task channel, execute each processing task, and detect whether each processing task has been executed successfully. The module is used to place the first processing task into the target task channel if there is a first processing task that has failed to execute among the processing tasks, so that the multi-task channel system can retrieve the first processing task that failed to execute from the target task channel and execute it again.
[0012] In addition, to achieve the above objectives, this application also provides a task processing device, including: a memory, a processor, and a task processing program stored in the memory and executable on the processor, wherein the task processing program, when executed by the processor, implements the steps of the task processing method as described above.
[0013] In addition, to achieve the above objectives, this application also provides a computer-readable storage medium storing a task processing program, which, when executed by a processor, implements the steps of the task processing method described above.
[0014] In this application, when the multi-task channel system receives a task processing instruction, it determines whether a first target creation date matching the current processing date exists among the creation dates, determines the target task channel corresponding to the first target creation date, retrieves multiple processing tasks to be processed from the target task channel, executes each processing task, and places the first processing task that failed in execution into the target task channel, so that the first processing task that failed in execution can be retrieved from the target task channel again and executed. This avoids the low success rate of task processing due to network fluctuations, server downtime, system instability, etc., which are common in existing systems. In this embodiment, by setting up multiple task channels and placing failed processing tasks back into the task channels, the failed processing tasks can be executed again until successful, thereby improving the success rate of task processing. Attached Figure Description
[0015] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings.
[0016] Figure 1 This is a schematic diagram of the task processing device structure of the hardware operating environment involved in the embodiments of this application; Figure 2 This is a flowchart illustrating the first embodiment of the task processing method of this application; Figure 3 This is a schematic diagram of a single task channel in the task processing method of this application; Figure 4 This is an illustrative diagram illustrating the task processing method of this application, which involves executing processing tasks based on a task channel. Figure 5 This is another flowchart illustrating the task processing method of this application; Figure 6 This is a schematic diagram of the device module of the task processing apparatus of this application. Detailed Implementation
[0017] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0018] Reference Figure 1 , Figure 1 This is a schematic diagram of the task processing device structure of the hardware operating environment involved in the embodiments of this application.
[0019] like Figure 1 As shown, the task processing device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed random access memory (RAM) or a stable non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.
[0020] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the task processing device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0021] like Figure 1 As shown, the memory 1005, which is a computer-readable storage medium, may include an operating device, a data storage module, a network communication module, a user interface module, and a task processing program.
[0022] exist Figure 1In the task processing device shown, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the task processing device of this application can be set in the task processing device, and the task processing device calls the task processing program stored in the memory 1005 through the processor 1001 and executes the task processing method provided in the embodiment of this application.
[0023] Reference Figure 2 This application provides a task processing method. In a first embodiment of the task processing method, the task processing method is applied to a multi-task channel system, which includes multiple task channels. Each task channel is assigned a creation date, and different task channels have different creation dates. The task processing method includes the following steps: Step S10: Upon receiving a task processing instruction, retrieve the current processing date from the preset storage area; This embodiment provides a multi-task channel system that can be used to acquire data between multiple systems, including but not limited to e-commerce systems, portal systems, cloud service systems, etc. The multi-task channel system includes multiple channels, and each channel is assigned a creation date, which uniquely identifies a channel. The creation date can be any date. Furthermore, each channel also includes a pending queue, an excessive error count queue, and a delayed non-excess error count queue.
[0024] The queue to be processed stores processing tasks. Data can be stored at both ends of the queue. The processing tasks can come from the preset business database (i.e., the preset database) and other queues in the same channel. The execution layer of the multi-task channel system can retrieve data from the tail of this queue.
[0025] The excess error queue is used when a processing task fails and the number of failures exceeds the preset maximum number of errors (or maximum failure count). When the daily task processing of the task channel is completed, the processing task in this queue will be taken out and placed into the pending queue of the same task channel. Optionally, it can be placed from the head of the pending queue.
[0026] The delayed non-excessive error count queue is used when a processing task fails, and the number of failures is less than or equal to the preset maximum error count. When a processing task in the delayed non-excessive error count queue reaches its earliest execution time, it is moved from the tail of the waiting queue in the same channel. The earliest execution time can be calculated based on a preset formula: n = a + (f - 1). m, where f is the number of times the task failed, a is the current time, such as the current time when the task is placed in the queue of non-excessive delay errors, and m is a preset influence factor, such as 5, 6, 7, 8, etc.
[0027] Creation conditions for creating new task channels can be preset. When these conditions are met, a new task channel is created. Optionally, the preset creation condition could be that a new task channel is created when a date update is detected, and the new task channel is initialized. Channel initialization may include creating a pending queue, an excessive error count queue, and a delayed non-excess error count queue within the channel, and setting a channel identifier to uniquely identify the new task channel. Optionally, the channel identifier can be the creation date, which can be the date the task channel was created. For example, taking a task channel as an example, refer to... Figure 3 The channel identifier for a task channel is its creation date, which is the date the task channel was created. For example, if the task channel was created on February 8th, then its creation date is February 8th. The task channel contains a queue for excessive error counts and a queue for non-excessive delay error counts. Therefore, synchronous business processes are stored within the task channel as processing tasks. The task channel is divided into three queues, forming a new channel each day. This better controls large-scale data acquisition processes and ensures that processing tasks are performed in batches and at different times.
[0028] The multi-channel task system is equipped with a processing date recording unit to record the current processing date in a preset storage area. When the multi-channel task system receives a task processing instruction, it retrieves the current processing date from the preset storage area. The current processing date records the creation date of the task channel currently being processed by the multi-channel task system. This date can be flexibly changed; it can be continuously adjusted backward during task processing, and can also be adjusted to the latest date in the early morning to synchronize new data in a timely manner. During idle time, previous data can be synchronized backward. For example, assuming the current processing date is February 5th, it means that the system is currently processing a task in a task channel created on February 5th. It should be noted that when adjusting the current processing date forward, it can further determine whether the current processing date is more than a preset number of days away from the current date. If it is more than the preset number of days away, no processing will be performed. For example, assuming the current processing date is February 1st, the current date is February 7th, and the preset number of days is 5 days, in this case, the current processing date is more than the preset number of days away from the current date, so the task channel with the creation date of February 1st will not be processed. Optionally, task channels created on or before February 1st can also be deleted to free up memory and reduce resource consumption.
[0029] Step S20: Determine the first target creation date that matches the current processing date among the creation dates, and determine the target task channel corresponding to the first target creation date; The system checks whether the creation date of each channel in the multi-channel task system matches the current processing date. If there is one creation date that matches the current processing date, then this creation date is the first target creation date that matches the current processing date.
[0030] In one embodiment, prior to the step of determining a first target creation date among the creation dates that matches the current processing date, the method further includes: Step S201: Determine the current date included in the task processing instruction, and detect whether there is a second target creation date that matches the current date among the creation dates; The current date included in the task processing instruction can be parsed. It's worth noting that the multi-channel task system can also periodically send task processing instructions to itself. For example, the multi-channel task system can send task processing instructions to itself during idle periods. Optionally, a field in the task processing instruction can be designated as the current date field. The current date can be parsed from this field. If this field is empty, it means the task processing instruction does not contain a date. In this case, the date of receipt of the task processing instruction can be used as the current date. For example, assuming the multi-channel system receives a task processing instruction and the current date field in the instruction is empty, and the date of receipt is February 7th, then the current date is February 7th. Alternatively, upon receiving a task processing instruction, the date of receipt can be directly obtained as the current date without needing to parse the current date from the instruction.
[0031] Step S202: If the second target creation date exists, then the step of determining the first target creation date that matches the current processing date among the creation dates is executed; For example, suppose the current processing date is February 6th, and the current date is February 7th. In one scenario, assuming there are 6 task channels in the multi-channel task system, and the creation dates of each task channel are [February 7th, February 6th, February 5th, February 4th, February 3rd, and February 2nd], then there exists a second target creation date that matches the current date, namely February 7th. In this case, the first target creation date that matches the current processing date among all creation dates is February 6th, and the channel corresponding to February 6th is taken as the target task channel. Suppose in another scenario, there are 5 task channels in the multi-channel task system, and the creation dates of each task channel are [February 6th, February 5th, February 4th, February 3rd, and February 2nd], then there is no second target creation date that matches the current date. In this case, step S203 is executed.
[0032] Step S203: If the second target creation date does not exist, create a new task channel, set the current date as the creation date of the new task channel, and create a pending queue, a delay non-excess error count queue, and an excess error count queue in the new task channel after setting the creation date.
[0033] If no second target creation date matches the current date, a new task channel can be created, and the creation date of the new task channel can be set to the current date. Preprocessing tasks can be retrieved from the preset database and added to the pending queue of the new task channel. The current processing date in the preset storage area is updated to the current date, and the process returns to step S10.
[0034] For example, assuming the current date is February 7th, in one scenario, a multi-channel task system has 6 task channels, and the creation dates of each task channel are [February 7th, February 6th, February 5th, February 4th, February 3rd, and February 2nd]. Then, the second target creation date is February 7th. In another scenario, assuming the multi-channel task system has 5 task channels, and the creation dates of each task channel are [February 6th, February 5th, February 4th, February 3rd, and February 2nd], there is no second target creation date matching the current date. Therefore, a new task channel can be created, and its creation date can be set to February 7th. Within this new task channel, a pending processing queue, a queue for non-excessive delay errors, and a queue for excessive delay errors can be created. Pre-processing tasks are retrieved from a pre-defined database and added to the pending processing queue of the new task channel created on February 7th. The current processing date is then updated to February 7th.
[0035] Understandably, if both the first and second target creation dates exist, it means the task channel for the current date has already been processed. Following the rollback mechanism of the current processing date, the target task channel corresponding to the first target's creation date should be processed. However, if the first target's creation date exists but the second target's creation date does not, it means the task channel for the current date has not been processed. In this case, a new task channel with the current date should be created and processed. This ensures that the multi-channel task system prioritizes processing the task channel with the latest date. After processing the task channel with the latest date, it rolls back to the current processing date and processes the previous task channels, resulting in high-quality task processing. It should be noted that processing a task channel means processing the tasks within that task channel.
[0036] In one embodiment, after step S203, the method further includes: Step S204: Obtain preprocessing tasks from a preset database and detect the number of preprocessing tasks obtained. Step S205: If the number of tasks is zero, subtract one from the current date to get the new current processing date, store the new current processing date in the preset storage area, and return to the step of obtaining the current processing date from the preset storage area when the task processing instruction is received.
[0037] Other systems can place the preprocessing tasks to be processed into a preset database. The multi-task channel system retrieves the preprocessing tasks from the preset database. If the number of preprocessing tasks retrieved is zero, it means that there are no processing tasks to be processed on the current date. In this case, the current processing date is rolled back from the current date, that is, the day before the current date is taken as the new current processing date, and the system returns to step S10. Furthermore, the system can roll back the current processing date from the current date when the number of preprocessing tasks retrieved from the preset database is zero for a preset number of consecutive times. In other words, the day before the current date is taken as the new current processing date, and the system returns to step S10. During the rollback, the multi-channel task system can be triggered to send a task processing instruction to process the task itself, or it can wait for other systems to trigger a task processing instruction. Alternatively, if the multi-channel task system triggers task processing instructions periodically, it can wait for the task processing instruction of the next cycle to arrive. This embodiment does not limit the triggering method of the task processing instruction.
[0038] Step S206: If the number of tasks is greater than zero, the obtained preprocessing tasks are added to the pending processing queue of the new task channel as pending processing tasks, the current date is used as the new current processing date, the new current processing date is stored in the preset storage area, and the process returns to the step of obtaining the current processing date from the preset storage area when the task processing instruction is received.
[0039] If the number of tasks is greater than zero, it means that there are processing tasks that need to be processed on the current date. The obtained preprocessing tasks are added to the waiting queue of the new task channel as processing tasks to be processed. A preset number of preprocessing tasks can be obtained at one time, such as 1000 preprocessing tasks. The current date is used as the new current processing date. The new current processing date is stored in the preset storage area, and the process returns to step S10.
[0040] Step S30: Take out multiple processing tasks to be processed from the target task channel, execute each processing task, and detect whether each processing task has been executed successfully. Retrieving multiple processing tasks from the target task channel can be understood as setting the number of tasks retrieved at once, i.e., a preset number of processing tasks can be retrieved from the target task channel. For example, assuming the preset number of tasks is 100, then 100 processing tasks can be retrieved from the target task channel. Furthermore, multiple processing tasks can be retrieved from a queue within the target task channel, i.e., a preset number of processing tasks can be retrieved from the queue within the target task channel.
[0041] After successfully retrieving a processing task from the target task channel (i.e., the number of processing tasks retrieved from the target task channel is not zero), each processing task can be executed, and execution feedback from each processing task can be received to detect whether each processing task has been executed successfully. If the execution feedback of a certain processing task is successful, this processing task can be deleted to release memory and reduce resource consumption. If the execution feedback of a certain task is unsuccessful, the unsuccessful task is returned to the target task channel, that is, the task bodies of all successfully executed second processing tasks in each processing task are deleted, and all unsuccessful first processing tasks in each processing task are returned to the target task channel.
[0042] Additionally, if the number of pending processing tasks retrieved from the pending queue of the target task channel is zero, it can be determined whether the current processing date is consistent with the current date. If they are consistent, another preset number of preprocessing tasks to be processed are retrieved from the preset business database and placed into the target task channel. Further, these tasks are placed into the pending queue of the target task channel, where the other preset number can be 1000 or 2000. It is also determined whether the number of processing tasks generated in the target task channel is greater than zero. If it is greater than zero, the process returns to step S10 and waits for the next task processing instruction to be received before processing the processing tasks in the target task channel. Alternatively, step S30 can be executed again to retrieve processing tasks from the target channel for processing. If the number is equal to zero, the current processing date is updated, such as by subtracting one day from the current processing date, i.e., the day before the current processing date, and the process returns to step S10.
[0043] Step S40: If there is a first processing task that has failed to execute among the processing tasks, the first processing task is placed into the target task channel so that the first processing task that failed to execute can be retrieved from the target task channel and executed again.
[0044] If any of the processing tasks fails, the first processing task is placed into the target task channel. Further, if multiple first processing tasks fail, the failure count of each first processing task is incremented by one. Each first processing task is iterated sequentially. If the failure count of the iterated first processing task is greater than a preset maximum error count, the iterated first processing task is placed into the excess error count queue of the target task channel. If the failure count of the iterated first processing task is less than or equal to the preset maximum error count, the iterated first processing task is placed into the delay non-excess error count queue of the target task channel. After iterating through all first processing tasks, all failed first processing tasks are placed into the corresponding queues of the target task channel. Understandably, for the processing tasks placed into the delay non-excess error count queue of the target task channel, the earliest execution time of each first processing task is further updated based on the aforementioned preset formula.
[0045] Now, let's explain in detail with reference to specific scenarios, for example, refer to Figure 4Assuming the current processing date is February 7th, and the multi-channel task system has 6 task channels, each created on February 7th, February 6th, February 5th, February 4th, February 3rd, and February 2nd respectively, then the creation dates of the first and second targets are both February 7th. The target task channel is the one created on February 7th. Channels created before February 7th are historical channels, such as channels created on February 6th and February 5th. Each channel includes a pending queue, an excessive error count queue, and a delayed non-excess error count queue. The preset business database (i.e., the preset database) packages business requests into processing tasks and places them at the end of the pending queue of the target task channel on February 7th. The multi-channel task system then processes the pending requests from the target task channel on February 7th. The processing task is retrieved from the head of the queue and executed. For the second processing task, which reports successful execution (i.e., normal feedback), the task body of the second processing task is deleted. For the first processing task, which reports failure, the failure count of the first processing task is incremented by one, and it is determined whether the failure count of the first processing task exceeds the preset maximum number of errors (or maximum failure count). If it exceeds the preset maximum number of errors, the first processing task is placed in the excess error count queue of the target task channel. If the failure count of the first processing task does not exceed the preset maximum number of errors, the first processing task is placed in the delay non-excess error count queue of the target task channel. It should be noted that if there are multiple first processing tasks, each processing task needs to be processed separately, the failure count of each first processing task is incremented by one, and it is determined whether to add it to the excess error count queue or the non-excess error count queue.
[0046] In addition, to aid in understanding the task processing method flow in this embodiment, examples are provided below.
[0047] Reference Figure 5When the multi-task channel system receives a task processing instruction, it determines whether there exists a second target creation date that matches the current date among the creation dates (i.e., K dates) of each task channel within the multi-task channel system. If no second target creation date matches the current date, a new task channel can be created, and a pending processing queue, an excessive error count queue, and a delayed non-excess error count queue can be created within the new task channel. The current date is set as the creation date of the new task channel, and the current processing date of the multi-task channel system is changed to the current date. If a second target creation date exists, the task channel whose creation date matches the current processing date is selected as the target task channel. It then determines whether the current processing date within the task channel is more than a preset number of days away from the current date. If the current date is more than a preset number of days away, the process ends and returns to the beginning. If the current processing date in the task channel is less than a preset number of days away, a preset number of pending processing tasks are retrieved from the target task channel. For example, if 100 pending processing tasks are retrieved from the target task channel, it is checked whether the number of retrieved processing tasks is greater than 0. If the number of retrieved processing tasks is greater than 0, the processing tasks are executed, such as calling other coordination interfaces to obtain data and checking the execution results. If the execution is successful, the successfully executed processing tasks are deleted, and the data obtained during the execution of the processing tasks is saved to the database. If the execution fails, the failure count of the failed processing tasks is incremented by 1, and its earliest execution time is updated according to a preset formula, where the earliest execution time is updated to n, n = a + (f - 1). m = Current time + (Number of failures - 1) Let m be 5, then n = current time + (number of failures - 1). 5. If the number of processing tasks obtained is 0, check if the current processing date matches the current date. If the current processing date matches the current date, retrieve another preset number of processing tasks to be processed from the database and place them into the target task channel. For example, retrieve the first 1000 generated processing tasks from the database and place them into the target task channel. Check the number of generated processing tasks. If it is greater than 0, the process ends. If it is equal to 0, the failure count of processing tasks within the current processing date is reset to zero, and the current processing date is rolled back one day. If the current processing date does not match the current date, the failure count of processing tasks within the current processing date is reset to zero, and the current processing date is rolled back one day.
[0048] In this embodiment, when the multi-task channel system receives a task processing instruction, it determines whether there exists a first target creation date among the creation dates that matches the current processing date. It then determines the target task channel corresponding to the first target creation date, retrieves multiple processing tasks to be processed from the target task channel, executes each processing task, and places the first processing task that failed into the target task channel, so that it can be retrieved and executed again. This avoids the low success rate of task processing due to network fluctuations, server downtime, system instability, etc., common in existing technologies. In this embodiment, by setting up multiple task channels and re-placing failed processing tasks into them, the system can re-execute failed processing tasks until successful, thereby improving the success rate of task processing.
[0049] Furthermore, based on the first embodiment of this application described above, a second embodiment of the task processing method of this application is proposed. In this embodiment, the refinement of step S30 of the above embodiment, which involves retrieving multiple processing tasks to be processed from the target task channel, executing each processing task, and detecting whether each processing task has been successfully executed, includes: Step a: Determine the target queue to be processed included in the target task, retrieve multiple processing tasks to be processed from the target queue to be processed, and check whether the processing tasks have been successfully obtained. Step b: If the processing task fails to be obtained, check whether the current processing date is consistent with the current date; In this embodiment, each task channel of the multi-channel task system is equipped with a pending processing queue, an excessive error count queue, and a delay non-excess error count queue. Multiple processing tasks are retrieved from the target pending processing queue included in the target task channel, and it is checked whether the processing tasks have been successfully obtained. If the number of retrieved processing tasks is zero, the acquisition of processing tasks fails. It is then checked whether the current processing date is consistent with the current date. If they are consistent, preprocessing tasks are retrieved from a preset database, and the number of retrieved preprocessing tasks is determined. If the number of retrieved preprocessing tasks is zero, the current processing date is reduced by one to become the new current date, which is stored in a preset storage area, and the process returns to step S10. If the number of retrieved preprocessing tasks is greater than zero, the process directly returns to step S10.
[0050] Step c: If the current processing date is inconsistent with the current date, adjust the current processing date in a preset manner. The preset manner includes subtracting one from the current processing date, storing the adjusted current processing date in a preset storage area, and returning to the step of retrieving the current processing date from the preset storage area when the task processing instruction is received.
[0051] If the current processing date is inconsistent with the current date, the current processing date is adjusted in a preset manner. This preset manner includes subtracting one from the current processing date, storing the adjusted current processing date in a preset storage area, and returning to step S10. Thus, the multi-channel task system can utilize spare time to roll back the processing date, processing historical task channels and previously failed tasks. The system can initiate tasks day after day for several consecutive days to ensure synchronization quality while guaranteeing the timeliness of newly generated processing tasks.
[0052] In one embodiment, the step of placing the first processing task into the target task channel includes: Step d: Obtain the first failure count of the first processing task, and increment the first failure count by one to obtain the updated first failure count; Step e: If the updated first failure count is greater than the preset maximum error count, determine the target excess error count queue included in the target task channel; Step f: Add the first processing task to the target error count queue so that after all processing tasks in the target processing queue have been processed, the processing tasks in the target error count queue are processed.
[0053] In this embodiment, the preset maximum number of errors can be arbitrarily set by the user in advance, such as 5, 6, or 7 times. The first processing task with a cumulative failure count exceeding the preset maximum number of errors is added to the target excess error count queue. Furthermore, after the processing tasks in the target task channel for the day are completed, the processing tasks in the target excess error count queue can be moved to the target pending processing queue. For example, assuming the target task channel is a task channel created on February 8th, and the current date is February 8th, then on February 9th, the processing tasks in the excess error count queue of the February 8th task channel will be retrieved and moved to the pending processing queue of the February 8th task channel. With the rollback mechanism of the current processing date, when the current processing date rolls back to February 8th, the processing tasks placed in the pending processing queue can be retrieved and executed, i.e., the processing tasks are processed. In this embodiment, the current processing date and processing tasks are linked. As the processing tasks in the task channel for the day are completed, the current processing date continuously advances towards historical time, completing previously failed processing tasks day by day. The task channel's processing of processing tasks is clear and flexible.
[0054] In one embodiment, after the step of incrementing the first failure count by one to obtain the updated first failure count, the method further includes: Step g: If the updated first failure count is less than or equal to the preset maximum error count, determine the target delay non-excess error count queue included in the target task channel; Step h: Obtain the current earliest execution time of the first processing task, and adjust the current earliest execution time by the first number of failures to obtain the adjusted current earliest execution time; Step i: Set the adjusted current earliest execution time as the earliest execution time of the first processing task, and add the first processing task with the set earliest execution time to the target delay non-exceeding error count queue.
[0055] In this embodiment, each task in the delay-free error count queue of each task channel can be set with an earliest execution time. If the current time reaches the earliest execution time of a task in the delay-free error count queue, this task that has reached its earliest execution time will be removed from the delay-free error count queue and placed into the pending queue of the same task channel. The adjustment method obtained by adjusting the current earliest execution time based on the first failure count can be based on a preset formula, where the preset formula can be the earliest execution time n = a + (f - 1). m and f represent the number of failed processing tasks, a represents the current time (e.g., the current time when the processing task is placed in the delayed non-excessive error count queue), and m represents a preset impact factor (e.g., 5, 6, 7, 8, etc.). Processing tasks are extracted from the business database and their processing is controlled by the multi-task channel system. Each task has an earliest execution time and a specified number of errors, allowing for better coordination with initiation and resending mechanisms, resulting in high flexibility in task processing. By setting a maximum number of errors, an earliest execution time, and a next-day processing method, large amounts of data are first transmitted. Tasks that temporarily fail are placed in the delayed non-excessive error count queue for delayed processing. Tasks that cannot be processed on the same day can be rolled back to the next day or processed the day after that, utilizing spare time to complete previously failed tasks. The multi-task channel system can initiate tasks day after day, ensuring processing quality while guaranteeing the timeliness of newly generated tasks.
[0056] In one embodiment, after the step of adding the first processing task with the earliest execution time set to the target delay non-exceeding error count queue, the method further includes: Step j: Obtain the earliest execution time of each processing task in the queue of non-exceeding error counts for the target delay, based on the current time. Step k: Determine the first earliest execution time that is greater than or equal to the current time among the earliest execution times, determine the second processing task corresponding to the first earliest execution time, and add the second processing task to the target waiting queue for processing.
[0057] In this embodiment, once any processing task in the target delay non-exceeding error count queue of the target task channel reaches its earliest execution time, the second processing task reaching its earliest execution time is added to the target pending processing list. In this embodiment, data synchronization, data acquisition, data output, and other business processes are packaged as processing tasks and stored within the channel. Each channel is divided into three queues, forming a new channel each day. This ensures better control over the batching and time-sharing of a large number of processing tasks, improving the success rate of each processing task's execution.
[0058] Furthermore, this application also provides a task processing device, which includes a multi-task channel system. The multi-task channel system includes multiple task channels, each of which is assigned a creation date. Different task channels have different creation dates. (Refer to...) Figure 6 The task processing device further includes: The receiving module A10 is used to retrieve the current processing date from the preset storage area when it receives a task processing instruction; Module A20 is used to determine the first target creation date that matches the current processing date among the creation dates, and to determine the target task channel corresponding to the first target creation date. The execution module A30 is used to retrieve multiple processing tasks to be processed from the target task channel, execute each processing task, and detect whether each processing task has been executed successfully. The module A40 is used to place the first processing task into the target task channel if there is a first processing task that has failed to execute among the processing tasks, so that the multi-task channel system can retrieve the first processing task that failed to execute from the target task channel and execute it again.
[0059] Furthermore, this application also proposes a task processing device, which includes a memory, a processor, and a task processing program stored in the memory and executable on the processor. When the task processing program is executed by the processor, it implements the steps of the task processing method described above.
[0060] The specific implementation of the task processing device in this application is basically the same as the various embodiments of the task processing method described above, and will not be repeated here.
[0061] In addition, to achieve the above objectives, this application also provides a computer-readable storage medium storing a task processing program, which, when executed by a processor, implements the steps of the task processing method described above.
[0062] The specific implementation of the computer-readable storage medium in this application is basically the same as the embodiments of the task processing method described above, and will not be repeated here.
[0063] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0064] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0065] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a computer-readable storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, cloud server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0066] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A task processing method, characterized in that, The task processing method is applied to a multi-task channel system, which includes multiple task channels. Each task channel is assigned a creation date, and different task channels have different creation dates. The task processing method includes the following steps: Upon receiving a task processing instruction, retrieve the current processing date from the preset storage area; Determine the first target creation date that matches the current processing date from among the creation dates, and determine the target task channel corresponding to the first target creation date; Take out multiple processing tasks to be processed from the target task channel, execute each processing task, and check whether each processing task is executed successfully; If there is a first processing task that fails to execute among the processing tasks, the first processing task is placed into the target task channel so that the multi-task channel system can retrieve the first processing task that failed to execute from the target task channel and execute it again. The step of placing the first processing task into the target task channel includes: Obtain the first failure count of the first processing task, and increment the first failure count by one to obtain the updated first failure count; If the updated first failure count is greater than the preset maximum error count, determine the target excessive error count queue included in the target task channel; The first processing task is added to the target excess error count queue so that the processing tasks in the target excess error count queue are processed after all the pending processing tasks in the target pending processing queue have been processed. After the step of adding one to the first failure count to obtain the updated first failure count, the method further includes: If the updated first failure count is less than or equal to the preset maximum error count, the target task channel is determined to include a target delay non-excess error count queue. Obtain the current earliest execution time of the first processing task, and adjust the current earliest execution time by the first number of failures to obtain the adjusted current earliest execution time; Set the adjusted current earliest execution time as the earliest execution time of the first processing task, and add the first processing task with the set earliest execution time to the target delay non-exceeding error count queue.
2. The task processing method as described in claim 1, characterized in that, Before the step of determining the first target creation date that matches the current processing date among the creation dates, the method further includes: Determine the current date included in the task processing instruction, and detect whether there is a second target creation date that matches the current date among the creation dates; If a second target creation date exists, then the step of determining a first target creation date that matches the current processing date among the creation dates is performed; If the second target creation date does not exist, create a new task channel, set the current date as the creation date of the new task channel, and create a pending queue, a queue of non-excessive delay error counts, and a queue of excessive delay error counts within the new task channel after setting the creation date.
3. The task processing method as described in claim 2, characterized in that, After the step of creating a pending queue, a queue for delaying non-excessive error counts, and a queue for exceeding error counts within the new task channel after setting the creation date, the method further includes: Retrieve preprocessing tasks from a pre-defined database and detect the number of preprocessing tasks retrieved. If the number of tasks is zero, subtract one from the current date to get the new current processing date, store the new current processing date in the preset storage area, and return to the step of retrieving the current processing date from the preset storage area when the task processing instruction is received; If the number of tasks is greater than zero, the obtained preprocessed tasks are added to the pending queue of the new task channel as pending processing tasks, the current date is used as the new current processing date, the new current processing date is stored in the preset storage area, and the process returns to the step of obtaining the current processing date from the preset storage area when the task processing instruction is received.
4. The task processing method as described in claim 3, characterized in that, The step of retrieving multiple processing tasks to be processed from the target task channel includes: The target task channel includes the target queue to be processed, multiple processing tasks to be processed are taken out from the target queue to be processed, and it is detected whether the processing tasks are successfully obtained. If the processing task fails to be obtained, check whether the current processing date is consistent with the current date. If the current processing date is inconsistent with the current date, the current processing date is adjusted in a preset manner. The preset manner includes subtracting one from the current processing date, storing the adjusted current processing date in a preset storage area, and returning to the step of retrieving the current processing date from the preset storage area when the task processing instruction is received.
5. The task processing method as described in claim 1, characterized in that, After adding the first processing task with the earliest execution time set to the target delay non-exceeding error count queue, the method further includes: Obtain the current time and the earliest execution time of each processing task in the queue of non-exceeding error counts for the target delay; Determine the first earliest execution time that is greater than or equal to the current time among the earliest execution times, determine the second processing task corresponding to the first earliest execution time, and add the second processing task to the target pending processing queue for processing.
6. A task processing device, characterized in that, The task processing device includes a multi-task channel system, which includes multiple task channels. Each task channel is assigned a creation date, and different task channels have different creation dates. The task processing device also includes: The receiving module is used to retrieve the current processing date from the preset storage area when it receives a task processing instruction; The determination module is used to determine the target task channel corresponding to the first target creation date that matches the current processing date among the creation dates. An execution module is used to retrieve multiple processing tasks to be processed from the target task channel, execute each processing task, and detect whether each processing task has been executed successfully. The module is used to place the first processing task into the target task channel if there is a first processing task that has failed to execute among the processing tasks, so that the multi-task channel system can retrieve the first processing task that failed to execute from the target task channel and execute it again. The module is also used to obtain the first failure count of the first processing task, and increment the first failure count by one to obtain the updated first failure count; if the updated first failure count is greater than the preset maximum number of errors, the target task channel is determined to include a target excess error count queue; the first processing task is added to the target excess error count queue so that after all pending processing tasks in the target pending processing queue are processed, the processing tasks in the target excess error count queue are processed. The delay processing module is used to determine the target delay non-exceeding error count queue included in the target task channel if the updated first failure count is less than or equal to the preset maximum error count; obtain the current earliest execution time of the first processing task, adjust the current earliest execution time with the first failure count to obtain the adjusted current earliest execution time; set the adjusted current earliest execution time as the earliest execution time of the first processing task, and add the first processing task with the set earliest execution time to the target delay non-exceeding error count queue.
7. A task processing device, characterized in that, The task processing device includes: a memory, a processor, and a task processing program stored in the memory and executable on the processor, wherein the task processing program, when executed by the processor, implements the steps of the task processing method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a task processing program, which, when executed by a processor, implements the steps of the task processing method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Multi-Channel Time Slice Groups
CN103197918A
Software and hardware engine device, software and hardware engine setting method, equipment and medium
CN116431307A