Defining Queueable Apex implementations
Queueable Apex, like Batch Apex, is defined through the implementation of an Apex interface – in this case, the Queueable
interface.
To define a Queueable Apex job, we simply implement this interface, which has a single method, execute(QueueableContext context)
. A very basic implementation would look as follows:
public class ExampleQueueable implements Queueable { public void execute(QueueableContext context) { //Do something } }
As we discussed, unlike our Batch Apex implementations, we must define the scope for the Queueable Apex job to process. We can do this in two ways. First, we can do this by using a query within our execute
method:
public class ExampleQueueable implements Queueable { public void execute(QueueableContext context) { List<Account> accs...