Things to Remember while working with Queueable Apex:
- 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.
- System.enqueueJob method, the method returns the ID of the AsyncApexJob record which can be used to identify and monitor the progress of the job, either through Salesforce UI in Apex jobs or by querying from AsyncApexJob.
- Chaining of one job to another job by starting a second job from a running job is possible.
- We can’t chain queueable jobs in an Apex test, doing so results in an error. To avoid errors, we can check if Apex is running in test context by calling Test.isRunningTest() before chaining jobs.
- We can add up to 50 jobs to the queue with System.enqueueJob in a single transaction.
- When chaining jobs, we can add only one job from an executing job with System.enqueueJob
- No limit is enforced on the depth of chained jobs. However, for Developer Edition and Trial orgs, the maximum stack depth for chained jobs is 5.