Method and device for automatically configuring tasks based on task scheduling platform

By implementing the method of automatically configuring tasks in the task scheduling platform, the problem of error-prone configuration operations is solved, the accuracy and efficiency of configuration are improved, and the need for manual intervention is reduced.

CN119781872AActive Publication Date: 2025-04-08BEIJING QINGSONG YIKANG INFORMATION TECHNOLOGY CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510283413.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-11
Publication Date
2025-04-08
Estimated Expiration
2045-03-11

AI Technical Summary

Technical Problem

The configuration operation of the task scheduling platform is prone to errors, especially when the number of tasks increases, the risk of manual configuration is higher.

Method used

The method of automatically configuring tasks in the task scheduling platform is to automatically complete the registration of the executor and tasks by detecting the executor configuration, registering the executor, analyzing the task annotation information and registering the task, ensuring that the executioner and task registration is automatically completed when the project starts.

Benefits of technology

It reduces the need for manual intervention, reduces errors caused by human negligence, and improves the configuration accuracy and efficiency of the task scheduling platform.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119781872A_ABST
    Figure CN119781872A_ABST
Patent Text Reader

Abstract

The present application relates to a method and device for automatically configuring tasks based on a task scheduling platform, the method comprising: after a project in the task scheduling platform is successfully started, if the executor configuration of the project is detected, it is determined that the necessary components of the project have been correctly configured; if the target executor is not registered in the task scheduling platform according to the value of the executor configuration, the target executor is registered in the task scheduling platform; if it is determined that the target task with the first annotation information in the project also has the second annotation information, the configuration parameters of the target task are parsed according to the second annotation information; if the target task does not exist in the task set registered by the target executor in the task scheduling platform, the task is registered in the task scheduling platform through the task name and configuration parameters of the target task. The present application improves the configuration accuracy of the task scheduling platform.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cloud computing technology, and in particular to a method and device for automatically configuring tasks based on a task scheduling platform. Background Art

[0002] Task scheduling is an indispensable part of modern software development. For example, XXL-JOB, as a lightweight task scheduling platform, has been widely used due to its clear interface, simple configuration and support for distributed systems. It significantly simplifies the operation process of scheduled task scheduling and improves development and operation efficiency.

[0003] However, in actual use, executors and tasks must be manually configured through the task scheduling platform page. This configuration method is relatively easy to manage when the number of executors and tasks is small. However, as the number of tasks increases, manual configuration operations on the page increase the risk of operational errors. Summary of the invention

[0004] The present application provides a method and device for automatically configuring tasks based on a task scheduling platform to solve the problem that configuration operations of the task scheduling platform are prone to errors.

[0005] In a first aspect, the present application provides a method for automatically configuring tasks based on a task scheduling platform, the method comprising: After the project in the task scheduling platform is successfully started, if the executor configuration of the project is detected, it is determined that the necessary components of the project have been correctly configured; If it is found according to the value of the executor configuration that the target executor has not been registered in the task scheduling platform, registering the target executor in the task scheduling platform, wherein the value of the executor configuration is used to uniquely identify the executor; If it is determined that the target task in the project having the first annotation information also has the second annotation information, then parsing the configuration parameters of the target task according to the second annotation information, wherein the first annotation information is used to mark the task, and the second annotation information is used to provide configuration information of the task; If the target task does not exist in the task set of the target executor registered on the task scheduling platform, the task is registered in the task scheduling platform using the task name and configuration parameters of the target task.

[0006] Optionally, after a project in the task scheduling platform is successfully started, if the executor configuration of the project is detected, determining that the necessary components of the project have been correctly configured includes: After the project is successfully started, the executor adds events by automatically registering the manager; When the executor addition event is monitored, scanning the configuration files in the project; If the configuration file includes the actuator configuration, it is determined that the necessary components of the project are correctly configured.

[0007] Optionally, if it is found according to the value of the executor configuration that the target executor has not been registered in the task scheduling platform, registering the target executor in the task scheduling platform includes: Determining a target executor in the project using the value of the executor configuration; If it is found through the preset executor query interface in the task scheduling platform that the target executor has not been registered in the task scheduling platform, the target executor is registered through the preset executor registration interface in the task scheduling platform.

[0008] Optionally, if it is determined that the target task having the first annotation information in the project also has the second annotation information, parsing the configuration parameters of the target task according to the second annotation information includes: Determine a task list having the first annotation information by scanning the methods or classes marking the tasks in the project; If the target task in the task list has both the first annotation information and the second annotation information, the configuration parameters of the target task are parsed according to the second annotation information.

[0009] Optionally, if the target task does not exist in the task set registered by the target executor in the task scheduling platform, registering the task in the task scheduling platform using the task name and configuration parameters of the target task includes: Calling a preset task query interface in the task scheduling platform to query the task collection of the target executor registered in the task scheduling platform; Comparing the task list scanned in the project with the task collection registered in the task scheduling platform; If the target task in the task list does not exist in the task collection, determining that the target task has not been registered in the task scheduling platform; According to the task name and configuration parameters of the target task, the task is registered through a task registration interface preset in the task scheduling platform.

[0010] Optionally, before the project in the task scheduling platform is started, the method further includes: Configure interface information in the task scheduling platform, and introduce the calling logic of the interface information in the project, wherein the interface information includes an executor query interface, an executor registration interface, a task query interface, and a task registration interface; second annotation information for adding a task to the project; Add an automatic registration manager to the project, wherein the automatic registration manager inherits the monitoring interface and is used to monitor events and execute query and registration processes; Package the project and publish it to the settings repository.

[0011] In a second aspect, the present application provides a device for automatically configuring tasks based on a task scheduling platform, the device comprising: A detection module, used for determining that necessary components of the project have been correctly configured if the executor configuration of the project is detected after the project in the task scheduling platform is successfully started; An executor registration module, configured to register the target executor in the task scheduling platform if it is found according to the value of the executor configuration that the target executor has not been registered in the task scheduling platform, wherein the value of the executor configuration is used to uniquely identify the executor; A parsing module, configured to parse the configuration parameters of the target task according to the second annotation information if it is determined that the target task with the first annotation information in the project also has the second annotation information, wherein the first annotation information is used to mark the task and the second annotation information is used to provide configuration information of the task; The task registration module is used to register the target task in the task scheduling platform according to the task name and configuration parameters of the target task if the target task does not exist in the task set registered by the target executor in the task scheduling platform.

[0012] Optionally, the task registration module is used to: Calling a preset task query interface in the task scheduling platform to query the task collection of the target executor registered in the task scheduling platform; Comparing the task list scanned in the project with the task collection registered in the task scheduling platform; If the target task in the task list does not exist in the task collection, determining that the target task has not been registered in the task scheduling platform; According to the task name and configuration parameters of the target task, the task is registered through a task registration interface preset in the task scheduling platform.

[0013] In a third aspect, the present application provides an electronic device comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus.

[0014] In a fourth aspect, the present application further provides a computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute the method for automatically configuring tasks based on a task scheduling platform as described in any one of the above items of the present application.

[0015] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art: After determining that the project components are correctly configured through the executor configuration, the executor can be automatically registered in the task scheduling platform, and the configuration parameters of the task can be determined based on the annotation information of the task in the executor. Then, the task can be registered in the task scheduling platform based on the project name and configuration parameters. This application can automatically register the executor and tasks to the task scheduling platform when the project starts. The automated configuration detection and registration mechanism reduces the need for manual intervention, avoids errors caused by human negligence, and improves the configuration accuracy of the task scheduling platform. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0018] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0019] Figure 1 A flowchart of a method for automatically configuring tasks based on a task scheduling platform provided in an embodiment of the present application; Figure 2 A flowchart of automatically configuring tasks based on a task scheduling platform provided in an embodiment of the present application; Figure 3 A schematic diagram of a device structure for automatically configuring tasks based on a task scheduling platform provided in an embodiment of the present application; Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0020] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0021] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0022] In order to solve the problem that the configuration operation of the task scheduling platform mentioned in the background technology is prone to errors, the embodiment of the present application automatically adds the executors and tasks required for the project to the task scheduling platform after the project is started, without the need for manual configuration, thereby improving configuration accuracy.

[0023] This application can be applied to distributed task scheduling as well as to a single-machine environment.

[0024] Some of the terms mentioned in the embodiments of the present application are explained below, including the following contents.

[0025] The value of executor configuration xxl.job.executor.appname is used to identify and distinguish different executors. Each executor has a unique executor name appName in the task scheduling platform, which is the identity of the executor.

[0026] The first annotation information @xxlJob: is an annotation used to mark the method or class of the task.

[0027] The second annotation information xxlJobRegisterWithParam: is used to mark and configure a specific task. It contains various parameters of the task, such as task description, responsible person, Cron expression, scheduling type, running mode, etc. This information helps the task scheduling platform understand the scheduling rules and behaviors of the task.

[0028] Task list taskNameList: This is a list of task names obtained by scanning all methods or classes annotated with @xxlJob in the current project. These tasks are defined according to the business needs of the project and may include newly added tasks or modified tasks.

[0029] The collection of registered tasks xxlJobtaskNameList: This is a list of all registered tasks under the executor name obtained from the task scheduling platform. These tasks have been registered on the task scheduling platform and can be managed and scheduled.

[0030] The following will be combined with specific implementation methods to provide a method for automatically configuring tasks based on a task scheduling platform provided in an embodiment of the present application. Take application to a server as an example. Figure 1 As shown, the specific steps are as follows: Step 101: After the project in the task scheduling platform is successfully started, if the executor configuration of the project is detected, it is determined that the necessary components of the project have been correctly configured; Step 102: if it is found that the target executor has not been registered in the task scheduling platform according to the value of the executor configuration, the target executor is registered in the task scheduling platform, wherein the value of the executor configuration is used to uniquely identify the executor; Step 103: If it is determined that the target task with the first annotation information in the project also has the second annotation information, the configuration parameters of the target task are parsed according to the second annotation information, wherein the first annotation information is used to mark the task, and the second annotation information is used to provide configuration information of the task; Step 104: If the target task does not exist in the task set that the target executor has registered on the task scheduling platform, the task is registered on the task scheduling platform using the task name and configuration parameters of the target task.

[0031] In step 101, after the project in the task scheduling platform is successfully started, it is first necessary to check whether the executor configuration of the project is correct. This step is achieved by checking the xxl.job.executor.appname configuration item in the configuration file. If the configuration item exists and is valid, it can be determined that the necessary components of the project have been correctly configured. This automatic detection mechanism not only improves the accuracy of the configuration, but also reduces the need for manual intervention. For example, in a SpringBoot project, the developer only needs to add the corresponding executor configuration in the file, and the system will automatically verify the existence and validity of these configuration items at startup.

[0032] Among them, the task scheduling platform includes but is not limited to XXL-JOB, Quartz, ElasticJob (elastic job) or SpringBatch (Spring batch processing). This application does not specifically limit the type of task scheduling platform.

[0033] In step 102, once the executor configuration is confirmed to be correct, the system then needs to query the task scheduling platform (such as XXL-JOB) to determine whether the target executor has been registered. If not, the corresponding API is called to register the executor in the task scheduling platform. The value of the executor configuration is used to uniquely identify the executor, ensuring that each executor has a unique name in the task scheduling platform. This automated registration mechanism simplifies the management process of executors and avoids the tedious operation of manually registering one by one. In addition, it reduces errors caused by human negligence and improves the reliability and stability of the system.

[0034] In step 103, for each task in the project, the system needs to check whether it has two annotations at the same time: one for marking the task (first annotation information), and the other for providing configuration information of the task (second annotation information). This dual annotation design makes the management and configuration of tasks more flexible and efficient. For example, the @XxlJob annotation (first annotation information) can be used to mark tasks, while the @XxlJobRegisterWithParam annotation (second annotation information) provides specific configuration parameters for the task, such as Cron expressions, task processors, etc. By parsing the @XxlJobRegisterWithParam annotation, the system can automatically generate detailed configuration of the task, making it easier to register it in the task scheduling platform.

[0035] In step 104, the system obtains the task set of the target executor that has been registered in the task scheduling platform. If the system finds that a task in the project does not exist in the task set, indicating that the task has not been registered in the task scheduling platform, it can be automatically registered in the task scheduling platform according to the task name and configuration parameters of the task.

[0036] For example, there is an e-commerce backend management system that contains multiple scheduled tasks, such as order processing, inventory update, and promotion management. In order to simplify the configuration process of task scheduling, an automated configuration mechanism can be introduced: 1. Executor configuration detection: When the application starts, the system will listen to the executor add event through the automatic registration manager and automatically scan the application.properties file to find out whether there is a valid xxl.job.executor.appname configuration item in the file. If the configuration item is detected, it is considered that the necessary components of the project have been correctly configured.

[0037] 2. Executor registration: query the task scheduling platform (such as XXL-JOB) according to the value of xxl.job.executor.appname. If the corresponding executor is not found, the executor is automatically registered. This ensures that each executor can be correctly identified and managed.

[0038] 3. Task Annotation Parsing: The system automatically scans all methods and classes in the project and looks for tasks annotated with @XxlJob and @XxlJobRegisterWithParam. For each eligible task, the system parses its configuration parameters, such as task name, Cron expression, etc.

[0039] 4. Automatic task registration: If a task has not been registered in the task scheduling platform, the system will automatically register it in the task scheduling platform according to its task name and configuration parameters. This ensures that all tasks can be scheduled and executed in a timely manner without the need to manually configure them one by one.

[0040] In this application, after determining that the project components are correctly configured through the executor configuration, the executor can be automatically registered in the task scheduling platform, and the configuration parameters of the task can be determined based on the annotation information of the task in the executor. Then, the task can be registered in the task scheduling platform based on the project name and configuration parameters. This application can automatically register the executor and tasks to the task scheduling platform when the project starts. The automated configuration detection and registration mechanism reduces the need for manual intervention, avoids errors caused by human negligence, and improves the configuration accuracy of the task scheduling platform.

[0041] In addition, the automatic registration mechanism in this application not only improves the accuracy of configuration, but also reduces the workload of manual operations, especially when the number of tasks is large. Through automatic registration, the system can automatically scan all executors and eligible tasks when the application starts, and register them to the task scheduling platform, thereby improving work efficiency.

[0042] As an optional implementation, in step 101, after the project in the task scheduling platform is successfully started, if the executor configuration of the project is detected, determining that the necessary components of the project have been correctly configured includes the following: Step S11: After the project is successfully started, the executor add event is monitored through the automatic registration manager; Step S12: When an executor adding event is detected, scan the configuration files in the project; Step S13: If the configuration file includes the actuator configuration, it is determined that the necessary components of the project are correctly configured.

[0043] In step S11, after the project is successfully started, the automatic registration manager (such as the xxlJobAddexecutor class) inherits the ApplicationListener interface to listen to the executor addition event. This mechanism ensures that the executor-related configuration and registration work is automatically detected and processed when the application starts. Specifically, the automatic registration manager triggers the corresponding event listener after the application is started to check whether the project's executor configuration has been correctly set. This method not only improves the accuracy of the configuration, but also reduces the need for manual intervention.

[0044] In step S12, once the actuator addition event is monitored, the next step is to scan the project's configuration file to further confirm the specific content of the actuator configuration. This step usually involves reading and parsing the configuration file (such as application.properties or application.yml) to extract the configuration items related to the actuator. In this way, the system can obtain detailed information about the actuator, such as name, address, etc.

[0045] The process of scanning configuration files not only simplifies configuration management, but also improves the flexibility of the system. For example, if you need to modify certain parameters of the executor, you only need to update the configuration file and restart the application, without manually adjusting the relevant settings in the task scheduling platform. In addition, centralized management of configuration files also helps reduce the possibility of configuration errors, because all configurations are concentrated in one place, which is convenient for unified management and maintenance.

[0046] In step S13, the executor configuration xxl.job.executor.appname is a key configuration item used to identify and distinguish different executors. Each executor needs to have a unique appName so that the xxl-job task scheduling platform can identify and manage different executors. In xxl-job, tasks are assigned to specific executors to run. Therefore, appName can be used to associate tasks with specific executors.

[0047] When the project starts, the system will scan and check if there is a valid xxl.job.executor.appname configuration. If the configuration does not exist, it means that the executor cannot be correctly identified, and the system cannot know which executor to use to run the task. Moreover, the task depends on the executor to execute specific logic. If the executor is not configured or registered correctly, the task will not be scheduled and executed normally.

[0048] After scanning the configuration file, if it is found that it contains valid executor configuration, it can be determined that the necessary components of the project have been correctly configured. This means that the system has the basic conditions required to run the scheduled task and can proceed with subsequent operations, such as task registration and scheduling. This automated detection mechanism not only improves the accuracy of the configuration, but also reduces the need for manual intervention and reduces errors caused by human negligence. When the system detects that these configuration items exist and are valid, it will assume that the executor configuration has been correctly set and proceed to the next step. This mechanism ensures that each executor can be correctly identified and managed, laying a solid foundation for subsequent task scheduling.

[0049] For example, in a SpringBoot project, developers can add actuator-related configurations in the application.properties file, and automatically verify the existence and validity of these configuration items when the application starts through the automatic registration manager. In this way, the system can complete the necessary preparations at the startup stage to ensure that subsequent task scheduling can proceed smoothly.

[0050] In this application, after the executor addition event is listened to by the automatic registration manager (such as the xxlJobAddexecutor class), the executor configuration xxl.job.executor.appname in the project is scanned. Since each executor needs to have a unique appName, the necessary components of the project (executors and tasks) can be checked through the executor configuration to ensure that the executors and tasks can be registered normally in the future. This mechanism ensures that all executors can be correctly identified and managed, avoiding task scheduling failures caused by configuration errors or omissions.

[0051] As an optional implementation, in step 102, if it is found according to the value of the executor configuration that the target executor has not been registered in the task scheduling platform, registering the target executor in the task scheduling platform includes: Step S21: Determine the target actuator in the project using the value of the actuator configuration; Step S22: if it is found through the preset executor query interface in the task scheduling platform that the target executor has not been registered in the task scheduling platform, the target executor is registered through the preset executor registration interface in the task scheduling platform.

[0052] In step S21, after the project is successfully started, the system first needs to determine the target executor in the project according to the value of the executor configuration xxl.job.executor.appname. This process involves reading and parsing the configuration file and extracting the executor's unique identifier appName. This step ensures that each executor has a unique identifier and that the identifier can be correctly identified and managed on the task scheduling platform. In this way, the system can clearly identify the target executor that needs to be managed and scheduled in the current project.

[0053] In step S22, once the target executor is determined, it is necessary to query whether the executor has been registered through the preset interface provided by the task scheduling platform. Specifically: 1. Query the executor: call the executor query interface provided by the task scheduling platform (such as XXL-JOB), use appName as the query parameter, and check whether the executor has been registered in the task scheduling platform.

[0054] 2. Register the executor: If the query result shows that the target executor has not been registered, call the executor registration interface provided by the task scheduling platform to register the executor with the task scheduling platform. When registering, you need to provide relevant information about the executor, such as appName and address.

[0055] In this application, the automated query and registration mechanism reduces the need to manually register executors one by one. Developers only need to add the necessary information in the configuration file, and the system will automatically complete the relevant verification and registration work at startup, reducing the workload of manual intervention and avoiding possible errors caused by human registration of executors.

[0056] As an optional implementation, in step 103, if it is determined that the target task with the first annotation information in the project also has the second annotation information, parsing the configuration parameters of the target task according to the second annotation information includes: Step S31: determining a task list having first annotation information by scanning methods or classes of marked tasks in the project; Step S32: If the target task in the task list has both the first annotation information and the second annotation information, the configuration parameters of the target task are parsed according to the second annotation information.

[0057] After the project is successfully started, the system first needs to scan all methods or classes in the project, find tasks with the first annotation information (such as @XxlJob), and generate a task list. This process ensures that the system can fully identify all tasks that need to be scheduled in the project. This scanning mechanism not only simplifies the task management process, but also improves the flexibility of the system. Developers only need to add corresponding annotations when defining tasks, without manually configuring each task. The system will automatically complete the relevant identification work at startup.

[0058] Once the list of tasks with the first annotation information is determined, the next step is to check whether these tasks also have the second annotation information and parse the configuration parameters. Specifically, the @XxlJobRegisterWithParam annotation is used to provide specific configuration parameters for the task, such as Cron expression, task processor, etc. If a task has both @XxlJob and @XxlJobRegisterWithParam annotations, the system will parse the configuration parameters of the task based on the @XxlJobRegisterWithParam annotation. In this way, the system can obtain detailed configuration information of the task, such as task name, Cron expression, task processor, etc. These configuration parameters are essential for the correct registration and scheduling of tasks, ensuring that the tasks can be correctly executed within the specified time interval. If a task in the project has the first annotation information but does not have the second annotation information, the system needs to notify the developer to add the second annotation information for the task.

[0059] Exemplarily, when the application starts, the system scans all methods or classes in the project, searches for tasks annotated with @XxlJob, and generates a task list. For example, the system scans the following tasks: orderProcessingTask, inventoryUpdateTask, and promotionManagementTask. For each task, the system checks whether it also has the @XxlJobRegisterWithParam annotation and parses the configuration parameters. For example, assuming that only the task orderProcessingTask has the @XxlJobRegisterWithParam annotation, the configuration parameters of the task orderProcessingTask are parsed, including but not limited to the task name (orderProcessingTask), Cron expression (00 / 5...) or task handler (OrderProcessingTaskHandler), etc.

[0060] In this application, only when a task has the first annotation information will the system identify it as a schedulable task. This step ensures that the system will not mistakenly process ordinary classes or methods as tasks. Only when a task also has the second annotation information will the system parse its specific configuration parameters. This step ensures that the system can obtain detailed configuration information of the task, such as scheduling time, processor, etc., so as to ensure that the task can be executed at the correct time and method. If the system parses configuration parameters for all tasks with the first annotation, unnecessary parsing operations may result. For example, some tasks may not require complex scheduling configurations, but only simple markings. Therefore, configuration parameter parsing is performed only when the task has both the first and second annotations, which can avoid unnecessary calculations and resource consumption.

[0061] In addition, the configuration information of tasks is centrally managed through annotations, making the configuration more intuitive and easier to maintain. Developers can manage the configuration of all tasks in one place, which is convenient for subsequent adjustments and optimizations, reducing maintenance costs and complexity.

[0062] As an optional implementation, in step 104, if the target task does not exist in the task set registered by the target executor in the task scheduling platform, registering the task in the task scheduling platform using the task name and configuration parameters of the target task includes: Step S41: calling a preset task query interface in the task scheduling platform to query the task collection of the target executor registered in the task scheduling platform; Step S42: Compare the task list scanned in the project with the task collection registered in the task scheduling platform; Step S43: if the target task in the task list does not exist in the task collection, it is determined that the target task has not been registered in the task scheduling platform; Step S44: According to the task name and configuration parameters of the target task, the task is registered through a task registration interface preset in the task scheduling platform.

[0063] After the project is successfully launched, the system first needs to call the task query interface provided by the task scheduling platform (such as XXL-JOB) to query the task collection of the target executor registered in the task scheduling platform. This process uses appName to query all registered tasks related to the executor. This step ensures that the system can accurately obtain the task status of the current executor on the task scheduling platform, providing basic data support for subsequent operations.

[0064] Next, the system scans the project's code and configuration files, searches for tasks with the first annotation information @XxlJob, generates a task list, and then compares this task list with the task collection obtained from the task scheduling platform. This comparison mechanism can help the system identify which tasks have been registered on the task scheduling platform and which tasks have not yet been registered. In this way, the system can fully grasp the status of all tasks in the project and ensure that each task can be managed and scheduled correctly.

[0065] During the comparison process, if a task is found to exist in the task list of the project but not in the task collection of the task scheduling platform, it can be determined that the task has not been registered in the task scheduling platform. This process ensures that all necessary tasks are correctly identified and managed, avoiding task scheduling failures caused by unregistered tasks. For example, if a task named orderProcessingTask is defined in the project, but the task is not found in the task collection of the task scheduling platform, the system can confirm that the task has not been registered.

[0066] For those target tasks that have not been registered in the task scheduling platform, the system can register them according to their task names and configuration parameters through the task registration interface provided by the task scheduling platform. This step ensures that all newly added tasks can be recognized and managed by the task scheduling platform in a timely manner, thereby ensuring the smooth progress of task scheduling. For example, if the system finds that orderProcessingTask has not been registered, it will register it to the task scheduling platform according to the task name, Cron expression and other configuration parameters.

[0067] This application ensures that all tasks in the project are correctly registered by comparing the task list in the project with the task collection in the task scheduling platform, avoiding task scheduling failures due to task omissions and improving system reliability.

[0068] As an optional implementation, before the project in the task scheduling platform is started, the method further includes the following steps: Step S51: configuring interface information in the task scheduling platform, and introducing the calling logic of the interface information in the project, wherein the interface information includes an executor query interface, an executor registration interface, a task query interface, and a task registration interface; Step S52: Adding second annotation information of the task to the project; Step S53: Add an automatic registration manager to the project, wherein the automatic registration manager inherits the monitoring interface and is used to monitor events and execute query and registration processes; Step S54: Package the project and publish it to the setting repository.

[0069] In step S51, the necessary interface information is configured in the task scheduling platform (such as XXL-JOB), including the executor query interface, executor registration interface, task query interface, and task registration interface. These interfaces are used to interact with the task scheduling platform to ensure that the system can automatically complete operations such as querying and registering executors and tasks. Then, the calling logic of these interface information is introduced into the project. This step ensures that the system can automatically communicate with the task scheduling platform at startup, obtain the current status of the executor and task, and perform corresponding operations as needed. The functions of each interface information are as follows.

[0070] Executor query interface: used to query whether the current executor has been registered in the task scheduling platform.

[0071] Executor registration interface: used to register new executors on the task scheduling platform.

[0072] Task query interface: used to query the tasks registered by the current executor in the task scheduling platform.

[0073] Task registration interface: used to register new tasks on the task scheduling platform.

[0074] In this way, the system is able to automatically detect and handle the configuration of actuators and tasks at startup, reducing the need for manual intervention.

[0075] In step S52, a second annotation information (such as @XxlJobRegisterWithParam) is introduced into the project for the newly added task to provide specific configuration parameters of the task. This annotation not only identifies the existence of the task, but also provides detailed configuration information, such as the task name, Cron expression, task processor, etc.

[0076] In this way, the system can obtain detailed configuration information of the task to ensure that the task can be scheduled and executed at the right time and in the right way. For example, the task name is used to uniquely identify the task; the Cron expression is used to define the scheduling time of the task; and the task processor is used to specify the specific execution logic of the task. This design improves the flexibility of the system, allowing developers to set different configuration parameters for each task according to actual business needs.

[0077] In step S53, the system introduces an automatic registration manager into the project. The manager inherits the monitoring interface, which is used to monitor events and execute query and registration processes. Specifically, the following functions are included: 1. Monitoring interface, the automatic registration manager will monitor application startup events to ensure that related operations are automatically executed when the project starts. 2. Query process, the automatic registration manager will call the query interface provided by the task scheduling platform at startup to check the registration status of the executor and task. 3. Registration process, if it is found that an executor or task has not been registered, the corresponding registration interface will be automatically called to register the executor or task to the task scheduling platform. In this way, the system can automatically complete the management and registration of executors and tasks at startup, reducing the need for manual operations and improving the accuracy and efficiency of configuration.

[0078] In step S54, finally, the system packages the project and publishes it to the set warehouse (such as Maven warehouse or Nexus warehouse). This step ensures that the project can be easily deployed and distributed, which is convenient for subsequent version management and maintenance. Among them, the build tool can be used to package the project into a deployable format (such as JAR file or WAR file), and then upload the packaged file to the set warehouse for other team members or production environment to download and deploy. In this way, the project can be easily version controlled and continuously integrated, which improves the efficiency of development and operation and maintenance.

[0079] The present application provides a method flow for automatically configuring tasks based on a task scheduling platform, comprising the following steps.

[0080] 1. Preprocessing stage.

[0081] In the pre-processing stage of the project, you first need to ensure that all necessary dependencies and tools have been installed and configured, including build tools (such as Maven or Gradle), task scheduling platforms (such as XXL-JOB), and related development environments. Developers need to configure the executor query interface, executor registration interface, task query interface, and task registration interface on the task scheduling platform according to the needs of the project. These interfaces will be used for subsequent automated query and registration operations. In addition, you also need to add corresponding configuration items in the project's configuration file, such as xxl.job.executor.appname, to ensure that the system can correctly identify and manage the executor.

[0082] 2. Project initialization and configuration.

[0083] Next, in the project initialization phase, developers need to introduce the interface information provided by the task scheduling platform and write the interface call logic in the project. This step ensures that the system can automatically communicate with the task scheduling platform at startup, obtain the current status of the executor and task, and perform corresponding operations as needed.

[0084] 3. Introduction of automatic registration manager.

[0085] In order to realize the automatic management and registration of tasks, an automatic registration manager needs to be introduced in the project. This manager inherits the listening interface, which is used to listen to the application startup event, and automatically checks the executor configuration and executes the query and registration process at startup. Specifically, the automatic registration manager will call the query interface provided by the task scheduling platform when the project starts to check the registration status of the executor and task. If it is found that some executors or tasks have not been registered, the corresponding registration interface will be automatically called to complete the registration operation. This automation mechanism not only improves the accuracy and efficiency of configuration, but also reduces the workload of manual operations.

[0086] 4. Project packaging and release.

[0087] After completing all configuration and management operations, you need to package the project and publish it to the set repository (such as Maven repository or Nexus repository). Use build tools (such as Maven or Gradle) to package the project into a deployable format (such as JAR file or WAR file) and upload it to the set repository for other team members or production environments to download and deploy. In this way, the project can be easily version controlled and continuously integrated, improving the efficiency of development and operation and maintenance.

[0088] 5. The project is automatically executed.

[0089] After the project is published to the set warehouse, the production environment can automatically execute tasks by downloading and deploying the project package. After the deployment is completed, the system will automatically execute the configuration, query and registration process in the automatic registration manager at startup, and ensure that all business logic can be completed on time.

[0090] 6. Actuator configuration and testing.

[0091] After the project is successfully started, the system will automatically detect the executor configuration of the project. By reading the xxl.job.executor.appname configuration item in the configuration file, the system can determine that the necessary components of the project have been correctly configured. This automatic detection mechanism not only improves the accuracy of the configuration, but also reduces the need for manual intervention. If a valid executor configuration is detected, the system will proceed to the next step; otherwise, the developer will be prompted to make corresponding configuration corrections.

[0092] 7. Executor registration.

[0093] Once the executor configuration is confirmed to be correct, the system will call the executor query interface provided by the task scheduling platform to check whether the target executor has been registered in the task scheduling platform. If the query result shows that the target executor has not been registered, the system will automatically call the executor registration interface to register the executor in the task scheduling platform. This ensures that each executor can be correctly identified and managed, thus laying the foundation for subsequent task scheduling.

[0094] 8.Task scanning and annotation analysis.

[0095] After the executor is registered, the system scans all methods or classes in the project, searches for tasks with the first annotation information @XxlJob, and generates a task list. For each task, the system further checks whether it also has the second annotation information @XxlJobRegisterWithParam. If it has the second annotation information, it parses the configuration parameters. In this way, the system can obtain detailed configuration information of the task, such as the task name, Cron expression, and task processor, to ensure that the task can be executed at the right time and in the right way.

[0096] 9. Task query and comparison.

[0097] The system will call the task query interface provided by the task scheduling platform to obtain the task collection of the current executor that has been registered in the task scheduling platform. Then, the task list scanned in the project is compared with the task collection obtained from the task scheduling platform. If a task is found to exist in the task list of the project but not in the task collection of the task scheduling platform, it can be determined that the task has not been registered in the task scheduling platform. This comparison mechanism can help the system identify which tasks need to be further registered to avoid task scheduling failures due to missing tasks.

[0098] 10.Task registration.

[0099] For those target tasks that have not been registered in the task scheduling platform, the system will register them according to their task names and configuration parameters through the task registration interface provided by the task scheduling platform. This step ensures that all newly added tasks can be recognized and managed by the task scheduling platform in a timely manner, thereby ensuring the smooth progress of task scheduling. For example, if the system finds that orderProcessingTask has not been registered, it will register it to the task scheduling platform according to the task name, Cron expression and other configuration parameters.

[0100] Figure 2 The flowchart for automatically configuring tasks based on the task scheduling platform is as follows: Figure 2 As shown, the following steps are included.

[0101] Step 201: Determine that the project components have been configured through the xxl.job.executor.appname configuration item.

[0102] Step 202: Call the executor query interface to determine whether the target executor has been registered. If so, execute step 204; if not, execute step 203.

[0103] Step 203: Call the executor registration interface to register the executor.

[0104] Step 204: Scan the task list with @XxlJob annotation.

[0105] Step 205: Determine whether the task in the task list has the @XxlJobRegisterWithParam annotation. If not, notify the developer to add the annotation; if yes, execute step 206.

[0106] Step 206: Determine whether the task in the task list also exists in the task scheduling platform. If so, end. If not, execute step 207 and then end.

[0107] Step 207: Call the task registration interface to register the task.

[0108] Based on the same technical concept, the present application provides a device for automatically configuring tasks based on a task scheduling platform, such as Figure 3 As shown, the device comprises: The detection module 301 is used to determine that the necessary components of the project have been correctly configured if the executor configuration of the project is detected after the project in the task scheduling platform is successfully started; An executor registration module 302 is used to register the target executor in the task scheduling platform if it is found that the target executor has not been registered in the task scheduling platform according to the value of the executor configuration, wherein the value of the executor configuration is used to uniquely identify the executor; A parsing module 303, configured to parse the configuration parameters of the target task according to the second annotation information if it is determined that the target task with the first annotation information in the project also has the second annotation information, wherein the first annotation information is used to mark the task and the second annotation information is used to provide configuration information of the task; The task registration module 304 is used to register the target task in the task scheduling platform using the task name and configuration parameters of the target task if the target task does not exist in the task set that the target executor has registered in the task scheduling platform.

[0109] Optionally, the detection module 301 is used to: After the project is successfully started, the executor adds events by automatically registering the manager; When the executor add event is detected, the configuration files in the project are scanned; If the configuration file contains the actuator configuration, then make sure that the necessary components of the project are configured correctly.

[0110] Optionally, the actuator registration module 302 is used to: Use the value of the executor configuration to determine the target executor in the project; If it is found through the preset executor query interface in the task scheduling platform that the target executor has not been registered in the task scheduling platform, the target executor is registered through the preset executor registration interface in the task scheduling platform.

[0111] Optionally, the parsing module 303 is used to: Determine a task list having first annotation information by scanning methods or classes marked with tasks in the project; If the target task in the task list has both the first annotation information and the second annotation information, the configuration parameters of the target task are parsed according to the second annotation information.

[0112] Optionally, the task registration module 304 is used to: Call the preset task query interface in the task scheduling platform to query the task collection of the target executor registered in the task scheduling platform; Compare the scanned task list in the project with the collection of tasks registered in the task scheduling platform; If the target task in the task list does not exist in the task collection, it is determined that the target task has not been registered in the task scheduling platform; According to the task name and configuration parameters of the target task, the task is registered through the preset task registration interface in the task scheduling platform.

[0113] Optionally, the device is also used for: Configure the interface information in the task scheduling platform and introduce the calling logic of the interface information into the project. The interface information includes the executor query interface, executor registration interface, task query interface and task registration interface. Add a second annotation information for the task in the project; Add an automatic registration manager to the project. The automatic registration manager inherits the monitoring interface to monitor events and execute query and registration processes. Package the project and publish it to the set repository.

[0114] like Figure 4As shown, an embodiment of the present application provides an electronic device, including a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404.

[0115] The memory 403 is used to store computer programs.

[0116] In one embodiment of the present application, the processor 401 is used to implement the method for automatically configuring tasks based on the task scheduling platform provided by any one of the aforementioned method embodiments when executing the program stored in the memory 403.

[0117] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the method for automatically configuring tasks based on a task scheduling platform as provided in any of the aforementioned method embodiments are implemented.

[0118] The device embodiments described above are merely illustrative, wherein 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 distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0119] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution, in essence, or the part that contributes to the relevant technology, can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.

[0120] It should be understood that the terms used in the text are only for the purpose of describing specific example embodiments, and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used in the text may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0121] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.

Claims

1. A method for automatically configuring tasks based on a task scheduling platform, characterized in that: The method comprises: After the project in the task scheduling platform is successfully started, if the executor configuration of the project is detected, it is determined that the necessary components of the project have been correctly configured; If it is found according to the value of the executor configuration that the target executor has not been registered in the task scheduling platform, registering the target executor in the task scheduling platform, wherein the value of the executor configuration is used to uniquely identify the executor; If it is determined that the target task in the project having the first annotation information also has the second annotation information, then parsing the configuration parameters of the target task according to the second annotation information, wherein the first annotation information is used to mark the task, and the second annotation information is used to provide configuration information of the task; If the target task does not exist in the task set of the target executor registered on the task scheduling platform, the task is registered in the task scheduling platform using the task name and configuration parameters of the target task.

2. The method according to claim 1, characterized in that: After the project in the task scheduling platform is successfully started, if the executor configuration of the project is detected, determining that the necessary components of the project have been correctly configured includes: After the project in the task scheduling platform is successfully started, the executor adds events by automatically registering the manager; When the executor addition event is monitored, scanning the configuration files in the project; If the configuration file includes the actuator configuration, it is determined that the necessary components of the project are correctly configured.

3. The method according to claim 1, characterized in that If it is found according to the value of the executor configuration that the target executor has not been registered in the task scheduling platform, registering the target executor in the task scheduling platform includes: Determining a target executor in the project using the value of the executor configuration; If it is found through the preset executor query interface in the task scheduling platform that the target executor has not been registered in the task scheduling platform, the target executor is registered through the preset executor registration interface in the task scheduling platform.

4. The method according to claim 1, characterized in that: If it is determined that the target task with the first annotation information in the project also has the second annotation information, parsing the configuration parameters of the target task according to the second annotation information includes: Determine a task list having the first annotation information by scanning the methods or classes marking the tasks in the project; If the target task in the task list has both the first annotation information and the second annotation information, the configuration parameters of the target task are parsed according to the second annotation information.

5. The method according to claim 1, characterized in that If the target task does not exist in the task set registered by the target executor in the task scheduling platform, registering the task in the task scheduling platform using the task name and configuration parameters of the target task includes: Calling a preset task query interface in the task scheduling platform to query the task collection of the target executor registered in the task scheduling platform; Comparing the task list scanned in the project with the task collection registered in the task scheduling platform; If the target task in the task list does not exist in the task collection, determining that the target task has not been registered in the task scheduling platform; According to the task name and configuration parameters of the target task, the task is registered through a task registration interface preset in the task scheduling platform.

6. The method according to claim 1, characterized in that Before the project in the task scheduling platform is started, the method further includes: Configure interface information in the task scheduling platform, and introduce the calling logic of the interface information in the project, wherein the interface information includes an executor query interface, an executor registration interface, a task query interface, and a task registration interface; second annotation information for adding a task to the project; Add an automatic registration manager to the project, wherein the automatic registration manager inherits the monitoring interface and is used to monitor events and execute query and registration processes; Package the project and publish it to the settings repository.

7. A device for automatically configuring tasks based on a task scheduling platform, characterized in that: The device comprises: A detection module, used for determining that necessary components of the project have been correctly configured if the executor configuration of the project is detected after the project in the task scheduling platform is successfully started; An executor registration module, configured to register the target executor in the task scheduling platform if it is found according to the value of the executor configuration that the target executor has not been registered in the task scheduling platform, wherein the value of the executor configuration is used to uniquely identify the executor; A parsing module, configured to parse the configuration parameters of the target task according to the second annotation information if it is determined that the target task with the first annotation information in the project also has the second annotation information, wherein the first annotation information is used to mark the task and the second annotation information is used to provide configuration information of the task; The task registration module is used to register the target task in the task scheduling platform according to the task name and configuration parameters of the target task if the target task does not exist in the task set registered by the target executor in the task scheduling platform.

8. The device according to claim 7, characterized in that The task registration module is used to: Calling a preset task query interface in the task scheduling platform to query the task collection of the target executor registered in the task scheduling platform; Comparing the task list scanned in the project with the task collection registered in the task scheduling platform; If the target task in the task list does not exist in the task collection, determining that the target task has not been registered in the task scheduling platform; According to the task name and configuration parameters of the target task, the task is registered through a task registration interface preset in the task scheduling platform.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-6 when executing a program stored in a memory.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Networked simulation operation supporting system and method

    CN102523104A

  • Websocket-based task progress interaction method and system

    CN114327898A

  • Task scheduling method and device, electronic equipment and storage medium

    CN114356521A

  • Task scheduling method and device under remote multi-activity architecture, medium and related equipment

    CN115454606A

  • Timed task scheduling method and system

    CN119065803A