Task management method and device and computer program product

The method of dynamically managing scheduled tasks solves the problem in the prior art that scheduled tasks are static and cannot be dynamically modified, thereby achieving flexible configuration and efficient management of scheduled tasks.

CN120653374APending Publication Date: 2025-09-16BOE TECHNOLOGY GROUP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410288761.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-13
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

In the existing technology, the configuration of scheduled tasks is static and cannot be modified dynamically, resulting in the need for recompilation and redeployment when business needs change, making management and maintenance difficult.

Method used

A task management method is provided. By receiving operation instructions for scheduled tasks, the scheduled tasks can be dynamically added, deleted and modified. The task information is stored in a database and loaded into memory to realize the dynamic start and stop of tasks.

Benefits of technology

It realizes flexible management of scheduled tasks and can adjust task configuration at any time according to actual needs without recompiling and deploying, which improves the flexibility and maintenance efficiency of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120653374A_ABST
    Figure CN120653374A_ABST
Patent Text Reader

Abstract

The invention provides a task management method and device and a computer program product, and belongs to the technical field of task scheduling. The task management method comprises the steps that in response to an operation instruction for a timed task, target operation is executed on the timed task, and the target operation comprises at least one of the following items: the timed task is added in a service system; deleting the timed task in the service system; and changing the timed task in the service system. According to the technical scheme, dynamic starting and stopping of the timed task can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of task scheduling, and in particular to a task management method and device, and a computer program product. Background Art

[0002] Scheduled tasks are primarily used in business systems to automatically execute repetitive tasks, such as data backup, log cleanup, and data synchronization, or to periodically execute specific operations based on business needs, such as generating reports, sending emails, and updating data. Scheduled tasks can also be used to execute resource-intensive operations, such as data statistics and index rebuilds, during off-peak hours, minimizing impact on business system performance and saving costs.

[0003] In related technologies, the relevant information of scheduled tasks is statically configured in the code, and scheduled tasks cannot be added or deleted dynamically. Summary of the Invention

[0004] The technical problem to be solved by the present disclosure is to provide a task management method and device, and a computer program product, which can realize the dynamic start and stop of scheduled tasks.

[0005] To solve the above technical problems, the embodiments of the present disclosure provide the following technical solutions:

[0006] In one aspect, a task management method is provided, comprising:

[0007] In response to an operation instruction for a scheduled task, a target operation is performed on the scheduled task, where the target operation includes at least one of the following:

[0008] Add scheduled tasks in the business system;

[0009] Delete scheduled tasks in the business system;

[0010] Modify the scheduled tasks in the business system.

[0011] In some embodiments, adding a scheduled task in the business system includes:

[0012] Storing the task information and execution period of the scheduled task in the database of the business system;

[0013] Call addCronTask to load the scheduled task into the memory of the business system.

[0014] In some embodiments, deleting a scheduled task in the business system includes:

[0015] Modify the execution status of the scheduled task in the database of the business system to be disabled or invalid; or delete the task information and execution cycle of the scheduled task in the database of the business system;

[0016] Call cancelCronTask to delete the scheduled task in the memory of the business system.

[0017] In some embodiments, modifying a scheduled task in a business system includes:

[0018] Modify the execution period of the scheduled task in the database of the business system; or delete the task information and execution period of the scheduled task in the database of the business system, and store the modified task information and execution period of the scheduled task in the database of the business system;

[0019] Call updateTaskInfo to change the execution period of the scheduled task in the memory of the business system.

[0020] In some embodiments, after performing the target operation on the scheduled task, the method further includes:

[0021] When the business system is started, query whether there is a valid scheduled task in the business system;

[0022] If there is a valid scheduled task, call addCronTask to load the valid scheduled task into the memory of the business system;

[0023] The scheduled task is executed regularly according to the execution cycle of the scheduled task.

[0024] In some embodiments, after executing the scheduled task, the method further includes:

[0025] Execute subsequent business tasks based on the execution results of the scheduled task, including any of the following:

[0026] Execute multiple business tasks in sequence according to the preset task order;

[0027] After all predecessor tasks of the business task are executed, executing the business task, wherein the execution of the business task depends on the execution results of the predecessor tasks;

[0028] After any preceding task of the business task is executed, the business task is executed, wherein the execution of the business task depends on the execution result of the preceding task.

[0029] In some embodiments, after executing the scheduled task, the method further includes:

[0030] Execute subsequent business tasks based on the execution results of the scheduled tasks, including:

[0031] Step a: acquiring all post-tasks according to the association condition set of the business task, wherein the execution of the post-task depends on the execution results of other business tasks in the association condition set, and the association condition set includes a plurality of the business tasks having an association relationship;

[0032] Step b: traverse the business tasks in the association condition set;

[0033] Step c: determine whether a business task in the association condition set is included in the post-task; if yes, proceed to step b; if not, proceed to step d;

[0034] Step d: remove the business task from the association relationship condition set, save the business task in the task output list, and go to step e;

[0035] Step e: Determine whether the association relationship condition set is empty. If so, go to step f; if not, go to step a.

[0036] Step f: executing the business tasks in the order of tasks in the task output list.

[0037] The present disclosure also provides a task management device, including:

[0038] The task processor is configured to, in response to an operation instruction for a scheduled task, perform a target operation on the scheduled task, where the target operation includes at least one of the following:

[0039] Add scheduled tasks in the business system;

[0040] Delete scheduled tasks in the business system;

[0041] Modify the scheduled tasks in the business system.

[0042] In some embodiments, the task processor includes:

[0043] The adding unit is used to store the task information and execution cycle of the scheduled task in the database of the business system; and call addCronTask to load the scheduled task into the memory of the business system.

[0044] In some embodiments, the task processor includes:

[0045] The deletion unit is used to modify the execution status of the scheduled task in the database of the business system to disabled or invalid; or, delete the task information and execution cycle of the scheduled task in the database of the business system; call cancelCronTask to delete the scheduled task in the memory of the business system.

[0046] In some embodiments, the task processor includes:

[0047] A changing unit is used to change the execution period of the scheduled task in the database of the business system; or to delete the task information and execution period of the scheduled task in the database of the business system, and store the modified task information and execution period of the scheduled task in the database of the business system; call updateTaskInfo to change the execution period of the scheduled task in the memory of the business system.

[0048] In some embodiments, the apparatus further comprises:

[0049] A query module is used to query whether there is a valid scheduled task in the business system when the business system is started;

[0050] A loading module is used to call addCronTask to load a valid scheduled task into the memory of the business system if there is one;

[0051] The execution module is used to execute the scheduled task regularly according to the execution cycle of the scheduled task.

[0052] In some embodiments, the apparatus further comprises:

[0053] The business task execution module is used to execute subsequent business tasks according to the execution result of the scheduled task, including any of the following:

[0054] Execute multiple business tasks in sequence according to the preset task order;

[0055] After all predecessor tasks of the business task are executed, executing the business task, wherein the execution of the business task depends on the execution results of the predecessor tasks;

[0056] After any preceding task of the business task is executed, the business task is executed, wherein the execution of the business task depends on the execution result of the preceding task.

[0057] In some embodiments, the apparatus further comprises:

[0058] The business task execution module is used to execute subsequent business tasks according to the execution results of the scheduled tasks, including:

[0059] Step a: acquiring all post-tasks according to the association condition set of the business task, wherein the execution of the post-task depends on the execution results of other business tasks in the association condition set, and the association condition set includes a plurality of the business tasks having an association relationship;

[0060] Step b: traverse the business tasks in the association condition set;

[0061] Step c: determine whether a business task in the association condition set is included in the post-task; if yes, proceed to step b; if not, proceed to step d;

[0062] Step d: remove the business task from the association relationship condition set, save the business task in the task output list, and go to step e;

[0063] Step e: Determine whether the association relationship condition set is empty. If so, go to step f; if not, go to step a.

[0064] Step f: executing the business tasks in the order of tasks in the task output list.

[0065] An embodiment of the present disclosure further provides a computer program product, comprising computer instructions, which implement the steps of the above method when executed by a processor.

[0066] The embodiments of the present disclosure have the following beneficial effects:

[0067] In the above solution, after receiving the operation instruction for the scheduled task, the scheduled task can be added, deleted or modified in the business system, thereby realizing the dynamic start and stop of the scheduled task, and further realizing the addition of an efficient and flexible business system. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] Figure 1 and Figure 2 This is a schematic diagram of the structure of the task management device disclosed in the present invention;

[0069] Figure 3 A schematic diagram of adding a scheduled task in an embodiment of the present disclosure;

[0070] Figure 4 A schematic diagram of deleting a scheduled task according to an embodiment of the present disclosure;

[0071] Figure 5 A schematic diagram of changing a scheduled task according to an embodiment of the present disclosure;

[0072] Figure 6 A schematic diagram of the process of executing a scheduled task according to an embodiment of the present disclosure;

[0073] Figure 7-Figure 9 A schematic diagram of the execution logic of a business task according to an embodiment of the present disclosure;

[0074] Figure 10 A schematic diagram of the process of task scheduling according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0075] In order to make the technical problems, technical solutions and advantages to be solved by the embodiments of the present disclosure more clear, they will be described in detail below with reference to the accompanying drawings and specific embodiments.

[0076] In related technologies, the open source job scheduling framework Quartz can be used for scheduled task management, and job scheduling and task management can be implemented in Java applications. However, there are the following problems: 1) Complex configuration: The configuration of Quartz is relatively complex, and you need to be familiar with the framework's configuration files and properties, as well as the related application programming interfaces (APIs) and concepts. 2) It is impossible to flexibly adjust scheduled tasks according to needs. In addition, the execution time of scheduled tasks can also be written into the code, that is, the configuration of scheduled tasks is static and cannot be dynamically modified at runtime. If you need to dynamically adjust the execution time or execution cycle of the scheduled task, you need to restart the application.

[0077] The embodiments of the present disclosure provide a task management method and apparatus, and a computer program product, which can realize dynamic start and stop of scheduled tasks.

[0078] The present disclosure provides a task management method, including:

[0079] In response to an operation instruction for a scheduled task, a target operation is performed on the scheduled task, where the target operation includes at least one of the following:

[0080] Add scheduled tasks in the business system;

[0081] Delete scheduled tasks in the business system;

[0082] Modify the scheduled tasks in the business system.

[0083] In this embodiment, after receiving an operation instruction for a scheduled task, the scheduled task can be added, deleted or modified in the business system, thereby realizing dynamic start and stop of the scheduled task, and further realizing the addition of an efficient and flexible business system.

[0084] In this embodiment, Figure 1 and Figure 2As shown, the task manager can receive operation instructions and add, delete or modify scheduled tasks according to the operation instructions. The task manager can save the task information of the scheduled tasks, update the execution cycle of the scheduled tasks, start the scheduled tasks and stop the scheduled tasks.

[0085] In some embodiments, such as Figure 3 As shown, adding a scheduled task in the business system includes:

[0086] Storing the task information and execution period of the scheduled task in the database of the business system;

[0087] Call addCronTask to load the scheduled task into the memory of the business system.

[0088] Among them, the task information of the scheduled task includes but is not limited to the task name, task content, execution time, etc. of the scheduled task. The task manager can store the task information and execution cycle of the scheduled task in the database of the business system, and store the scheduled task in the memory of the business system, that is, the Map container, so that the specific logic in the scheduled task can be executed regularly according to the set execution cycle. Among them, the role of the Map container is to control the dynamic start and stop of the scheduled task under the running state of the business system and modify the execution cycle of the scheduled task.

[0089] When adding a scheduled task, you can first search the business system database based on the scheduled task name to determine whether the scheduled task name already exists in the database. If the scheduled task name already exists, an error message will be returned. If the scheduled task name does not exist in the database, the scheduled task name, execution time, execution cycle and other information will be stored in the database and loaded into the Map container.

[0090] In related technologies, after statically configuring scheduled tasks, adding scheduled tasks requires code modifications and recompilation, which is inflexible. Static configuration also requires consideration of various exceptions, making management and maintenance difficult. In this embodiment, scheduled tasks can be added flexibly and at any time based on actual needs. Furthermore, added scheduled tasks can take effect immediately during operation, providing real-time performance. The technical solution of this embodiment allows scheduled tasks to be monitored and managed during operation, ensuring their stability and reliability.

[0091] In some embodiments, such as Figure 4 As shown, deleting a scheduled task in the business system includes:

[0092] Modify the execution status of the scheduled task in the database of the business system to be disabled or invalid; or delete the task information and execution cycle of the scheduled task in the database of the business system;

[0093] Call cancelCronTask to delete the scheduled task in the memory of the business system.

[0094] In this embodiment, when deleting a scheduled task, all relevant information of the scheduled task in the database of the business system may be deleted, or only the execution status of the scheduled task in the database may be changed.

[0095] In related technologies, after statically configuring a scheduled task, deleting it requires code modification and recompilation, which is inflexible. Static configuration also requires consideration of various exceptions, making management and maintenance difficult. In this embodiment, scheduled tasks can be deleted flexibly and at any time based on actual needs. Furthermore, deletion of a scheduled task takes effect immediately during operation, providing real-time performance. The technical solution of this embodiment allows for monitoring and management of scheduled tasks during operation, ensuring their stability and reliability.

[0096] In some embodiments, such as Figure 5 As shown, the modification of scheduled tasks in the business system includes:

[0097] Modify the execution period of the scheduled task in the database of the business system; or delete the task information and execution period of the scheduled task in the database of the business system, and store the modified task information and execution period of the scheduled task in the database of the business system;

[0098] Call updateTaskInfo to change the execution period of the scheduled task in the memory of the business system.

[0099] In this embodiment, when modifying a scheduled task, the relevant information of the old scheduled task in the business system database can be deleted and the relevant information of the new scheduled task can be rewritten, or the execution cycle of the scheduled task can be directly changed in the business system database.

[0100] In related technologies, after statically configuring a scheduled task, if the scheduled task needs to be modified, it is necessary to modify the code and recompile it, which is not flexible enough. The scheduled task also needs to be recompiled and deployed before it takes effect, which is slow to take effect. When statically configuring tasks, various abnormal situations need to be considered, making management and maintenance more difficult. In this embodiment, scheduled tasks can be modified at any time and flexibly according to actual needs. Modifications to scheduled tasks can take effect immediately during operation, which is real-time. The technical solution of this embodiment can monitor and manage scheduled tasks during operation, ensuring the stability and reliability of scheduled tasks.

[0101] In some embodiments, such as Figure 6 As shown, after executing the target operation on the scheduled task, the method further includes:

[0102] When the business system is started, query whether there is a valid scheduled task in the business system;

[0103] If there is a valid scheduled task, call addCronTask to load the valid scheduled task into the memory of the business system;

[0104] The scheduled task is executed regularly according to the execution cycle of the scheduled task.

[0105] In this embodiment, when the business system starts, it first queries whether there is a valid scheduled task in the database. If so, the addCronTask method is executed to write the scheduled task into the memory, and then the scheduled task is executed according to the execution cycle of the scheduled task; if not, the loading is completed directly.

[0106] In a specific example, the visualization screen can communicate with the server through websocket. When the visualization screen is open, the page of the visualization screen communicates with the server through websocket. According to the configuration page of the visualization screen, the scheduled task information of each component in the page can be configured and changed, and the scheduled task can be started; the execution time can be set by the page to perform periodic execution of the scheduled task; when the page is closed, the websocket connection between the page and the server is disconnected, and the scheduled task can be canceled to avoid executing invalid tasks and consuming memory; in this embodiment, the page of the visualization screen supports online modification of scheduled tasks and takes effect immediately.

[0107] After executing a scheduled task, the technical solution of this embodiment can also perform task scheduling. Task scheduling is to execute different subsequent business tasks based on the execution results of the scheduled task after the scheduled task is completed. Task scheduling can be divided into three types of execution logic, including any of the following:

[0108] After all the preceding tasks of the business task are executed, the business task is executed, wherein the execution of the business task depends on the execution results of the preceding tasks, such as Figure 7 As shown, Task A and Task B are the predecessor tasks of Task C. After Task A and Task B are executed, Task C is executed according to the execution results of Task A and Task B.

[0109] After executing any of the preceding tasks of the business task, the business task is executed, wherein the execution of the business task depends on the execution result of the preceding task, such as Figure 8 As shown, Task A and Task B are the predecessor tasks of Task C. After Task A or Task B is executed, Task C is executed according to the execution result of Task A or Task B.

[0110] According to the preset task order, multiple business tasks are executed in sequence. The execution of all business tasks depends on the completion of the previous business task. Figure 9 As shown, task A is executed first. After task A is completed, task B is triggered to be executed. After task B is completed, task C is triggered to be executed.

[0111] In a specific example, there is an association relationship between business tasks A, B, C, D, E, F, and G as conditional data: business task A is a predecessor task of business task C, and the execution of business task C depends on the execution result of business task A. When the data of business task A changes, the data in business task C will also change synchronously; business task A is a predecessor task of business task D, and the execution of business task D depends on the execution result of business task A. When the data of business task A changes, the data in business task D will also change synchronously; business task A is a predecessor task of business task G, and the execution of business task G depends on the execution result of business task A. When the data of business task A changes, the data in business task G will also change synchronously; business task B is a predecessor task of business task C, and the execution of business task C depends on the execution result of business task B. When the data of business task B changes, the data in business task C will also change synchronously; business task D is a predecessor task of business task B. Tasks, the execution of business task B depends on the execution result of business task D. When the data of business task D changes, the data in business task B will also change synchronously; business task D is the predecessor task of business task E. The execution of business task E depends on the execution result of business task D. When the data of business task D changes, the data in business task E will also change synchronously; business task F is the predecessor task of business task E. The execution of business task E depends on the execution result of business task F. When the data of business task F changes, the data in business task E will also change synchronously; business task G is the predecessor task of business task F. The execution of business task F depends on the execution result of business task G. When the data of business task G changes, the data in business task F will also change synchronously; business task B is the predecessor task of business task G. The execution of business task G depends on the execution result of business task B. When the data of business task B changes, the data in business task G will also change synchronously. In the prior art, the execution logic output according to the above association relationship is as follows:

[0112] Execute pre-task A and business task C;

[0113] Execute pre-task A and business task D;

[0114] Execute pre-task D and business task B;

[0115] Execute pre-task B and business task C;

[0116] Execute the pre-task B and the business task G;

[0117] Execute the pre-task G and the business task F;

[0118] Execute pre-task F and business task E;

[0119] Execute pre-task D and business task E;

[0120] Execute pre-task A and business task G;

[0121] Execute the pre-task G and the business task F;

[0122] Execute pre-task F and business task E;

[0123] Execute pre-task B and business task C;

[0124] Execute the pre-task B and the business task G;

[0125] Execute the pre-task G and the business task F;

[0126] Execute pre-task F and business task E;

[0127] Execute pre-task D and business task B;

[0128] Execute pre-task B and business task C;

[0129] Execute the pre-task B and the business task G;

[0130] Execute the pre-task G and the business task F;

[0131] Execute pre-task F and business task E;

[0132] Execute pre-task D and business task E;

[0133] Execute pre-task F and business task E;

[0134] Execute the pre-task G and the business task F;

[0135] Execute the prerequisite task F and the business task E.

[0136] From the execution results, it can be seen that a total of 24 executions are required, that is, one conditional query requires querying the database 24 times, which is inefficient and consumes a lot of resources. To save resources and improve the efficiency of task execution, this embodiment can arrange tasks and implement more complex system functions by scheduling and executing different tasks.

[0137] In some embodiments, after executing the scheduled task, the method further includes:

[0138] Execute subsequent business tasks according to the execution results of the scheduled tasks, such as Figure 10 As shown, including:

[0139] Step a: acquiring all post-tasks according to the association condition set of the business task, wherein the execution of the post-task depends on the execution results of other business tasks in the association condition set, and the association condition set includes a plurality of the business tasks having an association relationship;

[0140] Step b: traverse the business tasks in the association condition set;

[0141] Step c: determine whether a business task in the association condition set is included in the post-task; if yes, proceed to step b; if not, proceed to step d;

[0142] Step d: remove the business task from the association relationship condition set, save the business task in the task output list, and go to step e;

[0143] Step e: Determine whether the association relationship condition set is empty. If so, go to step f; if not, go to step a.

[0144] Step f: executing the business tasks in the order of tasks in the task output list.

[0145] In a specific example, there is an association relationship between business tasks A, B, C, D, E, F, and G as conditional data: business task A is a predecessor task of business task C, and the execution of business task C depends on the execution result of business task A. When the data of business task A changes, the data in business task C will also change synchronously; business task A is a predecessor task of business task D, and the execution of business task D depends on the execution result of business task A. When the data of business task A changes, the data in business task D will also change synchronously; business task A is a predecessor task of business task G, and the execution of business task G depends on the execution result of business task A. When the data of business task A changes, the data in business task G will also change synchronously; business task B is a predecessor task of business task C, and the execution of business task C depends on the execution result of business task B. When the data of business task B changes, the data in business task C will also change synchronously; business task D is a predecessor task of business task B. Tasks, the execution of business task B depends on the execution result of business task D. When the data of business task D changes, the data in business task B will also change synchronously; business task D is the predecessor task of business task E. The execution of business task E depends on the execution result of business task D. When the data of business task D changes, the data in business task E will also change synchronously; business task F is the predecessor task of business task E. The execution of business task E depends on the execution result of business task F. When the data of business task F changes, the data in business task E will also change synchronously; business task G is the predecessor task of business task F. The execution of business task F depends on the execution result of business task G. When the data of business task G changes, the data in business task F will also change synchronously; business task B is the predecessor task of business task G. The execution of business task G depends on the execution result of business task B. When the data of business task B changes, the data in business task G will also change synchronously.

[0146] In this embodiment, according to Figure 10 The execution logic of the method output shown is as follows: execute business tasks A, D, B, C, G, F, and E in sequence, that is, only a total of 7 executions are required to obtain the required data, that is, one conditional query requires querying the database 7 times.

[0147] With a data volume of millions, it takes about 15 seconds to obtain the required data using related technologies, while it takes about 4 seconds to obtain the required data using the technical solution of this embodiment, which greatly improves the efficiency of task execution. In addition, the technical solution of this embodiment can also reduce the amount of query data returned.

[0148] The present disclosure also provides a task management device, including:

[0149] The task processor is configured to, in response to an operation instruction for a scheduled task, perform a target operation on the scheduled task, where the target operation includes at least one of the following:

[0150] Add scheduled tasks in the business system;

[0151] Delete scheduled tasks in the business system;

[0152] Modify the scheduled tasks in the business system.

[0153] In this embodiment, after receiving an operation instruction for a scheduled task, the scheduled task can be added, deleted or modified in the business system, thereby realizing dynamic start and stop of the scheduled task, and further realizing the addition of an efficient and flexible business system.

[0154] In this embodiment, Figure 1 and Figure 2 As shown, the task manager can receive operation instructions and add, delete or modify scheduled tasks according to the operation instructions. The task manager can save the task information of the scheduled tasks, update the execution cycle of the scheduled tasks, start the scheduled tasks and stop the scheduled tasks.

[0155] In some embodiments, the task processor includes:

[0156] The adding unit is used to store the task information and execution cycle of the scheduled task in the database of the business system; and call addCronTask to load the scheduled task into the memory of the business system.

[0157] Among them, the task information of the scheduled task includes but is not limited to the task name, task content, execution time, etc. of the scheduled task. The task manager can store the task information and execution cycle of the scheduled task in the database of the business system, and store the scheduled task in the memory of the business system, that is, the Map container, so that the specific logic in the scheduled task can be executed regularly according to the set execution cycle. Among them, the role of the Map container is to control the dynamic start and stop of the scheduled task under the running state of the business system and modify the execution cycle of the scheduled task.

[0158] When adding a scheduled task, you can first search the business system database based on the scheduled task name to determine whether the scheduled task name already exists in the database. If the scheduled task name already exists, an error message will be returned. If the scheduled task name does not exist in the database, the scheduled task name, execution time, execution cycle and other information will be stored in the database and loaded into the Map container.

[0159] In related technologies, after statically configuring scheduled tasks, adding scheduled tasks requires code modifications and recompilation, which is inflexible. Static configuration also requires consideration of various exceptions, making management and maintenance difficult. In this embodiment, scheduled tasks can be added flexibly and at any time based on actual needs. Furthermore, added scheduled tasks can take effect immediately during operation, providing real-time performance. The technical solution of this embodiment allows scheduled tasks to be monitored and managed during operation, ensuring their stability and reliability.

[0160] In some embodiments, the task processor includes:

[0161] The deletion unit is used to modify the execution status of the scheduled task in the database of the business system to disabled or invalid; or, delete the task information and execution cycle of the scheduled task in the database of the business system; call cancelCronTask to delete the scheduled task in the memory of the business system.

[0162] In this embodiment, when deleting a scheduled task, all relevant information of the scheduled task in the database of the business system may be deleted, or only the execution status of the scheduled task in the database may be changed.

[0163] In related technologies, after statically configuring a scheduled task, deleting it requires code modification and recompilation, which is inflexible. Static configuration also requires consideration of various exceptions, making management and maintenance difficult. In this embodiment, scheduled tasks can be deleted flexibly and at any time based on actual needs. Furthermore, deletion of a scheduled task takes effect immediately during operation, providing real-time performance. The technical solution of this embodiment allows for monitoring and management of scheduled tasks during operation, ensuring their stability and reliability.

[0164] In some embodiments, the task processor includes:

[0165] A changing unit is used to change the execution period of the scheduled task in the database of the business system; or to delete the task information and execution period of the scheduled task in the database of the business system, and store the modified task information and execution period of the scheduled task in the database of the business system; call updateTaskInfo to change the execution period of the scheduled task in the memory of the business system.

[0166] In this embodiment, when modifying a scheduled task, the relevant information of the old scheduled task in the business system database can be deleted and the relevant information of the new scheduled task can be rewritten, or the execution cycle of the scheduled task can be directly changed in the business system database.

[0167] In related technologies, after statically configuring a scheduled task, if the scheduled task needs to be modified, it is necessary to modify the code and recompile it, which is not flexible enough. The scheduled task also needs to be recompiled and deployed before it takes effect, which is slow to take effect. When statically configuring tasks, various abnormal situations need to be considered, making management and maintenance more difficult. In this embodiment, scheduled tasks can be modified at any time and flexibly according to actual needs. Modifications to scheduled tasks can take effect immediately during operation, which is real-time. The technical solution of this embodiment can monitor and manage scheduled tasks during operation, ensuring the stability and reliability of scheduled tasks.

[0168] In some embodiments, the apparatus further comprises:

[0169] A query module is used to query whether there is a valid scheduled task in the business system when the business system is started;

[0170] A loading module is used to call addCronTask to load a valid scheduled task into the memory of the business system if there is one;

[0171] The execution module is used to execute the scheduled task regularly according to the execution cycle of the scheduled task.

[0172] In this embodiment, when the business system starts, it first queries whether there is a valid scheduled task in the database. If so, the addCronTask method is executed to write the scheduled task into the memory, and then the scheduled task is executed according to the execution cycle of the scheduled task; if not, the loading is completed directly.

[0173] After executing the scheduled task, the technical solution of this embodiment can also perform task scheduling. Task scheduling is to execute different subsequent business tasks according to the execution results of the scheduled task after the scheduled task is completed; task scheduling can be divided into three types of execution logic, and the device also includes:

[0174] The business task execution module is used to execute subsequent business tasks according to the execution result of the scheduled task, including any of the following:

[0175] According to the preset task order, multiple business tasks are executed in sequence, such as Figure 9 As shown, task A is executed first, and after task A is completed, task B is triggered to be executed, and after task B is completed, task C is triggered to be executed;

[0176] After all the preceding tasks of the business task are executed, the business task is executed, wherein the execution of the business task depends on the execution results of the preceding tasks, such as Figure 7As shown, Task A and Task B are the predecessor tasks of Task C. After Task A and Task B are executed, Task C is executed according to the execution results of Task A and Task B.

[0177] After executing any of the preceding tasks of the business task, the business task is executed, wherein the execution of the business task depends on the execution result of the preceding task, such as Figure 8 As shown, Task A and Task B are the predecessor tasks of Task C. After Task A or Task B is executed, Task C is executed according to the execution result of Task A or Task B.

[0178] In order to save resources and improve the efficiency of task execution, this embodiment can arrange tasks and realize more complex system functions by scheduling and executing different tasks.

[0179] The business task execution module is used to execute subsequent business tasks according to the execution results of the scheduled tasks, including:

[0180] Step a: acquiring all post-tasks according to the association condition set of the business task, wherein the execution of the post-task depends on the execution results of other business tasks in the association condition set, and the association condition set includes a plurality of the business tasks having an association relationship;

[0181] Step b: traverse the business tasks in the association condition set;

[0182] Step c: determine whether a business task in the association condition set is included in the post-task; if yes, proceed to step b; if not, proceed to step d;

[0183] Step d: remove the business task from the association relationship condition set, save the business task in the task output list, and go to step e;

[0184] Step e: Determine whether the association relationship condition set is empty. If so, go to step f; if not, go to step a.

[0185] Step f: executing the business tasks in the order of tasks in the task output list.

[0186] An embodiment of the present disclosure further provides a computer program product, comprising computer instructions, which implement the steps of the above method when executed by a processor.

[0187] In the various method embodiments of the present disclosure, the serial numbers of the steps cannot be used to limit the order of the steps. For ordinary technicians in this field, without paying any creative work, changes to the order of the steps are also within the scope of protection of the present disclosure.

[0188] An embodiment of the present application further provides a computer program / program product, which is stored in a storage medium. The computer program / program product is executed by at least one processor to implement the various processes of the above-mentioned method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0189] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, but may also include performing functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0190] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of a computer software product plus a necessary general hardware platform, or of course, by hardware. The computer software product is stored in a storage medium (such as ROM, RAM, magnetic disk, optical disk, etc.) and includes a number of instructions for causing a terminal or network-side device to execute the methods described in each embodiment of the present application.

[0191] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms of implementation methods without departing from the purpose of this application and the scope of protection of the claims. These implementation methods are all within the protection of this application.

Claims

1. A task management method, characterized in that: include: In response to an operation instruction for a scheduled task, a target operation is performed on the scheduled task, where the target operation includes at least one of the following: Add scheduled tasks in the business system; Delete scheduled tasks in the business system; Modify the scheduled tasks in the business system.

2. The task management method according to claim 1, characterized in that: Adding a scheduled task in the business system includes: Storing the task information and execution period of the scheduled task in the database of the business system; Call addCronTask to load the scheduled task into the memory of the business system.

3. The task management method according to claim 1, characterized in that: Deleting a scheduled task in the business system includes: Modify the execution status of the scheduled task in the database of the business system to be disabled or invalid; or delete the task information and execution cycle of the scheduled task in the database of the business system; Call cancelCronTask to delete the scheduled task in the memory of the business system.

4. The task management method according to claim 1, characterized in that: Changing the scheduled task in the business system includes: Modify the execution period of the scheduled task in the database of the business system; or delete the task information and execution period of the scheduled task in the database of the business system, and store the modified task information and execution period of the scheduled task in the database of the business system; Call updateTaskInfo to change the execution period of the scheduled task in the memory of the business system.

5. The task management method according to any one of claims 1 to 4, characterized in that: After executing the target operation on the scheduled task, the method further includes: When the business system is started, query whether there is a valid scheduled task in the business system; If there is a valid scheduled task, call addCronTask to load the valid scheduled task into the memory of the business system; The scheduled task is executed regularly according to the execution cycle of the scheduled task.

6. The task management method according to claim 5, characterized in that: After executing the scheduled task, the method further includes: Execute subsequent business tasks based on the execution results of the scheduled task, including any of the following: Execute multiple business tasks in sequence according to the preset task order; After all predecessor tasks of the business task are executed, executing the business task, wherein the execution of the business task depends on the execution results of the predecessor tasks; After any preceding task of the business task is executed, the business task is executed, wherein the execution of the business task depends on the execution result of the preceding task.

7. The task management method according to claim 5, characterized in that: After executing the scheduled task, the method further includes: Execute subsequent business tasks based on the execution results of the scheduled tasks, including: Step a: acquiring all post-tasks according to the association condition set of the business task, wherein the execution of the post-task depends on the execution results of other business tasks in the association condition set, and the association condition set includes a plurality of the business tasks having an association relationship; Step b: traverse the business tasks in the association condition set; Step c: determine whether a business task in the association condition set is included in the post-task; if yes, proceed to step b; if not, proceed to step d; Step d: remove the business task from the association relationship condition set, save the business task in the task output list, and go to step e; Step e: Determine whether the association relationship condition set is empty. If so, go to step f; if not, go to step a. Step f: executing the business tasks in the order of tasks in the task output list.

8. A task management device, characterized in that: include: The task processor is configured to, in response to an operation instruction for a scheduled task, perform a target operation on the scheduled task, where the target operation includes at least one of the following: Add scheduled tasks in the business system; Delete scheduled tasks in the business system; Modify the scheduled tasks in the business system.

9. The task management device according to claim 8, characterized in that: The task processor includes: The adding unit is used to store the task information and execution cycle of the scheduled task in the database of the business system; and call addCronTask to load the scheduled task into the memory of the business system.

10. The task management device according to claim 8, characterized in that: The task processor includes: The deletion unit is used to modify the execution status of the scheduled task in the database of the business system to disabled or invalid; or, delete the task information and execution cycle of the scheduled task in the database of the business system; call cancelCronTask to delete the scheduled task in the memory of the business system.

11. The task management device according to claim 8, characterized in that: The task processor includes: A changing unit is used to change the execution period of the scheduled task in the database of the business system; or to delete the task information and execution period of the scheduled task in the database of the business system, and store the modified task information and execution period of the scheduled task in the database of the business system; call updateTaskInfo to change the execution period of the scheduled task in the memory of the business system.

12. The task management device according to any one of claims 8 to 11, characterized in that: The device further comprises: A query module is used to query whether there is a valid scheduled task in the business system when the business system is started; A loading module is used to call addCronTask to load a valid scheduled task into the memory of the business system if there is one; The execution module is used to execute the scheduled task regularly according to the execution cycle of the scheduled task.

13. The task management device according to claim 12, characterized in that: The device further comprises: The task scheduling module is used to execute subsequent business tasks according to the execution results of the scheduled tasks, including any of the following: Execute multiple business tasks in sequence according to the preset task order; After all predecessor tasks of the business task are executed, executing the business task, wherein the execution of the business task depends on the execution results of the predecessor tasks; After any preceding task of the business task is executed, the business task is executed, wherein the execution of the business task depends on the execution result of the preceding task.

14. The task management device according to claim 12, wherein: The device further comprises: The task scheduling module is used to execute subsequent business tasks according to the execution results of the scheduled tasks, including: Step a: acquiring all post-tasks according to the association condition set of the business task, wherein the execution of the post-task depends on the execution results of other business tasks in the association condition set, and the association condition set includes a plurality of the business tasks having an association relationship; Step b: traverse the business tasks in the association condition set; Step c: determine whether a business task in the association condition set is included in the post-task; if yes, proceed to step b; if not, proceed to step d; Step d: remove the business task from the association relationship condition set, save the business task in the task output list, and go to step e; Step e: Determine whether the association relationship condition set is empty. If so, go to step f; if not, go to step a. Step f: executing the business tasks in the order of tasks in the task output list.

15. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 7.