Brightspot CMS Developer Guide

Schedule tasks


The com.psddev.dari.util.Task class includes the following schedule methods to start a task at a specified time and to run it in periodic intervals. Unlike the submit method that runs a task one time and stops it, the schedule methods run the task repeatedly until it is manually stopped with the Task Status tool.

  • schedule(double initialDelay) runs a task with a delayed start and without pause. The schedule method below runs the task one hour after it is started. If initialDelay is zero, then the task starts immediately.
public MigrationTask() {
    /* Run repeatedly with a delayed start */
    task.schedule(3600.0);
}

  • scheduleWithFixedDelay(double initialDelay, double periodicDelay) runs a task with a delayed start, with a periodic delay, and with a single execution of the task between delays. The scheduleWithFixedDelay method below starts the task immediately, executes the doTask method one time, delays execution for one hour, then repeats the execution-delay pattern.
public MigrationTask() {
    /* Run repeatedly, delaying for one hour after a single execution of the task */
    task.scheduleWithFixedDelay(0,3600.0);
}

  • scheduleAtFixedRate(double initialDelay, double periodicDelay) runs a task with a delayed start and with fixed execution and delay times. The scheduleAtFixedRate method below starts the task immediately, repeatedly executes doTask for one hour, delays execution for one hour, then repeats the execution-delay pattern.
public MigrationTask() {
    /* Run repeatedly with one-hour execution and delay periods */
    task.scheduleAtFixedRate(0,3600.0);
}

Previous Topic
Creating a background task
Next Topic
Repeating tasks
Was this topic helpful?
Thanks for your feedback.
The elements that get you up and running in a matter of days, from pre-built content types, to modules, to landing pages.

Content types
Modules
Landing pages
Everything you need to manage and administer content within Brightspot CMS, including plug-and-play integrations.

Dashboards
Authoring content
Workflows
Admin configurations
A guide for installing, supporting and administering code on the Brightspot platform, including integrations requiring developer support to use.

Field types
Content modeling
Rich-text elements
Images