Thursday 13 September 2018

                             Queueable Apex:


Queueable Apex is similar to future methods, but provide additional job chaining and allow more complex data types to be used.

Queueable Apex allows you to submit jobs for asynchronous processing similar to future methods with the following additional benefits:
  • Non-primitive types: Your Queueable class can contain member variables of non-primitive data types, such as sObjects or custom Apex types. Those objects can be accessed when the job executes.
  • Monitoring: When you submit your job by invoking the System.enqueueJob method, the method returns the ID of the AsyncApexJob record. You can use this ID to identify your job and monitor its progress, either through the Salesforce user interface in the Apex Jobs page, or programmatically by querying your record from AsyncApexJob.
  • Chaining jobs: You can chain one job to another job by starting a second job from a running job. Chaining jobs is useful if you need to do some sequential processing.
---------------------------------------------------------------------------------------------------------------------
Queueable Apex:

public class QueueableExample implements Queueable {
public void execute(QueueableContext context) {
        Account a = new Account(Name='Annappa',Phone='11111111');
       insert a;     
    }
}
----------------------------------------------------------------------------------------------------------------------
Execute:

ID jobID = System.enqueueJob(new QueueableExample());
system.debug(jobId);

-------------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment