Summary
In this chapter, we looked in detail at how to use Scheduled Apex to define Apex classes that can be set to execute at some point in the future. We began the chapter by discussing the use cases for Scheduled Apex, namely one-off executions and repeating jobs. After discussing the definition of these use cases and how we might utilize Scheduled Apex, we looked at how we define an Apex class for scheduling by implementing the Schedulable
interface.
The majority of the chapter was spent discussing the different ways we can schedule an Apex class, using either the Apex Scheduler or the System.schedule
method, and the difference between this and System.scheduleBatch
. After discussing the issues and limitations in place to prevent so-called suicidal scheduling, we looked at monitoring scheduled jobs and the limits in place around scheduling Apex classes.
We finished the chapter by reviewing how we can test Scheduled Apex code and the different ways of verifying behavior. This...