Thursday 22 September 2016

Queueable Apex In Depth

The class which implements the Queueable Interface are basically called as Queueable apex class .
The interface has only one method execute which takes the parameter of QueableContext which has one method.

Below are the  classes and methods related to Queueable Apex

A.Queueable (Interface)
   1.public void execute(QueueableContext context)
B.QueableContext (Interface)
   2.public ID getJobId()

C.Limit(Class)
1.public static Integer getLimitQueueableJobs()
2public static Integer getQueueableJobs()

D.System(Class)

  1.public static Boolean isQueueable()
  2.public static ID enqueueJob(Object queueableObj)

Examples :

public class QueueableClass implements Queueable { 
    public void execute(QueueableContext context) {
        // TODO
    }

}


Queueable Apex Limits:

1.You can add up to 50 jobs to the queue with System.enqueueJob in a single transaction. 
2.Limits.getQueueableJobs() helps to check how many queueable jobs have been added in one transaction
3.No limit is enforced on the depth of chained jobs, which means that you can chain one job to another job and repeat this. 
4.Can add only one job from an executing job with System.enqueueJob, means that only child job can exist for parent queueable job
5.For Developer Edition and Trial organizations, the maximum stack depth for chained jobs is 5 .