Registering a recurring job is just as simple as registering a background job – you only need to write a single line of code:
This line creates a new recurring job entry in the
StorageProvider. A special component in
BackgroundJobServer checks the recurring jobs on a minute-based interval and then enqueues them as fire-and-forget jobs. This enables you to track them as usual.
Remark: for recurring methods to work, at least one BackgroundJobServer should be running all the time
The Cron class contains different methods and overloads to run jobs on a minute, hourly, daily, weekly, monthly and yearly basis. You can also use standard CRON expressions to specify a more complex schedule:
All these methods are also available on the JobScheduler bean:
Each recurring job has its own unique identifier. In the previous examples it was generated implicitly, using the type and method names of the given call expression (resulting in “
System.out.println” as the identifier). The
JobScheduler class contains overloads that take an explicitly defined job identifier. This way, you can refer to the job later on.