Task scheduling method and device based on scheduling rule configuration and storage medium
By using a task scheduling method based on scheduling rules, business events are directly received and parsed, and task execution requirements are automatically determined. This solves the problem that traditional task scheduling frameworks cannot respond to business events and simplifies the task scheduling response process.
Patent Information
- Application Number
- CN202610011358.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-06
- Publication Date
- 2026-05-19
AI Technical Summary
Traditional task scheduling frameworks cannot respond to business events, resulting in complex task scheduling responses, requiring the introduction of additional event detection logic and mechanisms.
A task scheduling method based on scheduling rule configuration is adopted. The trigger module directly receives status change information and compares it with the scheduling rule configuration in real time. The trigger instance automatically parses the event characteristics, determines whether the task execution requirements are met, and executes the scheduled task through the scheduler module.
It enables event-driven triggering as a native capability of the scheduling system, simplifies the task scheduling response process, eliminates the bypass problem of additional event detection logic, and improves response efficiency.
Smart Images

Figure CN122064436A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a task scheduling method, device and storage medium based on scheduling rule configuration. Background Technology
[0002] As enterprise applications become increasingly complex, task scheduling systems play an increasingly important role in modern software architectures. Especially with the widespread adoption of microservices and event-driven architectures, systems need to efficiently handle real-time task triggering and execution based on business state changes such as order payments, inventory alerts, and user behavior. Traditional task scheduling frameworks are primarily designed around a time-driven model, triggering tasks at preset times or periodically. This fails to respond to business event triggers, requiring developers to introduce message queues, custom event monitors, or webhook mechanisms specifically for capturing business state changes. Upon receiving an event, the event monitor must call the scheduling framework's API, such as Quartz's `triggerJob` method, to start the task, creating an indirect process of event detection and manual scheduling triggering, resulting in complex task scheduling responses.
[0003] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0004] The main purpose of this application is to provide a task scheduling method, device and storage medium based on scheduling rule configuration, which aims to solve the technical problem of complex task scheduling response in existing task scheduling frameworks.
[0005] To achieve the above objectives, this application proposes a task scheduling method based on scheduling rule configuration, applied to a task scheduling system. The task scheduling system includes a trigger module and a scheduler module. The task scheduling method based on scheduling rule configuration includes: When a trigger instance in the trigger module receives a status change message sent by the client, it compares the status change message with the trigger conditions in the scheduling rule configuration to determine whether the current status change meets the task execution requirements. After the trigger instance determines that the task execution requirements are met, it updates its own running data and sends the running data and the task identifier to the scheduler module. After the scheduler module receives the task identifier, it queries and obtains the corresponding scheduling task logic from the task management container based on the task identifier, and passes its own running data and the status change information as task parameters to the scheduling task logic to execute the scheduling task.
[0006] In one embodiment, the self-running data includes the number of times it has been triggered, the remaining number of executions, and the current system time; the step of updating the self-running data and sending the self-running data and the task identifier to the scheduler module after the trigger instance determines that the task execution requirements are met includes: After the trigger instance determines that the task execution requirements are met, the number of times it has been triggered is incremented by 1, the number of remaining execution times is decremented by 1, and the last trigger time is updated to the current system time. The number of times the task has been triggered and the task identifier are sent to the scheduler module.
[0007] In one embodiment, the task scheduling system further includes a persistent storage module. Before the step of comparing the state change information with the trigger conditions in the scheduling rule configuration to determine whether the current state change meets the task execution requirements when the trigger instance in the trigger module receives state change information sent by the client, the system further includes: When the scheduler module receives the registration request initiated by the client, it creates the trigger instance in the trigger module according to the scheduling rules configured in the registration request. Once the trigger instance is successfully created, the trigger instance registers the corresponding scheduling task according to the trigger type configured in the scheduling rule. After the registration and scheduling task is successful, the scheduler module associates the trigger instance with the corresponding instance identifier and stores it in the trigger management container, and saves the scheduling rule configuration associated with the trigger instance and its own running data as trigger instance data to the persistent storage module.
[0008] In one embodiment, the task scheduling system further includes an event monitoring module. The step of registering the corresponding scheduled task according to the trigger type configured in the scheduling rules after the trigger instance is successfully created includes: If the trigger type is time-based, the trigger conditions and remaining execution counts in the scheduling rule configuration are sent to a third-party scheduler, and the corresponding timed scheduling task is registered through the third-party scheduler. If the trigger type is event-based, then the corresponding event scheduling task is registered in the event monitoring module and bound to the corresponding event type.
[0009] In one embodiment, after the step of registering the corresponding scheduled task according to the trigger type configured in the scheduling rule after the trigger instance is successfully created, the method further includes: After the trigger instance registers a scheduling task, the first theoretical number of triggers from the start time to the current system time is determined according to the start time and triggering conditions in the scheduling rule configuration. Once the trigger instance determines the first theoretical trigger count, it determines the number of lost tasks based on the difference between the first theoretical trigger count and the number of triggered tasks, and executes compensation tasks according to the loss compensation strategy in the scheduling rule configuration based on the number of lost tasks. After the trigger instance completes the compensation task, it updates its own running data.
[0010] In one embodiment, the task scheduling system further includes a persistent storage module. After the scheduler module receives the task identifier, queries and retrieves the corresponding scheduling task logic from the task management container based on the task identifier, and passes its own running data and the status change information as task parameters to the scheduling task logic to execute the scheduling task, the system further includes: When the server restarts, the scheduler module reads all saved trigger instance data from the persistent storage module, determines the instance identifier from the trigger instance data, and calls the recovery interface based on the instance identifier to associate the corresponding instance template to restore the trigger instance. Once the trigger instance is successfully restored, the second theoretical number of triggers from the last trigger time to the current system time is determined according to the trigger frequency in the scheduling rule configuration of the trigger instance. Once the trigger instance determines the second theoretical trigger count, it determines the number of lost tasks to be restarted based on the difference between the second theoretical trigger count and the number of triggered tasks in the trigger instance data, and executes compensation tasks according to the loss compensation strategy in the scheduling rule configuration based on the number of lost tasks to be restarted. After the trigger instance completes the compensation task, it updates its own running data.
[0011] In one embodiment, the task scheduling system further includes a persistent storage module. After the scheduler module receives the task identifier, queries and retrieves the corresponding scheduling task logic from the task management container based on the task identifier, and passes its own running data and the status change information as task parameters to the scheduling task logic to execute the scheduling task, the system further includes: After the trigger instance finishes executing the compensation task or the scheduling task, it is determined whether the current remaining number of executions is 0 or whether the scheduling termination condition in the scheduling rule configuration is met. If the current remaining execution count is 0 or the scheduling termination condition in the scheduling rule configuration is met, the trigger instance sends a completion signal and instance identifier to the scheduler module; When the scheduler module receives the completion signal and the instance identifier, it searches for the corresponding instance in the trigger management container according to the instance identifier, and deletes the instance and the instance data associated with the instance from the persistent storage module.
[0012] In one embodiment, the task scheduling system further includes a channel push module, and the task scheduling method based on scheduling rules configuration includes: When the channel push module receives user event data sent by the client, it calls the interface provided by the scheduler module to encapsulate the user event data into a scheduling rule and send it to the scheduler module. The user event data includes user identifier, event content and event time offset. When the scheduler module receives the scheduling rule, it creates a timed push task according to the scheduling rule, wherein the task trigger time of the timed push task is the current time plus the event time offset; When the scheduled push task is triggered, the channel push module queries the target channel and push authorization credential corresponding to the user identifier from the active user pool of the persistent storage module according to the user identifier, encapsulates the event content according to the protocol format of the target channel, carries the push authorization credential, calls the event reporting interface provided by the target channel, and initiates an event push request.
[0013] In addition, to achieve the above objectives, this application also proposes a task scheduling device based on scheduling rule configuration, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the task scheduling method based on scheduling rule configuration as described above.
[0014] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the task scheduling method based on scheduling rule configuration as described above.
[0015] This application provides a task scheduling method based on scheduling rule configuration, applied to a task scheduling system. The task scheduling system includes a trigger module and a scheduler module. When a trigger instance in the trigger module receives state change information sent by a client, it compares the state change information with the trigger conditions in the scheduling rule configuration to determine whether the current state change meets the task execution requirements. After determining that the task execution requirements are met, the trigger instance updates its own running data and sends its own running data and task identifier to the scheduler module. After receiving the task identifier, the scheduler module queries and retrieves the corresponding scheduling task logic from the task management container based on the task identifier, and passes its own running data and state change information as task parameters to the scheduling task logic to execute the scheduling task.
[0016] The method described above directly receives state change information sent by the client through trigger instances in the trigger module and compares it in real time with the predefined trigger conditions in the scheduling rule configuration. This makes the event itself the core signal for task triggering, rather than relying on a fixed point in time. When the business state changes, the trigger instance automatically parses the event characteristics and determines whether the execution requirements are met, thus achieving a direct mapping from event to task. This eliminates the need for additional event detection logic in traditional frameworks, making event-driven triggering a native capability of the scheduling system and simplifying the task scheduling response process. Attached Figure Description
[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a flowchart illustrating an embodiment of the task scheduling method based on scheduling rules in this application. Figure 2 This is a flowchart illustrating Embodiment 2 of the task scheduling method based on scheduling rules in this application; Figure 3 This is a flowchart illustrating Embodiment 3 of the task scheduling method based on scheduling rules in this application; Figure 4 This is a schematic diagram of the trigger instance registration and scheduling task triggering process of the task scheduling method based on scheduling rule configuration provided in Embodiment 3 of this application; Figure 5This is a flowchart illustrating Embodiment 4 of the task scheduling method based on scheduling rules in this application; Figure 6 This is a flowchart illustrating Embodiment 5 of the task scheduling method based on scheduling rules in this application; Figure 7 This is a schematic diagram of the crash recovery process of the task scheduling method based on scheduling rule configuration provided in Embodiment 5 of this application; Figure 8 This is a flowchart illustrating Embodiment Six of the task scheduling method based on scheduling rules in this application; Figure 9 This is a schematic diagram of the device structure of the hardware operating environment involved in the task scheduling method based on scheduling rules in the embodiments of this application.
[0020] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0021] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of this application and are not intended to limit this application.
[0022] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific embodiments. It should be noted that all actions involving the acquisition of signals, information, or data in this application are performed in accordance with the relevant data protection laws and regulations of the country where the application is located, and with authorization from the owner of the corresponding device.
[0023] As enterprise applications become increasingly complex, task scheduling systems play an increasingly important role in modern software architectures. Especially with the widespread adoption of microservices and event-driven architectures, systems need to efficiently handle real-time task triggering and execution based on business state changes such as order payments, inventory alerts, and user behavior. Traditional task scheduling frameworks are primarily designed around a time-driven model, triggering tasks at preset times or periodically. This fails to respond to business event triggers, requiring developers to introduce message queues, custom event monitors, or webhook mechanisms specifically for capturing business state changes. Upon receiving an event, the event monitor must call the scheduling framework's API, such as Quartz's `triggerJob` method, to start the task, creating an indirect process of event detection and manual scheduling triggering, resulting in complex task scheduling responses.
[0024] In view of the above problems, this application proposes a task scheduling method based on scheduling rule configuration, applied to a task scheduling system. The task scheduling system includes a trigger module and a scheduler module. When a trigger instance in the trigger module receives state change information sent by the client, the method compares the state change information with the trigger conditions in the scheduling rule configuration to determine whether the current state change meets the task execution requirements. After the trigger instance determines that the task execution requirements are met, it updates its own running data and sends its own running data and task identifier to the scheduler module. After the scheduler module receives the task identifier, it queries and obtains the corresponding scheduling task logic from the task management container based on the task identifier, and passes its own running data and state change information as task parameters to the scheduling task logic to execute the scheduling task.
[0025] The method described above directly receives state change information sent by the client through trigger instances in the trigger module and compares it in real time with the predefined trigger conditions in the scheduling rule configuration. This makes the event itself the core signal for task triggering, rather than relying on a fixed point in time. When the business state changes, the trigger instance automatically parses the event characteristics and determines whether the execution requirements are met, thus achieving a direct mapping from event to task. This eliminates the need for additional event detection logic in traditional frameworks, making event-driven triggering a native capability of the scheduling system and simplifying the task scheduling response process.
[0026] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or task scheduling system capable of performing the above functions. The following description uses a task scheduling system as an example to illustrate this embodiment and the subsequent embodiments.
[0027] For example, the task scheduling function of the above task scheduling system is mainly implemented by a trigger module, a scheduler module, and a channel push module.
[0028] The trigger module contains trigger instances, which are the concrete executors of the rules. They internally store rule information and trigger counts, and are responsible for implementing the core logic of task scheduling. Trigger instances include time-based trigger instances and event-based trigger instances. Their main functions include: Scheduling registration involves parsing scheduling rule configurations and registering scheduling tasks based on trigger types. Scheduling recovery is used to automatically calculate the number of lost tasks after a server restart and rebuild the schedule. This includes determining the second theoretical number of triggers from the last trigger time to the current system time based on the trigger frequency, determining the number of lost tasks, and executing compensation tasks according to compensation strategies such as no compensation, one compensation, or full compensation. It also involves calculating the new start time and remaining execution count of subsequent scheduled tasks using the second theoretical number of triggers, the number of triggers already triggered, and the start time, and creating the necessary subsequent scheduled tasks with the help of a third-party scheduler. Trigger a judgment to determine whether the current conditions meet the task execution requirements. Event-type trigger instances need to implement this judgment method themselves. Schedule execution to execute the triggered task logic; The state change interface allows external systems to call this interface to pass state change information when the business state changes. The trigger instance compares the changed state with the scheduling rule configuration. If the task execution requirements are met, the scheduled task is executed. The scheduler module is the core management component of the entire task scheduling system, and its main functions include: Manage trigger instances and their corresponding scheduled tasks; Maintain the persistence of trigger instances; Configuration persistence is achieved by periodically writing the runtime data of the trigger instance to the persistent storage module. The persistent storage module is an independent module responsible for persistently saving the data related to the trigger instance. It supports data writing, reading and updating, and ensures that data is not lost after system crash or restart. Provides a unified trigger operation interface to external users.
[0029] The channel push module relies on the scheduler module to implement its business functions, and its main functions include: User access involves accessing user login data from the client to form a pool of active game users.
[0030] Push task generation defines an event push interface for client access. After the client calls it, a one-time trigger is registered in the scheduler module to generate a scheduled push task. Channel push: When a scheduled push task is triggered, the system finds the corresponding user in the active user pool based on the user identifier and channel identifier attached to the task, obtains the push authorization credentials required for the user to push to the corresponding channel, and then pushes the event content.
[0031] Data landing and analysis: When a user triggers an event push, a data point of the push result is recorded, and corresponding reports are generated based on the push channel and time distribution for the operations side to analyze.
[0032] Based on this, the first embodiment of this application provides a task scheduling method based on scheduling rule configuration, applied to the above-mentioned task scheduling system, with reference to... Figure 1 In this embodiment, the task scheduling method based on scheduling rules configuration includes steps S10 to S30: Step S10: When the trigger instance in the trigger module receives the status change information sent by the client, it compares the status change information with the trigger conditions in the scheduling rule configuration to determine whether the current status change meets the task execution requirements.
[0033] The trigger module in the task scheduling system is responsible for managing trigger instances, receiving client state change information, and determining trigger conditions. It serves as the hub connecting business status and scheduled execution. A trigger instance is an executable object generated based on specific scheduling rule configurations. It carries dedicated scheduling rule metadata and runtime data, and is the main body for trigger condition determination and runtime data updates. State change information is generated by changes in the client's own business status, containing core data such as business status characteristics, change time, and associated business identifiers. It is the prerequisite signal for triggering scheduled tasks. The scheduling rule configuration is a set of pre-set task execution conditions by the client, including rule metadata such as trigger type, compensation strategy, task type and start time, trigger frequency, maximum number of executions, and scheduling termination conditions.
[0034] For example, a trigger instance receives state change information from the client, performs structured parsing on the information, extracts state feature dimensions such as business type, change level, and associated object attributes, and verifies the completeness and legality of the information, removing invalid or incorrectly formatted fields to obtain standardized, structured state change feature data. Next, the trigger instance extracts the feature dimensions and thresholds of the trigger conditions from the scheduling rule configuration, and assigns corresponding weight values to each trigger condition feature dimension based on the system's preset feature weight table, resulting in a weighted trigger condition feature set. The weight values can be dynamically adjusted according to the importance of the business scenario. The trigger instance compares the state change feature data with the trigger condition feature set dimension by dimension, weighting the matching results of each dimension according to the weight values to obtain an overall matching score. The matching score is then compared with the preset matching threshold in the scheduling rule configuration. If the matching score is greater than or equal to the matching threshold, the task execution requirements are met; if the matching score is less than the matching threshold, the task execution requirements are not met, and the current scheduling process is terminated.
[0035] Step S20: After the trigger instance determines that the task execution requirements are met, it updates its own running data and sends the running data and task identifier to the scheduler module.
[0036] Optionally, the trigger instance's own runtime data includes the number of times it has been triggered, the remaining number of executions, and the current system time.
[0037] The number of times the trigger instance has been triggered refers to the cumulative number of times the trigger condition has been met and the scheduled task has been executed since the instance was created. The initial value is 0. The remaining execution count is the maximum number of executions configured according to the scheduling rules, or an infinite repetition indicator. It represents the number of tasks that the trigger instance has not yet executed; the initial value is determined by the scheduling rules. The last trigger time is the system time recorded when the trigger instance last met the trigger condition and updated its own running data; the initial value is null. The current system time is the current real-time system time obtained when the trigger instance performs a data update operation.
[0038] Step S20 above includes steps S21 to S22: Step S21: After the trigger instance determines that the task execution requirements are met, increment the number of times it has been triggered by 1, decrement the remaining number of executions by 1, and update the last trigger time to the current system time.
[0039] Step S22: Send the number of times the task has been triggered and the task identifier to the scheduler module.
[0040] For example, once the trigger instance confirms that the task execution requirements are met, it increments the current number of triggers by 1 and decrements the remaining execution count by 1. Optionally, the trigger instance can first determine whether the upper limit of execution count configured in the scheduling rule has an infinite repetition flag. If it has infinite repetition, the remaining execution count remains unchanged; if it has a finite number of executions, the remaining execution count is decremented by 1. Then, the trigger instance obtains the high-precision current system time through the system's underlying interface and updates the previous trigger time to the current system time.
[0041] After the trigger instance updates its own running data, it filters the key data necessary for the scheduler module to execute the task, such as the number of times it has been triggered and the task identifier. It then encapsulates the number of times it has been triggered and the task identifier according to a preset standardized data format and sends it to the scheduler module. This allows the scheduler module to quickly parse and extract the task identifier and accurately locate the corresponding scheduling task logic in the task management container or local cache to execute the corresponding scheduling task.
[0042] Step S30: After the scheduler module receives the task identifier, it queries and obtains the corresponding scheduling task logic from the task management container based on the task identifier, and passes the self-run data and the status change information as task parameters to the scheduling task logic to execute the scheduling task.
[0043] It should be noted that the task management container is the carrier in the scheduler module that stores the mapping relationship between all scheduled task logic and task identifiers, enabling quick querying and retrieval of scheduled task logic. The scheduled task logic is the execution logic that implements specific business functions; it is the core business carrier of the scheduled task, receiving parameters and completing the corresponding business operations.
[0044] For example, the scheduler module parses the received task identifier, extracting feature information such as task type and version number; it then queries the local task management container to determine the scheduling task logic corresponding to the task identifier. Next, the scheduler module parses the parameter requirement definition of the scheduling task logic, classifies and maps the trigger instance's own runtime data and the status change information sent by the client according to parameter type, and standardizes the parameter format; it generates a standardized parameter set that meets the parameter requirements of the scheduling task logic, and then injects the standardized parameter set into the scheduling task logic to start the scheduling task execution process.
[0045] Optionally, during the execution of a scheduled task, the scheduler module can also monitor the execution status of the scheduled task in real time and record execution logs, including the execution start time, execution node, execution result, etc. After the execution is completed, the execution result can be fed back to the trigger instance, and the task execution status in the task management container can be updated at the same time.
[0046] This embodiment abstracts scheduling logic into a unified scheduling rule configuration, replacing the multi-layered complex configurations of traditional frameworks such as JobDetail and Trigger components. Trigger instances automatically update runtime data based on the scheduling rule configuration and interact with the scheduler module through lightweight data transmission, reducing redundant configuration overhead, making scheduling behavior more intuitive, and lowering the learning cost for developers and the difficulty of system maintenance. Furthermore, this embodiment manages task logic through a unified scheduler module, seamlessly connecting event triggering with task execution. State change information is directly passed as parameters to the scheduling task logic, ensuring the integrity of the business context and avoiding the multi-system splicing problem caused by the separation of event handling and scheduling systems in traditional solutions. This improves resource utilization efficiency and is suitable for scenarios requiring real-time response.
[0047] Based on the first embodiment of this application, in the second embodiment of this application, the task scheduling system further includes a persistent storage module. Please refer to [link / reference needed] for details. Figure 2 Before step S30, the task scheduling method based on scheduling rule configuration further includes steps S40 to S60: Step S40: After the scheduler module receives the registration request initiated by the client, it creates the trigger instance in the trigger module according to the scheduling rules configured in the registration request.
[0048] The client initiates a registration request to the scheduler module to create a trigger instance and register the scheduled task, including core information such as scheduling rule configuration and task identifier. Upon receiving the registration request, the scheduler module performs structured parsing, extracting the core fields of the scheduling rule configuration, including trigger type, compensation strategy, task type and start time, trigger frequency, maximum execution count, and scheduling termination conditions. Simultaneously, it verifies the legality of the registration request, including whether the request signature is valid, whether the client permissions match, and whether any core fields are missing. If the verification passes, the scheduler module matches the corresponding instance template in the trigger type template library based on the trigger type in the scheduling rule configuration, extracts the instance's basic attributes and initialization rules defined in the instance template, sends an instance creation instruction to the trigger module, and transmits the instance template and scheduling rule configuration. The trigger type, defined in the scheduling rule configuration, is the task triggering method, such as time-based or event-based, which determines the specific method by which the trigger instance registers the scheduled task. The trigger module initializes the basic attributes of the instance based on the instance template, encapsulates the scheduling rule configuration data into the instance, initializes its own running data, sets the number of triggered times to 0, assigns the remaining number of execution times according to the configuration, sets the last trigger time to null, and generates a unique trigger instance object.
[0049] Step S50: After the trigger instance is successfully created, the trigger instance registers the corresponding scheduling task according to the trigger type configured in the scheduling rule.
[0050] Trigger instances register corresponding scheduled tasks based on their trigger types, enabling the instances to receive trigger signals and execute tasks.
[0051] Optionally, if the trigger type is time-based, the trigger conditions and remaining execution counts in the scheduling rule configuration are sent to a third-party scheduler, and the corresponding timed scheduling task is registered through the third-party scheduler.
[0052] Time-based triggering refers to a method of triggering task execution based on preset time conditions such as Cron expressions, fixed intervals, or specified time points, relying on a third-party scheduler to achieve precise control of time nodes. The third-party scheduler is an external component with mature time scheduling capabilities, such as Quartz, responsible for receiving time-based trigger parameters, monitoring time nodes, and sending trigger signals, providing reliable timed scheduling support for the system.
[0053] The trigger instance extracts time-based trigger core parameters from the scheduling rule configuration, such as trigger conditions like Cron expressions, intervals, start / end times, and remaining execution counts. Based on the parameter formats supported by the third-party scheduler, it adapts and converts the extracted parameters, such as converting system timestamps to a date format recognized by the third-party scheduler and validating Cron expression syntax and converting it to a standard format, generating standardized registration parameters that meet the requirements of the third-party scheduler. Through a pre-defined communication protocol with the third-party scheduler, such as RPC or HTTP, it initiates a scheduled task registration request, transmitting the standardized registration parameters along with its own callback interface address. The callback interface address is used by the third-party scheduler to send a trigger signal to the trigger instance when the time node is reached. Meanwhile, the trigger instance receives the registration receipt from the third-party scheduler, verifies the completeness of the receipt (e.g., whether it contains core fields such as the registration task identifier and the effective status) and its validity (e.g., whether the effective status indicates successful registration). If the registration is successful, the instance binds and stores the registration task identifier returned by the third-party scheduler with its own instance for subsequent task modification, cancellation, and other operations. If the registration fails, the instance records the reason for the failure (e.g., incorrect parameters, insufficient resources of the third-party scheduler) and triggers a retry mechanism. If the retry fails, the registration process is terminated and an exception is reported.
[0054] Optionally, if the trigger type is event-based, the corresponding event scheduling task is registered in the event monitoring module and bound to the corresponding event type.
[0055] Event-driven triggering refers to a method of triggering task execution based on specific business events such as status changes, data updates, and external signals, relying on the event monitoring module to capture event signals. The event monitoring module is responsible for monitoring and capturing various business events in the system, supporting event registration and event signal distribution, and is the core carrier for receiving trigger signals for event-driven triggering tasks. Event types are identifiers used to distinguish different business events, such as order payment events and inventory warning events. Event scheduling tasks achieve precise monitoring of target events by binding event types.
[0056] For example, the trigger instance extracts the event type and triggering conditions, such as the target value for state changes and the threshold for data updates, from the scheduling rule configuration; it queries the system event type registry to verify whether the extracted event type is a legal event type supported by the system, and if it is a custom event type, it verifies whether the system filing has been completed; at the same time, it performs logical verification on the triggering conditions to ensure that the triggering conditions can be parsed by the event monitoring module. Then, based on the importance of the business scenario and the system's preset event priority rules, it sets the monitoring priority for the current event scheduling task; it encapsulates the event type, triggering conditions, monitoring priority, and its own callback interface address into an event registration data packet in a standardized format, and initiates an event scheduling task registration request through the registration interface provided by the event monitoring module. After receiving the event scheduling task registration request, the event monitoring module parses the event type in the event registration data packet, registers the event scheduling task to the monitoring queue of the corresponding event type, and sorts it according to the set monitoring priority; at the same time, it binds the event scheduling task with the event type, records the callback interface address of the trigger instance, and completes the registration association.
[0057] Step S60: After the registration and scheduling task is successful, the scheduler module associates the trigger instance with the corresponding instance identifier and stores it in the trigger management container, and saves the scheduling rule configuration associated with the trigger instance and its own running data as trigger instance data to the persistent storage module.
[0058] The trigger management container is a container in the scheduler module used to store the mapping relationship between trigger instances and instance identifiers. It supports quick querying, adding and deleting trigger instances, and realizes centralized management of instances.
[0059] For example, when creating a trigger instance, the scheduler module generates a unique instance identifier for the trigger instance; it then associates the instance identifier with the trigger instance as a key and writes it into the trigger management container; simultaneously, it performs a consistency check on the mapping relationship in the trigger management container to ensure that there are no duplicate instance identifiers. Next, the scheduler module extracts the trigger instance's scheduling rule configuration and its own runtime data, and integrates these data using the instance identifier as the primary key; it then serializes the integrated data, converts it to a data format supported by the persistent storage module, and generates a data checksum. Afterward, the scheduler module sends the trigger instance data and checksum to the persistent storage module, initiating a data write request; upon receiving the trigger instance data and checksum, the persistent storage module first verifies the data integrity using the checksum. If the verification is successful, it writes the trigger instance data to a storage medium such as Redis or a database according to a preset storage structure and returns a successful write confirmation message.
[0060] This embodiment supports a unified registration process for both time-based and event-based triggers. Time-based triggers utilize a third-party scheduler to ensure time accuracy, while event-based triggers achieve native responses to business events through an event monitoring module. This design allows businesses to dynamically register new task types, such as custom events, based on their needs without modifying the core framework, significantly improving the system's adaptability in microservices or complex business scenarios. Furthermore, a persistent storage module saves trigger instance data, enabling rapid recovery of the task context after system crashes or restarts, preventing data loss, reducing storage overhead, supporting task compensation, and enhancing robustness in distributed environments.
[0061] Based on the second embodiment of this application, please refer to the third embodiment of this application. Figure 3 After step S50, the task scheduling method based on scheduling rule configuration further includes steps S80~S100: Step S80: After the trigger instance registers the scheduling task, the first theoretical number of triggers from the start time to the current system time is determined according to the start time and triggering conditions in the scheduling rule configuration.
[0062] The first theoretical trigger count is the total number of times a task should be triggered to execute from the start time to the current system time, calculated based on the start time and trigger conditions in the scheduling rule configuration. It is the core benchmark for determining whether there are any missing tasks.
[0063] For example, after a trigger instance registers a scheduled task, it extracts the start time, trigger conditions, and trigger type from the scheduling rule configuration and selects the corresponding calculation logic based on the trigger type. For instance, a time-based trigger condition can be a Cron expression or an interval, and its corresponding time dimension calculation algorithm can be a Cron expression parsing algorithm or a fixed interval calculation algorithm; an event-based trigger condition can be an event trigger frequency, and its corresponding event frequency matching algorithm can be based on a preset event trigger frequency rule and time window conversion logic. The trigger instance executes the corresponding calculation logic according to the trigger type. For time-based triggers, by parsing the trigger conditions, it iterates through the time interval from the start time to the current system time and counts the total number of time nodes that meet the conditions; for event-based triggers, by using the event trigger frequency rule and combining it with the time interval length, it calculates the theoretical number of events that should be triggered from the start time to the current system time, thus obtaining the aforementioned first theoretical trigger count.
[0064] Step S90: After the trigger instance determines the first theoretical trigger count, the number of lost tasks is determined based on the difference between the first theoretical trigger count and the number of triggered tasks, and a compensation task is executed according to the loss compensation strategy in the scheduling rule configuration based on the number of lost tasks.
[0065] The trigger instance calculates the difference between the first theoretical trigger count and the actual trigger count to obtain the number of lost tasks. Then, it parses the loss compensation strategy in the scheduling rule configuration, such as no compensation, compensation once, or compensation for all tasks, and executes the corresponding compensation task. For example, if it is "no compensation," the process is terminated directly; if it is "compensate once," regardless of the number of lost tasks, only the compensation task closest to the current system time is executed once; if it is "compensate for all tasks," the corresponding number of compensation tasks is executed according to the determined number of lost tasks.
[0066] Step S100: After the trigger instance completes the compensation task, it updates its own running data.
[0067] For example, the specific steps for updating its own runtime data include: the trigger instance statistically analyzes the final execution results of the compensation tasks and extracts the number of successfully executed compensation tasks; if there are failed compensation tasks that cannot be retried, the failure identifier and reason can be recorded for subsequent anomaly investigation. Then, the number of triggered tasks is added to the number of valid compensation tasks; in non-infinite repetition scenarios, the remaining execution count is deducted from the number of valid compensation tasks; if the compensation task is successfully executed, the last trigger time is updated to the system time at the time of the last compensation task execution.
[0068] To better understand the solution presented in this embodiment in conjunction with the above embodiments, please refer to... Figure 4 , Figure 4 This application provides a schematic diagram of the trigger instance registration and task triggering process for the task scheduling method based on scheduling rules, specifically: The scheduler module receives the registration request from the client, extracts the scheduling rule configuration carried in the registration request, instantiates the corresponding trigger instance according to the trigger type in the scheduling rule configuration, encapsulates the rule metadata in the scheduling rule configuration into the trigger instance, and initializes the trigger instance's own runtime data, generating a trigger instance containing complete rule metadata and initial runtime data. The trigger instance calculates the first theoretical number of triggers from the start time to the current system time based on the start time and trigger conditions in the rule metadata, then calculates the difference between the first theoretical number of triggers and its own initial triggered number to obtain the number of lost tasks; finally, combined with the loss compensation strategy in the scheduling rule configuration, it determines the number of compensation tasks that need to be executed immediately. The trigger instance executes the corresponding compensation task logic according to the determined number of compensation tasks, and updates its own runtime data after the compensation tasks are completed. Then, the trigger instance registers scheduling tasks according to the trigger type. The scheduler module associates the trigger instance with its instance identifier and stores it in its own maintained trigger management container to achieve centralized management of trigger instances. Simultaneously, the scheduler module periodically persists the trigger instance data to the persistent storage module, completing the persistence of configuration and runtime data.
[0069] The trigger instance receives status change information from the client, compares it with the trigger conditions defined in the scheduling rule configuration, and determines whether the task execution requirements are met. If so, it enters the task execution process. After confirming that the task execution requirements are met, the trigger instance first updates its own running data. The scheduler module, based on the task identifier passed by the trigger instance, queries and retrieves the corresponding scheduling task logic from the business's task management container. The scheduler module passes the task identifier and the number of triggers to the scheduling task logic and executes the specific business processing operations. If trigger count push is configured, the trigger instance's number of triggers is synchronously pushed to the designated receiver (MQ). After the task execution is completed, the trigger instance checks whether the remaining execution count is 0 or whether the scheduling termination condition defined in the scheduling rule configuration is met. After confirming that all tasks have been executed, the trigger instance sends a cancellation request to the scheduler module, removes the trigger instance from the trigger management container, and releases the centralized management of the trigger instance.
[0070] Based on the above embodiments of this application, in the fourth embodiment of this application, please refer to... Figure 5 After step S30, the task scheduling method based on scheduling rule configuration further includes steps S110 to S140: Step S110: After the server restarts, the scheduler module reads all saved trigger instance data from the persistent storage module, determines the instance identifier from the trigger instance data, and calls the recovery interface to associate the corresponding instance template based on the instance identifier to restore the trigger instance.
[0071] When a system stops running due to maintenance, unexpected crashes, or other reasons, it needs to be restarted. During this time, the trigger instances and running data in the system memory will be lost and need to be recovered through persistent data. After the server restarts, the scheduler module calls the batch read interface of the persistent storage module to obtain all saved trigger instance data. The read data is initially filtered to remove invalid instance data that has exceeded the end time of the scheduling rule or has 0 remaining execution counts and is not infinitely repetitive, retaining the set of valid data that still needs to be executed. It can be understood that when a trigger instance is created, it is created based on the instance template and scheduling rule configuration. Therefore, after the scheduler module extracts the instance identifier from the trigger instance data, it can recreate the trigger instance according to the instance template and scheduling rule configuration corresponding to the instance identifier.
[0072] Step S120: After the trigger instance is successfully restored, determine the second theoretical number of triggers from the last trigger time to the current system time according to the trigger frequency in the scheduling rule configuration of the trigger instance.
[0073] The second theoretical trigger count is the total number of tasks that should be triggered during the restart period, calculated based on the trigger frequency of the trigger instance, the last trigger time, and the current system time after the server restarts. It is the core benchmark for judging lost tasks during restarts.
[0074] For example, if the trigger instance is time-type and its corresponding trigger condition is a time interval, then the second theoretical number of triggers from the last trigger time to the current system time is determined according to the event interval; if the trigger instance is event-type, the second theoretical number of triggers from the last trigger time to the current system time can be determined according to the trigger frequency in the historical records.
[0075] Step S130: After the trigger instance determines the second theoretical trigger count, the number of restarted lost tasks is determined based on the difference between the second theoretical trigger count and the number of already triggered tasks in the trigger instance data, and a compensation task is executed according to the loss compensation strategy in the scheduling rule configuration based on the number of restarted lost tasks.
[0076] Step S140: After the trigger instance completes the compensation task, it updates its own running data.
[0077] The trigger instance calculates the difference between the second theoretical trigger count and the actual trigger count to obtain the number of lost tasks to be restarted, and executes compensation tasks according to the loss compensation strategy configured in the scheduling rules. The compensation mechanism is the same as step S90 above, and will not be repeated here.
[0078] After the compensation task is completed, the trigger instance counts the number of successful and valid executions in the compensation task and adds the number of triggered times to the number of valid executions. In non-infinite repetition scenarios, the remaining number of executions is reduced by the number of valid executions, and the last trigger time is updated to the system time of the last successful compensation, and its own running data is updated.
[0079] Based on the above embodiments of this application, please refer to the fifth embodiment of this application. Figure 6 After step S30, the task scheduling method based on scheduling rule configuration further includes steps S150 to S170: Step S150: After the trigger instance finishes executing the compensation task or the scheduling task, determine whether the current remaining execution count is 0 or whether the scheduling termination condition in the scheduling rule configuration is met.
[0080] The scheduling termination condition is a preset condition in the scheduling rule configuration, except when the remaining number of executions is 0, which is the trigger condition for task termination. These conditions include reaching the scheduling end time, triggering a specific business status threshold, and exceeding the maximum execution time.
[0081] After the trigger instance completes the compensation task or scheduling task, the remaining execution count is extracted from the updated running data. If it is a non-infinite repetition scenario, it is determined whether the remaining execution count is 0. At the same time, all scheduling termination conditions are extracted from the scheduling rule configuration, and each scheduling termination condition is matched one by one.
[0082] In step S160, if the current remaining execution count is 0 or the scheduling termination condition in the scheduling rule configuration is met, the trigger instance sends a completion signal and instance identifier to the scheduler module.
[0083] Step S170: After the scheduler module receives the completion signal and the instance identifier, it searches for the corresponding instance in the trigger management container according to the instance identifier, and deletes the instance and the instance data associated with the instance from the persistent storage module.
[0084] If the remaining execution count is 0 or the scheduling termination condition in the scheduling rule configuration is met, the termination procedure is executed. The trigger instance sends a completion signal containing the instance identifier to the scheduler module, informing the scheduler module to perform the instance cleanup operation. The scheduler module parses the completion signal, extracts the instance identifier, and accurately locates the corresponding instance in the trigger management container; it deletes the instance from the trigger management container, releases the scheduler module from centralized management of the instance, and sends a data deletion request to the persistent storage module; the persistent storage module, based on the received instance identifier, locates the corresponding instance data and performs the deletion operation.
[0085] Optionally, if the current remaining execution count is not 0 or the scheduling termination condition in the scheduling rule configuration is not met, the time-type trigger instance will pass the updated remaining execution count, current system time and trigger condition to the third-party scheduler, and the third-party scheduler will register subsequent timed scheduling tasks; the event-type trigger instance will re-register to the system's event monitoring module and wait for subsequent business events to trigger. The specific execution steps can be referred to step S50 in the second embodiment.
[0086] To better understand the solution presented in this embodiment in conjunction with the above embodiments, please refer to... Figure 7 , Figure 7 This application provides a schematic diagram of the crash recovery process for the task scheduling method based on scheduling rules, specifically: After the server restarts, the scheduler module actively reads all saved scheduling-related data from the persistent storage module, calls its own recovery interface, and initiates the recovery process for a single configuration. It associates the corresponding instance template using the instance identifier in the configuration. Once the trigger instance successfully recovers, it calculates the second theoretical number of triggers from the last trigger time before the crash to the current system time, based on the start time and trigger frequency in its associated rule metadata. It then calculates the difference between this second theoretical number and the persistent triggered count to obtain the number of tasks lost during the crash. Combining this with the compensation strategy defined in the scheduling rule configuration, it determines the number of compensation tasks to be executed. The trigger instance executes the corresponding task logic sequentially according to the determined number of compensation tasks. If trigger count push is configured, the updated triggered count is pushed to the designated receiver (MQ) after each compensation task execution. After the compensation task execution is complete, it updates its own running data. Finally, the trigger instance checks whether the remaining execution count is 0 or whether the scheduling termination condition defined in the scheduling rule configuration is met to determine whether all scheduled tasks have been completed. If all tasks have been completed, the scheduler module, based on the completion signal and instance identifier transmitted by the trigger instance, locates the corresponding trigger instance in the trigger management container and deletes it from the trigger management container. Simultaneously, it deletes the relevant data of the trigger instance from the persistent storage module, releasing resources. If the task has not been fully executed, time-based trigger instances transmit the updated remaining execution count, new trigger start time, and trigger conditions to the third-party scheduler, which then registers subsequent scheduled tasks. Event-based trigger instances are re-registered with the system's event detection module, awaiting subsequent business events. The scheduler module re-includes the incompletely scheduled trigger instances and their updated runtime data into the trigger management container, verifies whether all reloaded configurations have been processed (either instance removal or management recovery), whether the runtime data of the trigger management container instance is consistent with the persistent data, and whether subsequent scheduled tasks are registered correctly. Once it is confirmed that all configurations have been restored, the data is consistent, and scheduling is available, the entire recovery process is complete.
[0087] Based on the above embodiments of this application, please refer to the sixth embodiment of this application. Figure 8 The task scheduling method based on scheduling rules configuration further includes steps S180~S200: Step S180: When the channel push module receives user event data sent by the client, it calls the interface provided by the scheduler module to encapsulate the user event data into a scheduling rule and send it to the scheduler module. The user event data includes user identifier, event content and event time offset.
[0088] User event data refers to event information sent by the client, including three core fields: user identifier, which uniquely identifies the user and is used to associate user information; event content, which contains the specific event information to be pushed, such as event type, event parameters, and message body; and event time offset, which is the delay time relative to the current time and is used to calculate the task trigger time.
[0089] For example, the channel push module receives user event data sent by the client through an external interface, encapsulates the user event data into a scheduling rule, sets the trigger type to time-based, and the trigger condition to a one-time task. The trigger time is calculated as the current system time plus the event time offset. After the scheduling rule is encapsulated, the channel push module calls the unified interface provided by the scheduler module to send the scheduling rule as a parameter.
[0090] Step S190: After the scheduler module receives the scheduling rule, it creates a timed push task according to the scheduling rule, wherein the task trigger time of the timed push task is the current time plus the event time offset.
[0091] The scheduler module parses the received scheduling rules and calculates the trigger time based on the trigger time in the scheduling rules, which is the current time plus the event time offset. For example, if the current time is T and the event time offset is ΔT, then the trigger time is T+ΔT. Then, a scheduled push task is created based on this trigger event. The task logic is bound to the execution interface of the channel push module to ensure that the push function can be invoked when triggered.
[0092] Step S200: When the scheduled push task is triggered, the channel push module queries the target channel and push authorization certificate corresponding to the user identifier from the active user pool of the persistent storage module according to the user identifier, encapsulates the event content according to the protocol format of the target channel, carries the push authorization certificate, calls the event reporting interface provided by the target channel, and initiates an event push request.
[0093] When the system time reaches the trigger time calculated in the scheduling rules, the scheduler module triggers the scheduled push task and calls the specified execution method of the channel push module, passing in the user identifier and event content. The channel push module accesses the active user pool in the persistent storage module based on the user identifier. The query logic is as follows: using the user identifier as the key, it retrieves the mapped target channel type and push authorization credential. If the user does not exist in the active user pool, the task fails and is logged. After a successful query, the channel push module encapsulates the event content according to the target channel's protocol format, such as HTTP JSON body, XML, or a custom binary format. Then, carrying the push authorization credential, the channel push module calls the event reporting interface provided by the target channel to initiate an event push request, pushing the event content to the target channel.
[0094] To better understand the solution presented in this implementation, please refer to... Figure 8 , Figure 8 This application provides a schematic diagram of the channel push process for the task scheduling method based on scheduling rules, specifically: After a user logs in, the game server collects login event data generated during the login process and reports this data to the channel push module in a specified format via a pre-defined Kafka topic, such as the "login" topic. The login message consumer monitors the designated Kafka topic, obtains the reported login event data in real time, and writes it to the persistent storage module for storage. After a user logs in, the channel push module queries the persistent storage module for existing scheduled push tasks for that user based on the user identifier, deleting all unexecuted historical task records to avoid duplicate pushes. Based on business scenario requirements, such as when a user triggers a specific business action, the game server collects user event data and reports it to the channel push module via another pre-defined Kafka topic. The push event consumer monitors the Kafka topic corresponding to the user event, obtains the user event data, and performs parsing and verification; it performs hash calculations using the user identifier to associate the user with a stable storage node, ensuring consistency of user data access; simultaneously, it records the relationship between the user identifier, event content, and time offset, providing a basis for task creation. Next, the channel push module calls the interface provided by the scheduler module to register a one-time trigger, encapsulating parameters such as event time offset, user identifier, and event content into scheduling rules. The scheduler module then creates a scheduled push task based on these rules, setting the task trigger time to the current time plus the event time offset. When the scheduled push task is triggered, the scheduler module retrieves the corresponding channel identifier and push authorization credential from the active user pool based on the user identifier. The channel push module encapsulates the event content according to the target channel's protocol format, carries the valid push authorization credential, and calls the event reporting interface provided by the channel to initiate a push request; simultaneously, it monitors the response result of the push request and records the push status. When the system receives a shutdown command, the channel push module cleans up resources on all currently allocated user storage nodes, unloads user data and task information associated with the nodes, and releases system resources. The channel service collects the execution data of all push tasks, performs data logging according to a preset format, and generates push performance reports based on the collected data, including statistical analysis by channel and time dimensions.
[0095] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the task scheduling method based on scheduling rules configured in this application. Any simple modifications based on this technical concept are within the protection scope of this application.
[0096] This application provides a task scheduling device based on scheduling rules configuration. The task scheduling device based on scheduling rules configuration includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the task scheduling method based on scheduling rules configuration in the above embodiment 1.
[0097] The following is for reference. Figure 9 This diagram illustrates a structural schematic of a task scheduling device suitable for implementing the embodiments of this application based on scheduling rule configuration. The task scheduling device based on scheduling rule configuration in the embodiments of this application may include, but is not limited to, mobile terminals such as laptops and tablets (PADs, Portable Application Descriptions) and fixed terminals such as desktop computers. Figure 9 The task scheduling device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0098] like Figure 9 As shown, the task scheduling device configured based on scheduling rules may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1002 or a program loaded from storage device 1003 into random access memory (RAM) 1004. The random access memory 1004 also stores various programs and data required for the operation of the task scheduling device configured based on scheduling rules. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the task scheduling device configured based on scheduling rules to communicate wirelessly or wiredly with other devices to exchange data. Although a task scheduling device configured based on scheduling rules with various systems is shown in the figure, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented alternatively.
[0099] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0100] The task scheduling device based on scheduling rules configuration provided in this application, employing the task scheduling method based on scheduling rules configuration in the above embodiments, can solve the technical problem of complex task scheduling response in existing task scheduling frameworks. Compared with the prior art, the beneficial effects of the task scheduling device based on scheduling rules configuration provided in this application are the same as those of the task scheduling method based on scheduling rules configuration provided in the above embodiments, and other technical features in this task scheduling device based on scheduling rules configuration are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0101] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0102] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0103] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, which are used to execute the task scheduling method based on scheduling rule configuration in the above embodiments.
[0104] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or flash memory, optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, radio frequency (RF), etc., or any suitable combination thereof.
[0105] The aforementioned computer-readable storage medium may be included in a task scheduling device configured based on scheduling rules; or it may exist independently and not be assembled into a task scheduling device configured based on scheduling rules.
[0106] The aforementioned computer-readable storage medium carries one or more programs that, when executed by a task scheduling device configured based on scheduling rules, enable the task scheduling device to write computer program code for performing the operations of this application in one or more programming languages or a combination thereof. These programming languages include object-oriented programming languages—such as Java, Smalltalk, and C++—and conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, or as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0107] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0108] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0109] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the task scheduling method based on scheduling rule configuration described above. This solves the technical problem of complex task scheduling responses in existing task scheduling frameworks. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the task scheduling method based on scheduling rule configuration provided in the above embodiments, and will not be repeated here.
[0110] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the task scheduling method based on scheduling rule configuration as described above.
[0111] The computer program product provided in this application can solve the technical problem of complex task scheduling response in existing task scheduling frameworks. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the task scheduling method based on scheduling rule configuration provided in the above embodiments, and will not be repeated here.
[0112] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A task scheduling method based on scheduling rule configuration, characterized in that, Applied to a task scheduling system, the task scheduling system includes a trigger module and a scheduler module, and the task scheduling method based on scheduling rule configuration includes: When a trigger instance in the trigger module receives a status change message sent by the client, it compares the status change message with the trigger conditions in the scheduling rule configuration to determine whether the current status change meets the task execution requirements. After the trigger instance determines that the task execution requirements are met, it updates its own running data and sends the running data and the task identifier to the scheduler module. After the scheduler module receives the task identifier, it queries and obtains the corresponding scheduling task logic from the task management container based on the task identifier, and passes its own running data and the status change information as task parameters to the scheduling task logic to execute the scheduling task.
2. The task scheduling method based on scheduling rule configuration as described in claim 1, characterized in that, The self-run data includes the number of times it has been triggered, the remaining number of executions, and the current system time; The step of updating its own running data and sending the running data and task identifier to the scheduler module after the trigger instance determines that the task execution requirements are met includes: After the trigger instance determines that the task execution requirements are met, the number of times it has been triggered is incremented by 1, the number of remaining execution times is decremented by 1, and the last trigger time is updated to the current system time. The number of times the task has been triggered and the task identifier are sent to the scheduler module.
3. The task scheduling method based on scheduling rule configuration as described in claim 1, characterized in that, The task scheduling system also includes a persistent storage module. Before the step of comparing the state change information with the trigger conditions in the scheduling rule configuration to determine whether the current state change meets the task execution requirements when the trigger instance in the trigger module receives state change information sent by the client, the system further includes: When the scheduler module receives the registration request initiated by the client, it creates the trigger instance in the trigger module according to the scheduling rules configured in the registration request. Once the trigger instance is successfully created, the trigger instance registers the corresponding scheduling task according to the trigger type configured in the scheduling rule. After the registration and scheduling task is successful, the scheduler module associates the trigger instance with the corresponding instance identifier and stores it in the trigger management container, and saves the scheduling rule configuration associated with the trigger instance and its own running data as trigger instance data to the persistent storage module.
4. The task scheduling method based on scheduling rule configuration as described in claim 3, characterized in that, The task scheduling system also includes an event monitoring module. The step of registering the corresponding scheduled task based on the trigger type configured in the scheduling rules after the trigger instance is successfully created includes: If the trigger type is time-based, the trigger conditions and remaining execution counts in the scheduling rule configuration are sent to a third-party scheduler, and the corresponding timed scheduling task is registered through the third-party scheduler. If the trigger type is event-based, then the corresponding event scheduling task is registered in the event monitoring module and bound to the corresponding event type.
5. The task scheduling method based on scheduling rule configuration as described in claim 3, characterized in that, After the step of registering the corresponding scheduled task according to the trigger type configured in the scheduling rule after the trigger instance is successfully created, the method further includes: After the trigger instance registers a scheduling task, the first theoretical number of triggers from the start time to the current system time is determined according to the start time and triggering conditions in the scheduling rule configuration. Once the trigger instance determines the first theoretical trigger count, it determines the number of lost tasks based on the difference between the first theoretical trigger count and the number of triggered tasks, and executes compensation tasks according to the loss compensation strategy in the scheduling rule configuration based on the number of lost tasks. After the trigger instance completes the compensation task, it updates its own running data.
6. The task scheduling method based on scheduling rule configuration as described in claim 1, characterized in that, The task scheduling system further includes a persistent storage module. After the scheduler module receives the task identifier, queries and retrieves the corresponding scheduling task logic from the task management container based on the task identifier, and passes its own running data and the status change information as task parameters to the scheduling task logic to execute the scheduling task, the system further includes: When the server restarts, the scheduler module reads all saved trigger instance data from the persistent storage module, determines the instance identifier from the trigger instance data, and calls the recovery interface based on the instance identifier to associate the corresponding instance template to restore the trigger instance. Once the trigger instance is successfully restored, the second theoretical number of triggers from the last trigger time to the current system time is determined according to the trigger frequency in the scheduling rule configuration of the trigger instance. Once the trigger instance determines the second theoretical trigger count, it determines the number of lost tasks to be restarted based on the difference between the second theoretical trigger count and the number of triggered tasks in the trigger instance data, and executes compensation tasks according to the loss compensation strategy in the scheduling rule configuration based on the number of lost tasks to be restarted. After the trigger instance completes the compensation task, it updates its own running data.
7. The task scheduling method based on scheduling rule configuration as described in claim 1, characterized in that, The task scheduling system further includes a persistent storage module. After the scheduler module receives the task identifier, queries and retrieves the corresponding scheduling task logic from the task management container based on the task identifier, and passes its own running data and the status change information as task parameters to the scheduling task logic to execute the scheduling task, the system further includes: After the trigger instance finishes executing the compensation task or the scheduling task, it is determined whether the current remaining number of executions is 0 or whether the scheduling termination condition in the scheduling rule configuration is met. If the current remaining execution count is 0 or the scheduling termination condition in the scheduling rule configuration is met, the trigger instance sends a completion signal and instance identifier to the scheduler module; When the scheduler module receives the completion signal and the instance identifier, it searches for the corresponding instance in the trigger management container according to the instance identifier, and deletes the instance and the instance data associated with the instance from the persistent storage module.
8. The task scheduling method based on scheduling rule configuration as described in claim 1, characterized in that, The task scheduling system also includes a channel push module, and the task scheduling method based on scheduling rule configuration includes: When the channel push module receives user event data sent by the client, it calls the interface provided by the scheduler module to encapsulate the user event data into a scheduling rule and send it to the scheduler module. The user event data includes user identifier, event content and event time offset. When the scheduler module receives the scheduling rule, it creates a timed push task according to the scheduling rule, wherein the task trigger time of the timed push task is the current time plus the event time offset; When the scheduled push task is triggered, the channel push module queries the target channel and push authorization credential corresponding to the user identifier from the active user pool of the persistent storage module according to the user identifier, encapsulates the event content according to the protocol format of the target channel, carries the push authorization credential, calls the event reporting interface provided by the target channel, and initiates an event push request.
9. A task scheduling device based on scheduling rule configuration, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the task scheduling method based on scheduling rules as described in any one of claims 1 to 8.
10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the task scheduling method based on scheduling rule configuration as described in any one of claims 1 to 8.
