Scheduled task scheduling method, device, electronic device and storage medium
Tasks are triggered through independent task scheduling systems and RPC interfaces, combined with callback services and failure compensation strategies, the problem of inability to monitor the execution results of timing tasks and excessive coupling between task scheduling and business systems in the existing technology is solved, and the decoupling of task scheduling and business systems is achieved and task configuration is simplified.
Patent Information
- Application Number
- CN202010668910.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-13
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2040-07-13
AI Technical Summary
In the prior art, the execution results of timing tasks cannot be effectively monitored, and the task scheduling system and the business system are too heavy, resulting in a change in task rules or business changes that require restart of the entire business system, and the task configuration is complicated.
By deploying an independent task scheduling system, using the RPC interface to trigger tasks, each task is configured with the execution thread, and the task execution results are monitored in real time through callback services. When task execution fails, retry the task according to the preconfigured failure compensation policy.
It realizes complete decoupling between task scheduling and business system, avoids the problem of restarting the task scheduling system when changing task rules or business changes, simplifies task configuration, and monitors task execution results in real time and performs task retry.
Smart Images

Figure CN113934517B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a timed task scheduling method, device, electronic device and storage medium. Background Art
[0002] In the project, you often encounter the need to execute certain program methods at a scheduled time, such as scheduled cache cleaning, data updating, data correction, statistical data, etc. These operations will use scheduled tasks.
[0003] Usually, scheduled tasks are maintained by creating a thread pool in the project, but this approach has many problems. For example, since there is no monitoring of the execution results of the task, timely task failure compensation cannot be performed; since the task scheduling system is too heavily coupled with the business, once the task rules change or the business tasks change, the entire business system needs to be restarted, and task configuration is difficult. Currently, there are some open source task scheduling tools on the market, such as the Quartz (open source project) framework. The Quartz framework is also highly invasive to the business, and there is no monitoring mechanism for the execution results of the task, so the task cannot be retried.
[0004] Currently, no effective solution has been proposed for the problems in related technologies such as the inability to monitor the execution results of scheduled tasks, the inability to retry tasks, and the over-coupling of task scheduling systems and business systems. Summary of the invention
[0005] The embodiments of the present application provide a scheduled task scheduling method, device, electronic device and storage medium to at least solve the problem in the related art that the execution results of the scheduled tasks cannot be monitored, and the problem that the task scheduling system is overly coupled with the business system.
[0006] In a first aspect, an embodiment of the present application provides a scheduled task scheduling method, comprising the following steps:
[0007] Deploy a task scheduling system, wherein the task scheduling system includes a scheduling center and a task executor;
[0008] The task is triggered by calling the remote procedure call (RPC) interface of the task executor;
[0009] Configuring an execution thread for each task, and executing the task through the execution thread;
[0010] After the task is executed, the dispatch center is notified of the task execution result through a callback service;
[0011] When the task execution result shows that the task execution fails, the task is retried according to a pre-configured failure compensation strategy.
[0012] In some embodiments, the scheduled task scheduling method further includes the following steps:
[0013] Use logs to record the execution process, input and output, and / or execution results of tasks.
[0014] In some embodiments, the scheduled task scheduling method further includes the following steps:
[0015] When the task execution result shows that the task execution fails, a remote alarm is issued through the communication platform.
[0016] In some embodiments, triggering a task by calling an RPC interface of the task executor comprises the following steps:
[0017] Adding task rules in the management page of the scheduling center;
[0018] Adding tasks to the task management data of the scheduling center and polling, parsing the tasks using triggers;
[0019] By calling the RPC interface of the task executor, the task whose parsing result meets the task rule is triggered.
[0020] In some embodiments, triggering a task by calling the RPC interface of the task executor further includes the following steps:
[0021] A daemon thread is configured for each task to monitor whether the task rules are changed;
[0022] When a change in the task rule is detected, the latest task rule is read from the database, and the latest task rule is updated to the management page of the scheduling center at regular intervals.
[0023] In some embodiments, the task rules include task triggering time, task triggering method, and the failure compensation strategy.
[0024] In some of these embodiments, the failure compensation strategy includes a retry rule, a retry interval, and a retry count.
[0025] In a second aspect, an embodiment of the present application provides a timed task scheduling device, which includes a deployment module, a trigger module, an execution module, a callback module, and a retry module.
[0026] The deployment module is used to deploy a task scheduling system, and the task scheduling system includes a scheduling center and a task executor;
[0027] The trigger module is used to trigger the task by calling the RPC interface of the task executor;
[0028] The execution module is used to configure an execution thread for each task and execute the task through the execution thread;
[0029] The callback module is used to notify the dispatch center of the task execution result through the callback service after the task execution is completed;
[0030] The retry module is used to retry the task according to a pre-configured failure compensation strategy when the task execution result is a failure.
[0031] In some embodiments, the scheduled task scheduling device further includes a log recording module. The log recording module is used to record the execution process, input and output, and / or execution result of the task using a log.
[0032] In some embodiments, the scheduled task scheduling device further includes a failure alarm module. The failure alarm module is used to issue a remote alarm through a communication platform when the task execution result shows that the task execution fails.
[0033] In some embodiments, the trigger module further includes a rule adding unit, a task parsing unit, and a task triggering unit. The rule adding unit is used to add task rules in the management page of the scheduling center; the task parsing unit is used to add tasks to the task management data of the scheduling center and perform polling, and parse the tasks using triggers; the task triggering unit is used to trigger the tasks whose parsing results meet the task rules by calling the RPC interface of the task executor.
[0034] In some embodiments, the trigger module further includes a task guard unit and a task update unit. The task guard unit is used to configure a guard thread for each task to monitor whether the task rules have changed; the task update unit is used to read the latest task rules from the database when the task guard unit detects that the task rules have changed, and regularly update the latest task rules to the management page of the scheduling center.
[0035] In some embodiments, the task rules include task triggering time, task triggering method, and the failure compensation strategy.
[0036] In some of these embodiments, the failure compensation strategy includes a retry rule, a retry interval, and a retry count.
[0037] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the timed task callback method as described in the first aspect above is implemented.
[0038] In a fourth aspect, an embodiment of the present application provides a storage medium on which a computer program is stored, and when the program is executed by a processor, the scheduled task callback method described in the first aspect above is implemented.
[0039] Compared with the related art, the timed task scheduling method, device, electronic device and storage medium provided in the embodiment of the present application, by deploying the task scheduling system separately and triggering the task using the RPC interface, each task is executed through a thread, thereby achieving complete decoupling of task scheduling from the business system. When the task rules change or the task changes, the task scheduling system does not need to be restarted, and flexible dynamic configuration can be achieved. And through the callback service, real-time monitoring of the execution results of the task and task retry are achieved.
[0040] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0042] Figure 1 It is a hardware structure block diagram of a terminal of the scheduled task scheduling method provided in an embodiment of the present application;
[0043] Figure 2 is a flowchart of a scheduled task scheduling method provided according to an embodiment of the present application;
[0044] Figure 3 yes Figure 2 Specific flow chart of step S202 in FIG.
[0045] Figure 4 is a structural block diagram of a task scheduling system provided in an embodiment of the present application;
[0046] Figure 5 It is a schematic diagram of the project flow provided by the embodiment of the present application;
[0047] Figure 6 It is a structural block diagram of a timed task scheduling device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application. In addition, it can also be understood that although the efforts made in this development process may be complex and lengthy, for ordinary technicians in the field related to the contents disclosed in the present application, some changes such as design, manufacturing or production based on the technical contents disclosed in the present application are only conventional technical means, and should not be understood as insufficient contents disclosed in the present application.
[0049] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0050] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to greater than or equal to two. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The terms "first", "second", "third" and the like involved in the present application are merely used to distinguish similar objects and do not represent a specific ordering of the objects.
[0051] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. Taking running on a terminal as an example, Figure 1 FIG. 1 is a hardware structure diagram of a terminal of a timed task scheduling method according to an embodiment of the present invention. Figure 1 As shown, the terminal 10 may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0052] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the timed task scheduling method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal 10 via a network. The above network includes but is not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0053] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by the communication provider of the terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0054] The present application provides a method for scheduling scheduled tasks. Figure 2 is a flowchart of a scheduled task scheduling method provided according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:
[0055] Step S201: deploying a task scheduling system, where the task scheduling system includes a scheduling center and a task executor;
[0056] Step S202: triggering the task by calling the RPC interface of the task executor;
[0057] Step S203: configure an execution thread for each task, and execute the task through the execution thread;
[0058] Step S204: After the task is completed, the dispatch center is notified of the task execution result through the callback service;
[0059] Step S205: When the task execution result shows that the task execution has failed, the task is retried according to a pre-configured failure compensation strategy.
[0060] The task scheduling system deployed above is a system dedicated to task scheduling that is independent of the business system (specific business project for executing tasks). The task scheduling system and the business system do not affect each other. When the task rules change or the tasks change, you only need to restart the project for executing the tasks without restarting the task scheduling system. The task scheduling system may include a scheduling center and a task executor. Among them, the scheduling center can be used to manage tasks, and the task executor can be used to execute tasks. The task executor is provided with an RPC interface, and the scheduling center triggers the task by calling the RPC interface of the task executor.
[0061] RPC in this application refers to a remote procedure call implemented by calling the interface of another application in one application, without worrying about the underlying network communication. Specifically, the communication process of triggering a task by calling the RPC interface of the task executor in this application can be implemented based on HTTP protocol, TCP protocol, UDP protocol, etc.
[0062] This embodiment deploys a task scheduling system separately and uses the RPC interface to trigger tasks. Each task is executed through a thread, which completely decouples task scheduling from the business system. When the task rules change or the task changes, only the project executing the task needs to be restarted, and the task scheduling system is not affected. In addition, task scheduling is decoupled from the business system, and can be maintained separately. Tasks can be flexibly configured to facilitate subsequent business iteration and expansion.
[0063] Furthermore, after the task is executed, the task execution result is notified to the dispatch center through the callback service; when the task execution result shows that the task execution failed, the task is retried according to the pre-configured failure compensation strategy.
[0064] As an implementable method, the return value after task scheduling can be used to confirm the status of task execution and implement callback service. Then, the task can be retried through the failure compensation strategy configured by the developer.
[0065] By notifying the dispatch center of the task execution results through the callback service, developers can monitor the task execution results in real time. Furthermore, it is convenient to intervene manually when the task fails, or retry the task through the pre-configured failure compensation strategy (you can re-call the trigger interface of the task, or configure other compensation interfaces).
[0066] The timed task scheduling method provided in this embodiment realizes the complete decoupling of task scheduling and business. When the task rules change or the task is changed, the task scheduling does not need to be restarted, and flexible dynamic configuration can be realized. Furthermore, through the callback service, the execution feedback of the task can be monitored in real time, and the task can be executed repeatedly.
[0067] The prior art uses the Quartz framework, which can only be used in the Java language and cannot support other high-level programming languages. In addition, the tool is complex to use, which limits the use of developers. The RPC interface in this application is not limited to the development language, and can be used by projects that can support the HTTP protocol. That is, as long as the project supports the HTTP interface, the scheduling center can configure when to call, the calling address, the calling interface, etc., to achieve task scheduling, which is completely decoupled from the business.
[0068] In some embodiments, the timed task scheduling method provided in the above embodiments further includes the following steps: using a log to record the execution process, input and output, and / or execution results of the task. Each step of the execution process is recorded in a log, including task submission, task execution, and task callback. Once an abnormality is found in the log record, a retry will be performed.
[0069] In some embodiments, the timed task scheduling method provided in the above embodiments further includes the following steps: when the task execution result shows that the task execution has failed, a remote alarm is issued through a communication platform.
[0070] For example, the task scheduling system can be connected to the SMS platform, and the alarm recipient can be configured. Once the task scheduling fails, the alarm recipient will be notified via SMS. Similarly, it can also be connected to the communication network such as China Mobile, China Unicom, and China Telecom to notify the alarm recipient by phone. The alarm recipient can also be notified through the Internet, such as WeChat, QQ, DingTalk, etc.
[0071] As an implementation method, Figure 3 As shown, in the above step S202, the task is triggered by calling the RPC interface of the task executor, which can be specifically implemented by the following steps:
[0072] S301, adding task rules in the management page of the dispatch center;
[0073] S302, adding the task to the task management data of the scheduling center and performing polling, and parsing the task using a trigger;
[0074] S303: triggering the task whose parsing result meets the task rules by calling the RPC interface of the task executor.
[0075] In the above step S302, the task is added to the task management data of the scheduling center and polled. The polling time can be set, for example, polling once per second, or polling once every 2 seconds.
[0076] Furthermore, the timed task scheduling method provided in the above embodiment may further include the following steps:
[0077] A daemon thread is configured for each task to monitor whether the task rules have changed; when a change in the task rules is detected, the latest task rules are read from the database and the latest task rules are regularly updated to the management page of the scheduling center.
[0078] The task rules in the above embodiment may include any configurable rules or policies related to task scheduling, such as task triggering time, task triggering mode, and failure compensation policy.
[0079] Among them, the task triggering methods include at least the following three forms:
[0080] The first type is triggered at a specific time point: for example, trigger at 00:00:00 on June 18, 2020, or trigger at 12:12:12 on November 11, 2020. For this form, you only need to configure a specific time point.
[0081] The second type is specific time interval triggering: for example, triggering once every 2 seconds, once every 5 seconds, once every 10 seconds, etc.
[0082] The third type is time rule triggering: for example, triggering at 1:01:01 on the first day of every month, 1:01:01 on Wednesday of every week, 2:01:01 every morning, etc.
[0083] The task triggering method may also include the following two types: task end interval and task start interval.
[0084] Task end interval: For example, if the interval is 5 seconds, you can configure it to be triggered again after 5 seconds after the task ends.
[0085] Task start interval: For example, if the interval is 5 seconds, the task will be triggered 5 seconds after it starts, regardless of whether the previous task has been completed.
[0086] The above time values are all configurable items and are not limited to the times listed above.
[0087] The failure compensation strategy can include retry rules, retry intervals, and the number of retries. The retry rule can be to call the trigger interface of the task again, or to configure other compensation interfaces for retry. The retry interval is the set retry time interval, such as 1 second, 2 seconds, 5 seconds, etc. The number of retries can be set to 1 or more times.
[0088] See also Figure 4 The embodiment of the present application also provides a scheduled task scheduling system 400 , which includes a scheduling center 410 and a task executor 420 .
[0089] The scheduling center 410 may include task management 411, executor management 412, log management 413, data center 414, scheduler 415, callback service 416, registration service 417 and others 418. Task management 411 is used to call the task executor to execute tasks, read and store tasks, and persist them to the database. Log management 413 is used to manage the logs, input and output, and execution result logs of the task execution process. Data center 414 is used to store the running status of the task, the registration data of the task, and the execution information data of the task. Scheduler 415 is a controller for executing task scheduling, which stores all triggers and corresponding task data, uses thread pool as the basic component of task operation, and improves the execution efficiency of tasks. Callback service 416 is used for callback of task execution results, which is convenient for notifying developers and executing failure compensation strategies. Others 418 include running report display, task dependency (for dependent tasks, a specific order can be configured so that tasks are called in order), triggers, etc. Triggers are used to define and parse the time rules for task scheduling, that is, to tell the scheduler when to trigger the task.
[0090] The task executor 420 may include an executor service 421, a log service 422, a callback thread 423, a task thread 424, a task processor 425, an RPC interface 426, a registration thread 427, and a scheduling result 428. Among them, the executor service 421 is used to execute a specific task. The log service 422 is used to print the log of the task. The callback thread 423 is used to report the task execution result to the scheduling center. The task thread 424 is the task thread pool. The task processor 425 is used to actually call the task execution. The RPC interface 426 is the task interface called by the scheduling center. The registration thread 427 is used for task registration.
[0091] The above-mentioned scheduled task scheduling system 400 can be used to implement the scheduled task scheduling method provided in the above-mentioned embodiment, and will not be repeated hereafter.
[0092] See also Figure 5 , Figure 5 The project flow shown can be based on Figure 4 The timing task scheduling system shown is implemented. It shows the processes of task callback, task retry, task submission exception log record, task execution exception log record, and task callback exception log record. For details, please refer to the relevant description of a timing task scheduling method provided in the above embodiment.
[0093] It should be noted that the steps shown in the above process or the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here. For example, Figure 3 The order of step S301 and step S302 in the method can be swapped.
[0094] This embodiment also provides a timed task scheduling device, which is used to implement the timed task scheduling method provided in the above embodiment, which has been described and will not be repeated. As used below, the terms "module", "unit", "subunit" and the like can implement a combination of software and / or hardware for a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceivable.
[0095] Figure 6 is a structural block diagram of a timed task scheduling device according to an embodiment of the present application, such as Figure 6 As shown, the device includes a deployment module 601, a trigger module 602, an execution module 603, a callback module 604, and a retry module 605.
[0096] Among them, the deployment module 601 is used to deploy the task scheduling system, which includes a scheduling center and a task executor; the trigger module 602 is used to trigger the task by calling the RPC interface of the task executor; the execution module 603 is used to configure an execution thread for each task and execute the task through the execution thread; the callback module 604 is used to notify the scheduling center of the task execution result through the callback service after the task execution is completed; the retry module 605 is used to retry the task according to the pre-configured failure compensation strategy when the task execution result is a failure.
[0097] As an implementation method, the above-mentioned scheduled task scheduling device is Figure 6 Based on the structure shown, a log recording module is also included. The log recording module is used to use logs to record the execution process, input and output, and / or execution results of the task.
[0098] Furthermore, the above-mentioned scheduled task scheduling device further includes a failure alarm module based on the log recording module. The failure alarm module is used to issue a remote alarm through a communication platform when the task execution result shows that the task execution fails.
[0099] As an implementation method, the trigger module 602 may also include a rule adding unit, a task parsing unit, and a task triggering unit. The rule adding unit is used to add task rules in the management page of the scheduling center; the task parsing unit is used to add tasks to the task management data of the scheduling center and perform polling, and parse the tasks using triggers; the task triggering unit is used to trigger the tasks whose parsing results meet the task rules by calling the RPC interface of the task executor.
[0100] Furthermore, as an implementable method, the trigger module 602 may also include a task guard unit and a task update unit. The task guard unit is used to configure a guard thread for each task to monitor whether the task rules have changed; the task update unit is used to read the latest task rules from the database when the task guard unit detects that the task rules have changed, and regularly update the latest task rules to the management page of the scheduling center.
[0101] The task rules include task triggering time, task triggering method, and failure compensation strategy, wherein the failure compensation strategy includes retry rules, retry interval, and retry times.
[0102] By using the timed task scheduling device provided in this embodiment, it is possible to achieve complete decoupling of task scheduling from business. When the task rules change or the task is changed, the task scheduling does not need to be restarted, and flexible dynamic configuration can be achieved. The device can also provide a callback service, monitor the execution results of the task in real time, and achieve task retry.
[0103] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0104] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0105] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0106] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0107] Step S201: deploying a task scheduling system, where the task scheduling system includes a scheduling center and a task executor;
[0108] Step S202: trigger the task by calling the RPC interface of the task executor;
[0109] Step S203: configure an execution thread for each task, and execute the task through the execution thread;
[0110] Step S204: After the task is completed, the dispatch center is notified of the task execution result through the callback service;
[0111] Step S205: When the task execution result shows that the task execution has failed, the task is retried according to a pre-configured failure compensation strategy.
[0112] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0113] In addition, in combination with the timed task scheduling method in the above embodiment, the embodiment of the present application can provide a storage medium for implementation. The storage medium stores a computer program; when the computer program is executed by a processor, any of the timed task scheduling methods in the above embodiment is implemented.
[0114] Those skilled in the art should understand that the technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0115] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A timed task scheduling method, characterized in that: The following steps are involved: Deploy a task scheduling system, wherein the task scheduling system includes a scheduling center and a task executor; The task is triggered by calling the RPC interface of the task executor; wherein the following steps are included: Adding task rules in the management page of the scheduling center; Adding tasks to the task management data of the scheduling center and polling, parsing the tasks using triggers; By calling the RPC interface of the task executor, the task whose parsing result meets the task rule is triggered; A daemon thread is configured for each task to monitor whether the task rules are changed; When a change in the task rule is detected, the latest task rule is read from the database, and the latest task rule is updated to the management page of the scheduling center at regular intervals; the task rule includes the task trigger time, the task trigger method, and the failure compensation strategy; Configuring an execution thread for each task, and executing the task through the execution thread; After the task is executed, the dispatch center is notified of the task execution result through a callback service; When the task execution result shows that the task execution fails, the task is retried according to a pre-configured failure compensation strategy.
2. The timed task scheduling method according to claim 1, characterized in that: The following steps are also included: Use logs to record the execution process, input and output, and / or execution results of tasks.
3. The timed task scheduling method according to claim 1, characterized in that: The following steps are also included: When the task execution result shows that the task execution fails, a remote alarm is issued through the communication platform.
4. The timed task scheduling method according to claim 1, characterized in that: The failure compensation strategy includes a retry rule, a retry interval, and a retry count.
5. A timed task scheduling device, characterized in that: Includes deployment module, trigger module, execution module, callback module, and retry module; The deployment module is used to deploy a task scheduling system, and the task scheduling system includes a scheduling center and a task executor; The trigger module is used to trigger the task by calling the RPC interface of the task executor; wherein the following steps are included: Adding task rules in the management page of the scheduling center; Adding tasks to the task management data of the scheduling center and polling, parsing the tasks using triggers; By calling the RPC interface of the task executor, the task whose parsing result meets the task rule is triggered; A daemon thread is configured for each task to monitor whether the task rules are changed; When a change in the task rule is detected, the latest task rule is read from the database, and the latest task rule is updated to the management page of the scheduling center at regular intervals; the task rule includes the task trigger time, the task trigger method, and the failure compensation strategy; The execution module is used to configure an execution thread for each task and execute the task through the execution thread; The callback module is used to notify the scheduling center of the task execution result through the callback service after the task execution is completed; The retry module is used to retry the task according to a pre-configured failure compensation strategy when the task execution result is a failure.
6. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the timed task scheduling method according to any one of claims 1 to 4.
7. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the scheduled task scheduling method according to any one of claims 1 to 4 when running.
Citation Information
Patent Citations
Asynchronous service integrated scheduling method and device which support time strategy
CN107015855A
Task scheduling method based on distributed scheduling system, server and memory medium
CN108762931A