Introduced for some time now particularly in Winter 15. Queueable Apex addresses some short coming of the @future methods. It’s an offspring of the marriage of @future methods and Batch Apex.
Queueable Apex allows you to submit jobs for asynchronous processing similar to future methods with the following additional benefits:
- Non-primitive types – you can pass SObjects and custom apex types
- Monitoring – you can monitor the job from the Apex jobs page in Setup or query the AsyncApexJob record
- Chaining Jobs – create sequential jobs
How to use Queueable Apex:
- Create a class that implements the Queueable interface
- If you are going to make callouts you need to extend your implementation to Datatabase.AllowCallouts
- To allow multiple primitive types, create a constructor and call the public void execute method.
- To execute the class, call it from your logic
- There you can chain jobs by calling another Queueable class on the execute method.
Things to note: This counts to your limit of 250 limits for asynchronous process per 24 hours.