With the recent Spring '15 release, Apex developers have a new asynchronous tool, queueable Apex classes. At first glance, queueable classes are very similar to @future
annotated methods. A closer look, however, reveals their true power. There are three key differences between @future
and queueable classes:
The method for enqueueing a job returns an ID, allowing you to monitor its progress much like a batch or scheduled job
Queueable jobs accept
sObjects
Finally, and perhaps most importantly, queueable code can invoke queueable code—no more exceptions complaining about how you are trying to call the
@future
methods or batch methods from an@future
context
Implementing the queueable interface is very similar to implementing the batchable or schedulable interfaces. Simply define your class as implementing the queueable interface and implement the execute()
method. Likewise, your implementation of the execute()
method must accept one argument of the QueueableContext
type. This...