All Products
Search
Document Center

Creation and Management of Scheduled Task

Last Updated: Aug 21, 2020

This topic describes how to add and manage scheduled tasks in the Scheduler console.

Add a scheduled task

Log on to the Scheduler console and click New task. In the dialog box that appears, enter scheduled task information as prompted and click OK.

Basic task information

  • Task name: We recommend that you name a scheduled task in the APPNAME_FUNCTION format. The task name must be consistent with the actual code.
  • Application name: The value must be the same as the app name that you configure in the project. When the scheduled task is executed, requests are sent based on app name.
  • CRON expression: the string that defines the period and time when the scheduled task is executed. For specific syntax, Detailed explanation of Cron expressions. The scheduling center of SOFAStack MS Platform uses Quartz to implement scheduled task execution. For specific configuration rules, see Quartz Tutorials.

Note: In the early stage of development and joint debugging, we recommend that you use the Cron expression 0 0 0 * * ? , which triggers scheduled tasks at a low frequency. After the development is completed, adjust the frequency to a desired one for automatic execution of the scheduled tasks.

Advanced settings

  • Routing strategy:
    • Random: Each time a task is triggered, a random client is called to balance the load. This is the default policy.
    • Oriented: Each time a task is triggered, a fixed client is called to facilitate fault locating. However, you cannot specify which client to call when using this policy.
    • Polling: IP addresses of clients connected to the server are arranged in order. Each time a task is triggered, a client is called in order.
  • Trigger type: Valid values include ONEWAY and CALLBACK.
    • ONEWAY: This trigger type is applicable to non-important tasks with a high execution frequency. Execution records are not written into the database. You cannot view execution records on the console.
    • CALLBACK: This trigger type is applicable to important tasks with a low execution frequency. All execution records are written into the database. The execution of a task is successful only after a successful callback. Multiple policies of processing execution failures are available. The interval for triggering tasks must be longer than 5 minutes.
  • Timeout: This parameter is required and applicable to tasks whose trigger type is CALLBACK. This parameter specifies the timeout interval of a scheduled task, in minutes or seconds. If no callback occurs after the specified interval, the task execution fails.
  • Failure Strategy: This parameter is required and applicable to tasks whose trigger type is CALLBACK. Valid values include:
    • No retry
    • Retry three times
    • Retry till the next trigger
  • Description: This parameter is optional. Use this parameter to describe a scheduled task in detail. For example, describe the business meaning and impact scope.

After the scheduled task is added, it is periodically executed at the expected frequency.

Manage scheduled tasks

After logging on to the console, you can manage scheduled tasks, including enabling, disabling, manually triggering, modifying, and deleting scheduled tasks.

On the scheduled task page, you can perform the following operations in addition to adding a scheduled task:

  • On/Off: If the state is On, the task is executed automatically. If you toggle off the switch, that is, change the state to Off, the task is not executed automatically.
  • Trigger: Each time you click Trigger, the task is executed once in the background.
  • Edit: After clicking Edit, you can edit the task name, Cron expression, and system name.
  • Delete: You can click Delete to delete a scheduled task.