Timed task scheduling execution method and electronic equipment

By centrally managing the scheduled task configuration information in the service database and utilizing the scheduling device platform to dynamically adjust the scheduled tasks, the problem of the inability to flexibly modify scheduled tasks in the existing technology is solved, efficient and flexible scheduled task management is achieved, the system architecture is simplified and maintenance costs are reduced.

CN120704816APending Publication Date: 2025-09-26DALIAN NEUSOFT CANGSU INTELLIGENT MEDICAL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510672177.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-23
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

The triggering method of scheduled tasks in the existing technology cannot be flexibly modified or deleted after the Web service is started, resulting in high system complexity and increased maintenance costs. In addition, the implementation methods of different developers are inconsistent, lacking flexibility and maintainability.

Method used

By centrally managing the configuration information of scheduled tasks in the service database, using the scheduling device platform to dynamically add, modify or delete scheduled tasks, and adopting multi-instance design and lock state management, flexible scheduling and efficient execution of tasks can be achieved.

Benefits of technology

It improves the flexibility and maintainability of the system, simplifies the system architecture, reduces the complexity of development and maintenance, avoids the need to restart Web services, and improves task processing efficiency and system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120704816A_ABST
    Figure CN120704816A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of software program management, and discloses a timed task scheduling execution method and electronic device.The method comprises the steps that configuration information of timed tasks of all Web services is determined from a service database; according to the configuration information of each timed task, determining a target timed task which needs to be executed currently and generating a task execution request; and sending the task execution request to a target Web service corresponding to the target timed task to indicate the target Web service to execute the target timed task. According to the method, the timed tasks are managed in a centralized manner based on the service database, the centralized management allows an administrator to dynamically add, modify or delete the configuration of the timed tasks in the Web service operation process, the Web service does not need to be restarted, the flexibility of the system is improved, and the complexity of development and maintenance is reduced. The Web system does not need to be integrated with a clocked flip-flop to trigger the timed task starting of the Web service, so that the development difficulty of the Web system is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of software program management, for example, to a timed task scheduling execution method and electronic device. Background Art

[0002] With the rapid development of the internet, modern web systems often need to handle a large number of scheduled tasks. These tasks may include scenarios such as data synchronization, scheduled backups, report generation, and data updates. To meet these needs, technologies can integrate scheduled triggers into web systems to trigger the start of scheduled tasks in web services. For example, scheduled tasks in web services can be triggered based on Crons or Triggers.

[0003] However, the related art method for triggering scheduled tasks means that subsequent triggering events for the scheduled task take effect once the Web service is started, making it impossible to flexibly modify or delete the scheduled task while the Web service is running. Adjusting the scheduled task's startup strategy requires restarting the entire Web service, which is unacceptable in a production environment. Furthermore, different developers may adopt different implementations for triggering scheduled tasks, which not only increases system complexity but also raises subsequent development and maintenance costs. Therefore, the related art method for triggering scheduled tasks suffers from shortcomings such as poor flexibility and low maintainability.

[0004] The information disclosed in the above Background section is only for enhancement of understanding of the background of the present disclosure and therefore it may contain information that does not form the prior art that is already known to a person of ordinary skill in the art. Summary of the Invention

[0005] In order to provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. The summary is not an extensive review, nor is it intended to identify key / critical elements or delineate the scope of protection of these embodiments, but rather serves as a prelude to the detailed description that follows.

[0006] The embodiments of the present disclosure provide a method for scheduling and executing a scheduled task and an electronic device, which can improve the flexibility and maintainability of triggering a scheduled task.

[0007] According to a first aspect of the present disclosure, a method for scheduling and executing a scheduled task is provided, comprising:

[0008] Determine the configuration information of the scheduled tasks of each Web service from the service database;

[0009] According to the configuration information of each scheduled task, determine the target scheduled task that needs to be executed and generate a task execution request;

[0010] The task execution request is sent to the target Web service corresponding to the target scheduled task to instruct the target Web service to execute the target scheduled task.

[0011] In some embodiments, each scheduled task is assigned to a corresponding instance; determining whether there is a scheduled task that needs to be executed currently based on the task trigger time of each scheduled task, and marking the scheduled task that needs to be executed currently as a target scheduled task, including: using each instance to poll its corresponding scheduled tasks, determining whether there is a scheduled task that needs to be executed currently based on the task trigger time of each scheduled task, and marking the scheduled task that needs to be executed currently as the target scheduled task;

[0012] Generating a task execution request based on the interface call parameters of the target scheduled task includes: generating a task execution request based on the interface call parameters of the target scheduled task marked by each instance.

[0013] In some embodiments, the configuration information includes a task number, and the attribution relationship between the instance and the scheduled task is determined based on the total number of instances, the sequence number of the instance, and the task number of the scheduled task.

[0014] In some embodiments, the configuration information includes an execution status, and the execution status includes executing and executed;

[0015] Utilize each instance to poll its corresponding scheduled tasks, determine whether there is a scheduled task that needs to be executed according to the task trigger time of each scheduled task, and mark the scheduled task that needs to be executed as the target scheduled task, including: using each instance to cyclically execute the polling process to mark the target scheduled task, wherein the polling process includes the following steps:

[0016] Use each instance to poll its corresponding scheduled tasks and determine whether there is a target scheduled task that needs to be executed based on the task trigger time of each scheduled task, including:

[0017] The scheduled tasks whose execution status is "executed" are selected as candidate scheduled tasks;

[0018] Use each instance to poll its corresponding candidate scheduled tasks, and determine whether there are candidate scheduled tasks that need to be executed according to the task trigger time of each candidate scheduled task;

[0019] When a candidate scheduled task to be executed is determined, the execution state of the candidate scheduled task to be executed is modified to being executed, so that the candidate scheduled task becomes a target scheduled task.

[0020] In some embodiments, after sending the task execution request to the target Web service corresponding to the target scheduled task, it also includes: when it is determined that the target scheduled task is executed successfully, using the instance to which the target scheduled task belongs to modify the execution status of the target scheduled task to executed, making it a candidate scheduled task.

[0021] In some embodiments, the configuration information includes a lock state, the lock state includes locked and unlocked, each instance includes a scheduling process, and the scheduling process has multiple scheduling threads;

[0022] Using each instance based on the interface call parameters of the target scheduled task marked by the instance to generate a task execution request, including: using each instance to cyclically execute a scheduling process to generate the task execution request of the target scheduled task, wherein the scheduling process includes the following steps:

[0023] Use the idle scheduling thread in the instance to query the target scheduled task whose lock status is unlocked;

[0024] When a target scheduled task with an unlocked lock state is found by querying using a scheduling thread, the lock state of the target scheduled task is modified to locked, and a task execution request is generated based on the interface call parameters of the target scheduled task.

[0025] In some embodiments, after sending the task execution request to the target Web service corresponding to the target scheduled task, the method further includes: when determining that the target scheduled task is successfully executed, using the corresponding scheduling thread to modify the lock state of the target scheduled task to unlocked.

[0026] In some embodiments, after sending the task execution request to the target Web service corresponding to the target scheduled task, the method further includes: executing a preset fault tolerance measure when determining that the target scheduled task fails to execute.

[0027] According to a second aspect of the present disclosure, an electronic device is provided, comprising a processor and a memory storing program instructions, wherein the processor is configured to execute the timed task scheduling execution method provided by the first aspect of the present disclosure when running the program instructions.

[0028] According to a third aspect of the present disclosure, a storage medium is provided, in which computer program instructions are stored. When the computer program instructions are executed by a processor, the scheduled task scheduling execution method provided by the first aspect of the present disclosure is executed.

[0029] The scheduled task scheduling execution method and electronic device provided by the embodiments of the present disclosure can achieve the following technical effects:

[0030] The scheduled task scheduling execution method provided by the embodiment of the present disclosure pre-generates a service database containing the configuration information of the scheduled tasks of the Web service, and centrally manages the scheduled tasks based on the service database. This centralized management allows administrators to dynamically add, modify, or delete the configuration of scheduled tasks during the operation of the Web service without restarting the Web service, which greatly improves the flexibility of the system. This not only simplifies the system architecture, but also unifies the management method of scheduled tasks, reducing the complexity of development and maintenance. In addition, the Web system does not need to integrate a scheduled trigger to trigger the start of the scheduled task of the Web service, which reduces the difficulty of Web system development.

[0031] The foregoing general description and the following description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] One or more embodiments are exemplarily described by corresponding drawings. These exemplary descriptions and drawings do not limit the embodiments. Elements with the same reference numerals in the drawings are shown as similar elements. The drawings do not constitute a scale limitation. In addition,

[0033] Figure 1 This is a schematic diagram of a configuration page of a scheduling device platform provided by an embodiment of the present disclosure;

[0034] Figure 2 This is a schematic diagram of configuration information of a Web service registered to a scheduling device platform provided by an embodiment of the present disclosure;

[0035] Figure 3 This is a schematic diagram of a method for scheduling and executing scheduled tasks provided by an embodiment of the present disclosure;

[0036] Figure 4 is a schematic diagram of another method for scheduling and executing scheduled tasks provided by an embodiment of the present disclosure;

[0037] Figure 5 is a schematic diagram of another method for scheduling and executing scheduled tasks provided by an embodiment of the present disclosure;

[0038] Figure 6 is a schematic diagram of another method for scheduling and executing scheduled tasks provided by an embodiment of the present disclosure;

[0039] Figure 7 is a schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0040] In order to be able to understand the features and technical content of the embodiments of the present disclosure in more detail, the implementation of the embodiments of the present disclosure is described in detail below in conjunction with the accompanying drawings. The accompanying drawings are for reference only and are not used to limit the embodiments of the present disclosure. In the following technical description, for the sake of convenience of explanation, a full understanding of the disclosed embodiments is provided through multiple details. However, one or more embodiments can still be implemented without these details. In other cases, to simplify the drawings, well-known structures and devices can be simplified for display.

[0041] In the description and claims of the embodiments of the present disclosure, as well as in the accompanying drawings, the terms "first," "second," and the like are used to distinguish similar items and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate to describe the embodiments of the present disclosure herein. In addition, the terms "including," "having," and any variations thereof are intended to cover non-exclusive inclusions.

[0042] Unless otherwise stated, the term "plurality" means two or more.

[0043] In the embodiment of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B means: A or B.

[0044] The term "and / or" describes an association between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or A and B.

[0045] The term "correspondence" may refer to an association relationship or a binding relationship. The correspondence between A and B means that there is an association relationship or a binding relationship between A and B.

[0046] An embodiment of the present disclosure provides an electronic device, which may be a server, a personal computer, an embedded device, an edge computing device, or a mobile device (such as a smartphone or tablet). The electronic device stores a service database that records configuration information of a scheduled task of at least one web service.

[0047] In some embodiments, the electronic device can be deployed with a specially designed scheduling device platform, and the scheduling device platform registers the configuration information of the scheduled tasks of at least one Web service. The electronic device can generate a service database based on the configuration information of the scheduled tasks of each Web service registered based on the scheduling device platform. The configuration information includes the task trigger time and interface call parameters. Here, the task trigger time is the time when the scheduled task needs to start execution, and the interface call parameters are the relevant parameters of the API (Application Programming Interface) of the Web service used to execute the scheduled task. These relevant parameters may include request method parameters, URL (Uniform Resource Locator) path, query parameters, request header, request body and authentication information, etc. The Web service can provide specific functions or services through the network to execute scheduled tasks. Scheduled tasks may include data processing and synchronization, report generation and sending, system maintenance, scheduled notifications and reminders, business logic processing (such as inventory management and price adjustment, etc.), security management and automated testing, etc.

[0048] In some embodiments, the electronic device can execute the scheduled task scheduling execution method by running the scheduling device platform. Specifically, by running the scheduling device platform, the electronic device can identify the task that needs to be executed currently based on the execution time of the scheduled task and mark it as the target task; then, generate an execution request based on the interface call parameters of the target task, and finally send this request to the corresponding target Web service to trigger task execution.

[0049] In the disclosed embodiment, a Web service is connected to the scheduling device platform to register the configuration information of the scheduled task of the Web service with the scheduling device platform. When a Web service needs to access the scheduling device platform, it is necessary to enter the domain name of the Web service into the scheduling device platform for security authentication, and then assign it a username, password, and authentication key (Authorization Key). The username and password serve as the authority authentication for logging into the scheduling device platform, and the authentication key serves as the security authentication for the scheduling device platform to access the Web service.

[0050] For Web services that need to access the scheduling device platform, the developers of the Web services open an API, and the style of the API can be RESTful (Representational State Transfer Fulfillment). RESTful API is an application programming interface designed based on the REST architectural principles. REST is a software architectural style that uses standard HTTP methods to process resources, enabling different systems to communicate and exchange data over the network. RESTful API has become one of the most popular API design styles in modern Web services due to its simplicity, scalability, and wide applicability. At the same time, set the authentication key in the API header. Then, combined with Figure 1 As shown, log in to the scheduling device platform according to the provided Web service user name and password, and register the Web service configuration information in the configuration page of the scheduling device platform. Figure 2 As shown, after completing the configuration information, the scheduling device platform can obtain various configuration information of the Web service.

[0051] In some embodiments, the configuration information also includes information about the normal execution duration, safety duration threshold, and fault tolerance measures of the scheduled task of the Web service. The electronic device can monitor the actual execution duration of the scheduled task while the Web service is executing the scheduled task, and can implement corresponding fault tolerance measures when the difference between the actual execution duration and the normal execution duration exceeds the safety duration threshold.

[0052] In the embodiment of the present disclosure, the fault tolerance measures may include retry and alarm. The configuration information may include the contact information of the alarm recipient (such as email address and mobile phone number).

[0053] In conjunction with the electronic device provided by the embodiment of the present disclosure (hereinafter referred to as the device), the embodiment of the present disclosure provides a method for scheduling and executing a timed task, such as Figure 3 As shown, the scheduled task scheduling execution method includes:

[0054] S301: The device determines the configuration information of the scheduled tasks of each Web service from the service database.

[0055] S302: The device determines the target scheduled task that needs to be executed currently based on the configuration information of each scheduled task and generates a task execution request.

[0056] S303: The device sends a task execution request to a target Web service corresponding to the target scheduled task, to instruct the target Web service to execute the target scheduled task.

[0057] The scheduled task scheduling execution method provided by the embodiment of the present disclosure pre-generates a service database containing the configuration information of the scheduled tasks of the Web service, and centrally manages the scheduled tasks based on the service database. This centralized management allows administrators to dynamically add, modify, or delete the configuration of scheduled tasks during the operation of the Web service without restarting the Web service, which greatly improves the flexibility of the system. This not only simplifies the system architecture, but also unifies the management method of scheduled tasks, reducing the complexity of development and maintenance. In addition, the Web system does not need to integrate a scheduled trigger to trigger the start of the scheduled task of the Web service, which reduces the difficulty of Web system development.

[0058] In some embodiments, the configuration information includes a task trigger time and interface call parameters. Based on the configuration information of each scheduled task, determining whether a target scheduled task currently needs to be executed and generating a task execution request includes: determining whether there is a scheduled task that needs to be executed based on the task trigger time of each scheduled task, marking the scheduled task that needs to be executed as the target scheduled task; and generating a task execution request based on the interface call parameters of the target scheduled task.

[0059] Combine Figure 4 As shown, the embodiment of the present disclosure provides another method for scheduling and executing a scheduled task. The device can execute the method for scheduling and executing a scheduled task by running a scheduling device platform. The method for scheduling and executing a scheduled task includes:

[0060] S401: The device determines the configuration information of the scheduled tasks of each Web service from the service database.

[0061] S402: The device determines whether there is a scheduled task that needs to be executed currently according to the task triggering time of each scheduled task, and marks the scheduled task that needs to be executed currently as a target scheduled task.

[0062] S403: The device generates a task execution request based on the interface call parameters of the target scheduled task.

[0063] S404: The device sends a task execution request to a target Web service corresponding to the target scheduled task, to instruct the target Web service to execute the target scheduled task.

[0064] The scheduled task scheduling execution method provided by the embodiment of the present disclosure provides a scheduling device platform, which can be used to obtain a service database. The scheduling device platform registers and centrally manages the configuration information of the scheduled tasks of multiple Web services (including task trigger time and interface call parameters). This centralized management allows administrators to dynamically add, modify or delete the configuration of scheduled tasks during the operation of the Web service without restarting the Web service, which greatly improves the flexibility of the system. By separating the scheduling of scheduled tasks from specific Web services, an independent scheduling device platform is used to be responsible for the identification, scheduling and execution of tasks. Each scheduled task has a clear trigger time and generates a task execution request based on its interface call parameters. This not only simplifies the system architecture, but also unifies the management method of scheduled tasks, reducing the complexity of development and maintenance. In addition, after the introduction of the scheduling device platform, the Web system does not have to integrate a timing trigger to trigger the start of the scheduled task of the Web service, reducing the difficulty of developing the Web system.

[0065] In some embodiments, the scheduling device platform may include multiple instances, and each scheduled task is assigned to a corresponding instance. Here, an instance refers to a specific running copy of the scheduling device platform, and each instance is responsible for managing and scheduling a group of scheduled tasks.

[0066] In the embodiment of the present disclosure, the configuration information includes a task number, and the ownership relationship between the instance and the scheduled task is determined based on the total number of instances, the serial number of the instance, and the task number of the scheduled task. Here, the total number of instances can be used as a sharding parameter, and the serial number of the instance can be used as the sharding index of the instance, and the ownership relationship between the instance and the scheduled task is determined based on the sharding parameter, the sharding index of the instance, and the task number of the scheduled task. Specifically, for an instance, the sharding parameter is modulo-operated on the sharding index of the instance to obtain the operation result, and the scheduled task with the task number equal to the operation result is attributed to this instance. In this way, each scheduled task is evenly distributed to all instances to ensure that a scheduled task will not be repeatedly executed by different instances.

[0067] Here, assume the scheduling platform includes three instances. The sharding parameter is represented by zoneParam, and the instance's sharding index is represented by zoneIndex. zoneParam = 3, and the zoneIndex of the three instances are 1, 2, and 3, respectively. For each instance, the sharding parameter modulo the instance's sharding index is expressed as: schedulId % zoneParam = zoneIdex. Here, schedulId is the result of the modulo operation, and the scheduled task with the task number equal to schedulId is assigned to this instance.

[0068] In an embodiment of the present disclosure, based on the task trigger time of each scheduled task, it is determined whether there is a scheduled task that needs to be executed at present, and the scheduled task that needs to be executed at present is marked as a target scheduled task, including: using each instance to poll its corresponding scheduled tasks, based on the task trigger time of each scheduled task, it is determined whether there is a scheduled task that needs to be executed at present, and the scheduled task that needs to be executed at present is marked as a target scheduled task.

[0069] Generating a task execution request based on the interface call parameters of the target scheduled task includes: generating a task execution request based on the interface call parameters of the target scheduled task marked by each instance.

[0070] In the disclosed embodiment, the scheduling device platform is configured with multiple instances, enabling multiple instances of the scheduling device platform to work in parallel to improve efficiency and reliability. The multi-instance design not only achieves load balancing of scheduled tasks, but also effectively avoids resource competition. Although each instance follows the same logic to identify, schedule, and execute scheduled tasks, they each maintain an independent task list and status information to ensure efficient operation and data consistency. This architecture optimizes the overall performance of the scheduling device platform and enhances the scalability and stability of the scheduling device platform.

[0071] Combine Figure 5 As shown, the embodiment of the present disclosure provides another method for scheduling and executing a scheduled task. The device can execute the method for scheduling and executing a scheduled task by running a scheduling device platform. The method for scheduling and executing a scheduled task includes:

[0072] S501: The device determines the configuration information of the scheduled tasks of each Web service from the service database.

[0073] S502: The device uses each instance to poll the corresponding scheduled tasks, determines whether there is a scheduled task that needs to be executed according to the task trigger time of each scheduled task, and marks the scheduled task that needs to be executed as the target scheduled task.

[0074] S503: The device generates a task execution request by using each instance based on the interface call parameters of the target scheduled task marked by the instance.

[0075] S504: The device sends a task execution request to a target Web service corresponding to the target scheduled task, to instruct the target Web service to execute the target scheduled task.

[0076] In some embodiments, the scheduling platform sets up separate polling processes and scheduling processes. The device can use an instance to execute the polling process to mark the target scheduled task, and use each instance to execute the scheduling process cyclically to generate a task execution request for the target scheduled task.

[0077] The polling process is responsible for regularly checking the scheduled task list under each instance, determining whether there are any tasks that need to be executed based on the task's trigger time, and marking them as target tasks. Because the polling process runs independently, it can continuously monitor task status in the background, ensuring that tasks can be quickly identified once their trigger time has arrived. The scheduling process generates specific task execution requests based on the marked target tasks and sends them to the corresponding web service. Because polling and scheduling are two separate processes, the scheduling process can focus on efficiently generating and sending requests without waiting for polling to complete, thereby improving overall response speed.

[0078] In some embodiments, the configuration information includes an execution status, where the execution status includes executing and executed. Each instance is used to poll its corresponding scheduled tasks, and based on the task trigger time of each scheduled task, it is determined whether there is a scheduled task that needs to be executed, and the scheduled task that needs to be executed is marked as a target scheduled task, including: using each instance to cyclically execute the polling process to mark the target scheduled task.

[0079] The polling process includes the following steps: using each instance to poll its corresponding respective scheduled tasks, and determining whether there is a target scheduled task that needs to be executed currently based on the task triggering time of each scheduled task, including: using scheduled tasks with an execution status of "executed" as candidate scheduled tasks; using each instance to poll its corresponding respective candidate scheduled tasks, and determining whether there is a candidate scheduled task that needs to be executed currently based on the task triggering time of each candidate scheduled task; when a candidate scheduled task that needs to be executed is determined, the execution status of the candidate scheduled task that needs to be executed is modified to "executing", so that it becomes the target scheduled task.

[0080] In some embodiments, after sending the task execution request to the target Web service corresponding to the target scheduled task, it also includes: when it is determined that the target scheduled task is executed successfully, using the instance to which the target scheduled task belongs to modify the execution status of the target scheduled task to executed, making it a candidate scheduled task.

[0081] Each instance independently runs a polling process that regularly checks all scheduled tasks for which it is responsible. This ensures that even in a distributed environment, each instance can effectively manage and schedule its task list. When a task is marked as a target scheduled task, its status changes from "Executed" to "Executing." During the next poll, the instance only monitors scheduled tasks with an "Executed" status, reducing unnecessary computational overhead and enabling quicker identification of tasks requiring re-execution, improving polling efficiency. Once a scheduled task successfully completes, its status is updated to "Executed" again, allowing it to be re-evaluated during the next poll. By introducing the concept of execution status and designing detailed polling and state transition logic, the scheduling platform is able to effectively manage and schedule scheduled tasks. This design not only improves system efficiency and reliability, but also simplifies monitoring and logging, supporting complex and diverse business needs, and ultimately enabling the entire system to maintain efficient and stable operation even under high-load environments.

[0082] In some embodiments, the configuration information includes a lock state, the lock state including locked and unlocked, each instance includes a scheduling process, and the scheduling process has multiple scheduling threads. Using each instance to generate a task execution request based on an interface call parameter of a target scheduled task marked by the instance includes: using each instance to cyclically execute the scheduling process to generate the task execution request of the target scheduled task.

[0083] The scheduling process includes the following steps: using an idle scheduling thread in an instance to query a target scheduled task whose lock state is unlocked; when a target scheduled task whose lock state is unlocked is queried using a scheduling thread, the lock state of the target scheduled task is modified to locked, and a task execution request is generated based on the interface call parameters of the target scheduled task.

[0084] In some embodiments, after sending the task execution request to the target Web service corresponding to the target scheduled task, the method further includes: when determining that the target scheduled task is successfully executed, using the corresponding scheduling thread to modify the lock state of the target scheduled task to unlocked.

[0085] Each idle scheduling thread in the scheduling process will query the list of scheduled tasks it is responsible for, looking for a target scheduled task with a lock status of "unlocked". When a scheduling thread finds a target scheduled task with a lock status of "unlocked", it will immediately change the lock status of the target scheduled task to "locked" to prevent other scheduling threads from processing the scheduled task at the same time. After a scheduling thread locks a target scheduled task, the scheduling thread generates a specific task execution request based on the interface call parameters of the target scheduled task, and sends the task execution request to the corresponding Web service. After receiving the task execution request, the Web service starts to execute the target scheduled task. Once the target scheduled task is executed successfully, the scheduling thread will change the lock status of the target scheduled task back to "unlocked" so that it can re-evaluate whether the target scheduled task needs to be executed again during the next poll.

[0086] By introducing a locking state and utilizing multiple scheduling threads in the scheduling process, the scheduling platform not only improves the efficiency and reliability of task processing but also enhances scalability and flexibility. The locking mechanism effectively avoids resource contention and duplicate task execution, while parallel processing significantly improves system throughput and responsiveness. Furthermore, clear task status management and detailed logging greatly simplify system maintenance and monitoring. These technical benefits combine to enable the entire system to maintain efficient and stable operation even in the face of large-scale scheduled tasks.

[0087] In some embodiments, the Web service returns a success notification after completing the target scheduled task. When the device receives the success notification returned by the Web service, it determines that the target scheduled task has been successfully executed.

[0088] Optionally, when the device receives a success notification returned by the Web service and the difference between the actual execution duration of the target scheduled task and the normal execution duration is not greater than a safety duration threshold, it is determined that the target scheduled task is successfully executed.

[0089] Optionally, when the device receives a success notification returned by the Web service and the actual execution duration of the target scheduled task does not exceed the normal execution duration, it is determined that the target scheduled task is executed successfully.

[0090] In some embodiments, after sending the task execution request to the target Web service corresponding to the target scheduled task, the method further includes: executing a preset fault tolerance measure when determining that the target scheduled task fails to execute.

[0091] In some embodiments, when the Web service fails to execute the target scheduled task, it may return a failure notification. When the device receives the failure notification returned by the Web service, it determines that the target scheduled task has failed to execute.

[0092] In some embodiments, when the difference between the actual execution duration of the target scheduled task and the normal execution duration is greater than the safety duration threshold, the device has not received a success notification returned by the Web service and determines that the target scheduled task has failed to execute.

[0093] In the embodiment of the present disclosure, the fault tolerance measures may include retry and alarm. The configuration information may include the contact information of the alarm recipient (such as email address and mobile phone number).

[0094] In some embodiments, when the number of execution failures of the target scheduled task does not reach a preset failure threshold, the device performs a retry measure, wherein the retry measure includes resending the task execution request to the target Web service corresponding to the target scheduled task.

[0095] In some embodiments, when the number of failed executions of the target scheduled task reaches a preset failure threshold, the device executes an alarm measure, which includes sending a reminder message of the scheduled task failure to the alarm recipient based on the alarm recipient's contact information.

[0096] Combine Figure 6 As shown, the embodiment of the present disclosure provides another method for scheduling and executing a scheduled task. A device can execute the method by running a scheduling device platform. The method is implemented based on an instance of the scheduling device platform. The instance synchronously executes the polling process and the scheduling process. The method includes the following steps:

[0097] S601a: The device selects scheduled tasks with an execution status of "executed" as candidate scheduled tasks.

[0098] In the embodiment of the present disclosure, the execution status of the scheduled task is initially set to "executed". Here, the value of scheduleStatus can be used to represent the execution status of the scheduled task. When the value of scheduleStatus is 2, it indicates that the execution status of the scheduled task is "executed".

[0099] S602a: The device polls each candidate scheduled task corresponding to the instance, and determines whether there is a candidate scheduled task that needs to be executed according to the task triggering time of each candidate scheduled task.

[0100] When the device determines the candidate scheduled task to be executed, S503 is executed; when the device does not determine the candidate scheduled task to be executed, the process returns to S501.

[0101] S603a: The device changes the execution status of the candidate scheduled task to be executed to "in progress", making it a target scheduled task.

[0102] In the embodiment of the present disclosure, when the value of scheduleStatus is 1, it indicates that the execution status of the scheduled task is in progress. Here, the scheduleStatus of the candidate scheduled task is modified to 1, making it the target scheduled task.

[0103] After S603a, the process returns to S601a. ​​When it is determined that the target scheduled task is successfully executed, S604a may also be executed simultaneously.

[0104] S604a: When the device determines that the target scheduled task is successfully executed, it changes the execution status of the target scheduled task to executed, making it a candidate scheduled task.

[0105] In the embodiment of the present disclosure, the scheduleStatus of the candidate scheduled task is modified to 2, making it a candidate scheduled task.

[0106] After S604a, the process returns to S601a.

[0107] S601b: The device uses an idle scheduling thread in the instance to query the target scheduled task whose lock status is unlocked.

[0108] In the embodiment of the present disclosure, the lock state of the scheduled task is initially defaulted to unlocked. Here, the value of lockStatus can be used to represent the lock state of the scheduled task. When the value of lockStatus is 2, it indicates that the lock state of the scheduled task is unlocked.

[0109] S602b: When the device uses a scheduling thread to query a target scheduled task whose lock status is unlocked, the device changes the lock status of the target scheduled task to locked.

[0110] In the embodiment of the present disclosure, when the value of lockStatus is 1, it indicates that the lock status of the scheduled task is locked. Here, the lockStatus of the target scheduled task is modified to 1, so that its lock status is changed to locked.

[0111] S603b: The device generates a task execution request based on the interface call parameters of the target scheduled task.

[0112] After S603b, the process returns to S601b. When it is determined that the target scheduled task is successfully executed, S604b may also be executed simultaneously. When it is determined that the target scheduled task fails to execute, S605b may also be executed simultaneously.

[0113] S604b: When the device determines that the target scheduled task is executed successfully, it uses the corresponding scheduling thread to modify the lock state of the target scheduled task to unlocked.

[0114] In the embodiment of the present disclosure, the lockStatus of the target scheduled task is modified to 2, so that its locking status is changed to unlocked.

[0115] After S604b, the process returns to S601b.

[0116] S605b: When the device determines that the target scheduled task has failed to execute, it executes a preset fault tolerance measure. In some embodiments, the Web service returns a failure notification when the target scheduled task has not been successfully executed. When the device receives the failure notification returned by the Web service, it determines that the target scheduled task has failed to execute.

[0117] In some embodiments, when the difference between the actual execution duration of the target scheduled task and the normal execution duration is greater than the safety duration threshold, the device has not received a success notification returned by the Web service and determines that the target scheduled task has failed to execute.

[0118] In some embodiments, when the number of execution failures of the target scheduled task does not reach a preset failure threshold, the device performs a retry measure, wherein the retry measure includes resending the task execution request to the target Web service corresponding to the target scheduled task.

[0119] In some embodiments, when the number of failed executions of the target scheduled task reaches a preset failure threshold, the device executes an alarm measure, which includes sending a reminder message of the scheduled task failure to the alarm recipient based on the alarm recipient's contact information.

[0120] In some embodiments, when the number of execution failures of the target scheduled task reaches a preset failure threshold, the scheduleStatus of the target scheduled task is modified to -1 to indicate that the execution has failed.

[0121] Combine Figure 7 As shown, an embodiment of the present disclosure provides an electronic device 700, which includes a processor 701 and a memory 702. Optionally, the device 700 may further include a communication interface 703 and a bus 704. The processor 701, the communication interface 703, and the memory 702 may communicate with each other through the bus 704. The communication interface 703 may be used for information transmission. The processor 701 may call the logic instructions in the memory 702 to execute the timed task scheduling execution method of the above embodiment. In addition, the logic instructions in the above-mentioned memory 702 may be implemented in the form of a software functional unit and may be stored in a computer-readable storage medium when sold or used as an independent product.

[0122] Memory 702, as a computer-readable storage medium, can be used to store software programs and computer-executable programs, such as program instructions / modules corresponding to the methods in the embodiments of the present disclosure. Processor 701 executes the program instructions / modules stored in memory 702 to execute functional applications and data processing, thereby implementing the scheduled task scheduling execution method in the above-mentioned embodiments.

[0123] The memory 702 may include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data generated based on the use of the terminal device. Furthermore, the memory 702 may include high-speed random access memory and non-volatile memory.

[0124] An embodiment of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured to execute the above-mentioned scheduled task scheduling execution method.

[0125] The technical solutions of the embodiments of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes one or more instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the embodiments of the present disclosure. The aforementioned storage medium may be a non-transitory storage medium, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, among other media capable of storing program code.

[0126] The above description and the accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent only possible variations. Unless explicitly required, individual components and functions are optional, and the order of operations may vary. Parts and features of some embodiments may be included in or replace parts and features of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to also include plural forms. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of one or more associated listings. In addition, when used in this application, the term "comprise" and its variations "comprises" and / or comprising refer to the presence of stated features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups of these. In the absence of further restrictions, an element defined by the sentence "comprising a..." does not exclude the presence of other identical elements in the process, method or device that includes the element. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the embodiments can be referred to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can be referred to the description of the method part.

[0127] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. The technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. The technicians will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0128] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices, equipment, etc.) can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units can be merely a logical functional division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, and can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected to implement this embodiment according to actual needs. In addition, the functional units in the embodiments of the present disclosure may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0129] The flowcharts and block diagrams in the accompanying drawings show the possible implementation architectures, functions and operations of the systems, methods and computer program products according to the embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment or part of the code, and the module, program segment or part of the code contains one or more executable instructions for implementing the specified logical functions. In some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, or they can sometimes be executed in the opposite order, which can depend on the functions involved. In the descriptions corresponding to the flowcharts and block diagrams in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in an order different from that disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, or they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified function or action, or may be implemented by a combination of dedicated hardware and computer instructions.

Claims

1. A method for scheduling and executing a scheduled task, characterized in that: Methods include: Determine the configuration information of the scheduled tasks of each Web service from the service database; According to the configuration information of each scheduled task, determine the target scheduled task that needs to be executed and generate a task execution request; The task execution request is sent to the target Web service corresponding to the target scheduled task to instruct the target Web service to execute the target scheduled task.

2. The method for scheduling and executing scheduled tasks according to claim 1, wherein: Configuration information includes task triggering time and interface call parameters. Based on the configuration information of each scheduled task, the target scheduled task to be executed is determined and a task execution request is generated, including: According to the task trigger time of each scheduled task, determine whether there is a scheduled task that needs to be executed at present, and mark the scheduled task that needs to be executed at present as the target scheduled task; Generates a task execution request based on the interface call parameters of the target scheduled task.

3. The method for scheduling and executing scheduled tasks according to claim 2, wherein: Each scheduled task is assigned to a corresponding instance; Determining whether there is a scheduled task that needs to be executed currently based on the task trigger time of each scheduled task, and marking the scheduled task that needs to be executed currently as a target scheduled task, including: polling each corresponding scheduled task of each instance, determining whether there is a scheduled task that needs to be executed currently based on the task trigger time of each scheduled task, and marking the scheduled task that needs to be executed currently as a target scheduled task; Generating a task execution request based on the interface call parameters of the target scheduled task includes: generating a task execution request based on the interface call parameters of the target scheduled task marked by each instance.

4. The method for scheduling and executing scheduled tasks according to claim 3, wherein: The configuration information includes the task number. The relationship between the instance and the scheduled task is determined based on the total number of instances, the instance sequence number, and the task number of the scheduled task.

5. The method for scheduling and executing scheduled tasks according to claim 3, wherein: Configuration information includes execution status, which includes executing and executed; Utilize each instance to poll its corresponding scheduled tasks, determine whether there is a scheduled task that needs to be executed according to the task trigger time of each scheduled task, and mark the scheduled task that needs to be executed as the target scheduled task, including: using each instance to cyclically execute the polling process to mark the target scheduled task, wherein the polling process includes the following steps: Use each instance to poll its corresponding scheduled tasks and determine whether there is a target scheduled task that needs to be executed based on the task trigger time of each scheduled task, including: The scheduled tasks whose execution status is "executed" are selected as candidate scheduled tasks; Use each instance to poll its corresponding candidate scheduled tasks, and determine whether there are candidate scheduled tasks that need to be executed according to the task trigger time of each candidate scheduled task; When a candidate scheduled task to be executed is determined, the execution state of the candidate scheduled task to be executed is modified to being executed, so that the candidate scheduled task becomes a target scheduled task.

6. The method for scheduling and executing scheduled tasks according to claim 3, wherein: After sending the task execution request to the target Web service corresponding to the target scheduled task, the method further includes: when determining that the target scheduled task is executed successfully, using the instance to which the target scheduled task belongs to modify the execution state of the target scheduled task to executed, making it a candidate scheduled task.

7. The method for scheduling and executing scheduled tasks according to claim 3, wherein: The configuration information includes a locking state, the locking state includes locked and unlocked, each instance includes a scheduling process, and the scheduling process has multiple scheduling threads; Using each instance based on the interface call parameters of the target scheduled task marked by the instance to generate a task execution request, including: using each instance to cyclically execute a scheduling process to generate the task execution request of the target scheduled task, wherein the scheduling process includes the following steps: Use the idle scheduling thread in the instance to query the target scheduled task whose lock status is unlocked; When a target scheduled task with an unlocked lock state is found by querying using a scheduling thread, the lock state of the target scheduled task is modified to locked, and a task execution request is generated based on the interface call parameters of the target scheduled task.

8. The method for scheduling and executing scheduled tasks according to claim 7, wherein: After sending the task execution request to the target Web service corresponding to the target scheduled task, the method further includes: when determining that the target scheduled task is executed successfully, using the corresponding scheduling thread to modify the locking state of the target scheduled task to unlocked.

9. The method for scheduling and executing scheduled tasks according to claim 7, wherein: After sending the task execution request to the target Web service corresponding to the target scheduled task, the method further includes: executing a preset fault tolerance measure when determining that the target scheduled task fails to execute.

10. An electronic device comprising a processor and a memory storing program instructions, characterized in that: The processor is configured to execute the scheduled task scheduling execution method according to any one of claims 1 to 9 when running program instructions.