-
Book Overview & Buying
-
Table Of Contents
Mastering Apex Programming - Second Edition
By :
Queueable Apex jobs are invoked using the System.enqueueJob method, as shown in the following code snippet:
Id apexJobId = System.enqueueJob(new ExampleQueueable());
As we can see, the System.enqueueJob method returns an Id for an AsyncApexJob sObject instance that we can use to monitor the status of the Queueable Apex job in the same way we monitor the job in a Batch Apex context. It should be noted, however, that as Queueable Apex does not process batches of records, JobItemsProcessed and TotalJobItems will always return 0.
We can also include a minimum delay for starting a Queueable job by using the overloaded System.enqueueJob method, in which we provide several minutes between 0 and 10 (note that with a value of 0, the job is run as soon as possible). The following snippet would add a five-minute delay before our job can execute:
Id apexJobId = System.enqueueJob(new ExampleQueueable(), 5);
It should also be noted that administrators can also...
Change the font size
Change margin width
Change background colour