Add a task

To add a bean-mode task, first develop a job handler based on the XXL-JOB executor source code, and then record the value defined by @JobHandler for the JobHandler class in the executor.

  1. On the top navigation bar, select Cloud Services, and then select Distributed Task Scheduling Platform from the Middleware menu.

  1. From the left navigation pane, select Task Management.

  1. Click Create Task to add a task.

  1. Configure the task parameters as needed.

Table-1 Configuring task parameters

Parameter

Description

Executor

Select an executor to bind the task and the executor. You must bind a task to an executor. An executor can be bound to multiple tasks.

In task scheduling, the scheduling platform can automatically discover the registered executors and thus discover the tasks bound to the executors.

Task Description

Enter the description for the task to facilitate task searching.

Cron Expression

Specify a Cron expression to define the execution time for the task.

For information about the format and syntax of a Cron expression string, see the Cron related documentation.

The Business Apps platform has converted the complicated Cron expression string configuration into visual configuration. Click the input box to activate the configuration interface. Select the time conditions, and the Cron expression string will be automatically generated.

  • The time condition tabs include second, minute, hour, day, month, week, and year. You can select multiple time conditions as needed. The task will be executed in the time period that matches all the time conditions.

  • Each time condition tab supports several time conditions. The following provides the descriptions on the day conditions for task execution:

  • Per Day Allowed WildcardsExecutes the task every day.

  • No Specific DayDoes not restrict the day.

  • Range From X-Y DaySpecify a range of days. The task will be executed on day X to day Y of the month.

  • Start From X Day, Repeat Every Y Day AfterwardsThe task will be executed on day X of the month and repeat every Y days until stopped.

  • On X of the Month. Use Nearest One If Not WeekdayExecutes the task on the specified weekday of the month. If the specified day is not a weekday, executes the task on the nearest weekday to the specified day.

  • Last Day of This Month—Executes the task on the last day of the month.

  • Select—Select the days (1 to 31) and the task will be executed on the selected days of each month.

  • You can configure multiple time condition tabs to specify the execution time. The following is some examples:

  • Execute the task every 30 seconds from 2:10 pm to 2:44 pm on Wednesday in the second week on March every year.

  • Execute the task every 3 hours starting from 10:00 am on the nearest weekday to the 25th day of March, June, September, and December (months 3, 6, 9, and 12) in 2020 to 2022.

Scheduling Algorithm

Select the scheduling algorithm used to select an executor instance for the task when the executor is a cluster of multiple executor instances.

  • FirstAlways selects the first executor.

  • LastAlways selects the last executor.

  • RoundSelects an executor through round selection.

  • RandomSelects an executor randomly.

  • Consistent HashEvenly distributes tasks to different executors and selects the same executor for the same task.

  • Least Frequently UsedSelects the least often used selector.

  • Least Recently UsedSelects the longest not used selector.

  • FailoverGoes through the selectors in turn and selects the first selector that is not faulty.

  • BusyoverGoes through the selectors in turn and selects the first selector that is not busy.

  • Sharding broadcastTriggers all executors in the cluster to execute the task once through broadcast, and the sharding parameters are transferred at the same time. The sharding task will be executed according to the sharding parameters.

Operation Mode

  • BEANA task is maintained in the executor as a JobHandler and will be executed according to the JobHandler properties.

  • GLUE (Java)The task source code is maintained in the scheduling center. It is actually a Java code segment inherited from IJobHandler and must be executed in the executor instance.

  • GLUE (Shell)A task in this mode is a shell script. The task source code is maintained in the scheduling center.

  • GLUE (Python)A task in this mode is a Python script. The task source code is maintained in the scheduling center.

  • GLUE (PHP)A task in this mode is a PHP script. The task source code is maintained in the scheduling center.

  • GLUE (NodeJS)A task in this mode is a NodeJS script. The task source code is maintained in the scheduling center.

  • GLUE (PowerShell)A task in this mode is a PowerShell script. The task source code is maintained in the scheduling center.

Block Handling

Specify the policy used to process a scheduling task request when scheduling tasks are congested in the executor.

  • Single-Machine Serial BatchThe default processing policy. The executor adds the task scheduling request into the FIFO queue and executes it serially.

  • Discard Subsequent Scheduling TasksThe executor discards the task scheduling request and marks it failed if there is already a scheduling task.

  • Overwrite Previous Scheduling TasksAfter receiving a task scheduling request, the executor stops the running task, clears the task queue, and then executes this received scheduling task.

Job Handler

Specify the job handler for the task.

This field is required when the operation mode is bean. It represents the value defined by @JobHandler for the JobHandler class in the executor.

Child Task IDs

Specify the child task IDs.

After a task is executed successfully, its child tasks (identified by child task IDs) will also be executed once automatically.

The ID of a task is automatically generated after the task is added. You can obtain task IDs from the task list.

Task Retries

Specify the number of scheduling retries. If all the retries fail, the task fails.

Task Timeout

Specify the task execution timeout time. If the execution of a task exceeds the timeout time, the task will be stopped.

Send Alarms via Emails

Specify the email addresses used to receive task failure alarms. Separate the email addresses by commas.

Task Parameter

Configure the parameter required for execution of the task.

 

  1. Click OK.