Queueable Apex

What is Queueable Apex in Salesforce - All You Need to Know

Delivered in Winter '15, Queueable Peak is basically a superset of future strategies with some extra #awesomesauce. We took the effortlessness of future strategies and the force of Group Summit and combined them as one to shape Queueable Zenith! It gives you a class structure that the stage serializes for you, a disentangled interface without start and finish techniques, and even permits you to use something beyond crude contentions! It is called by a straightforward System.enqueueJob() strategy, which restores a task ID that you can screen. It thrashes cut bread hands! 

Queueable Pinnacle permits you to submit occupations for nonconcurrent handling like future techniques with the accompanying extra advantages: 

Non-crude sorts: Your Queueable class can contain part factors of non-crude information types, for example, sObjects or custom Zenith types. Those items can be gotten to when the work executes

Observing: When you present your work by conjuring the System.enqueueJob strategy, the technique restores the ID of the AsyncApexJob record. You can utilize this ID to distinguish your work and screen its encouraging, either through the Salesforce UI in the Pinnacle Occupations page, or automatically by questioning your record from AsyncApexJob

Binding positions: You can anchor one occupation to another work by beginning a second occupation from a running position. Anchoring occupations is valuable on the off chance that you need to do some consecutive preparation.

dont miss out iconDon't forget to check out: How To Use Database.Stateful Interface In Batch Apex In Salesforce

Queueable Versus Future

Since queueable techniques are practically identical to future strategies, more often than not you'll presumably need to utilize queueable rather than future strategies. Nonetheless, this doesn't really mean you should return and refactor all your future techniques at the present time. 

Another motivation to utilize future strategies rather than queueable is the point at which your usefulness is some of the time executed simultaneously, and at times non concurrently. It's a lot simpler to refactor a strategy as such than changing over to a queueable class. This is helpful when you find that piece of your current code should be moved to async execution. You can just make a comparative future strategy that wraps your coordinated technique like so:

static void myFutureMethod(List<String> params) {
    // call synchronous method

Queueable Syntax

public class SomeClass implements Queueable {
    public void execute(QueueableContext context) {
        // awesome code here

Things to Remember

Queueable Summit is an extraordinary new instrument yet there are a couple of things to keep an eye out for: 

The execution of a lined occupation counts once as a detriment to as far as possible for offbeat Summit strategy executions

You can amount to 50 positions to the line with System.enqueueJob in a solitary exchange. 

dont miss out iconCheck out another amazing blog by Sumit here: Future Methods in Apex | The Salesforce Developer Guide

When binding positions, you can add just one occupation from an executing position with System.enqueueJob, which implies that just a single kid occupation can exist for each parent queueable work. Beginning different kid occupations from a similar queueable occupation is a no-no. 

No restriction is upheld on the profundity of tied positions, which implies that you can affix one occupation to another work and rehash this interaction with each new kid task to connect it to another youngster's work. Notwithstanding, for Engineer Version and Preliminary organizations, the greatest stack profundity for fastened positions is 5, which implies that you can chain occupations multiple times and the most extreme number of occupations in the chain is 5, including the underlying guardian queueable work.


Popular Salesforce Blogs