Contents
When to use queueable instead of future methods?
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. Because queueable methods are functionally equivalent to future methods, most of the time you’ll probably want to use queueable instead of future methods.
How does the queueable interface work in apex?
Queueable Apex Take control of your asynchronous Apex processes by using the Queueable interface. This interface enables you to add jobs to the queue and monitor them. Using the interface is an enhanced way of running your asynchronous Apex code compared to using future methods.
How to test the execution of a queueable job?
This example shows how to test the execution of a queueable job in a test method. A queueable job is an asynchronous process. To ensure that this process runs within the test method, the job is submitted to the queue between the Test.startTest and Test.stopTest block.
How does a queueable process in Salesforce work?
The system executes all asynchronous processes started in a test method synchronously after the Test.startTest statement. Next, the test method verifies the results of the queueable job by querying the account records that the job updated.
How to capture queueable class status when job is completed?
Put you queue able code in try/catch and update the job status to complete at the end of the queuable as last line in try block or as a failure in the catch block . It may not work if the errors are non catch-able like limit exceptions.
Can You schedule a queueable class in apex?
In Apex code (be it Queueable, Batch job) once your make changes to db, you cannot make callouts. So make sure you adjust your code accordingly (either to separate into different jobs or do all callouts and then make db changes) [2] Scheduled job can start 20 other queueable jobs and one queueable job can start one other queueable job.
How to schedule a queueable class in Salesforce?
So make sure you adjust your code accordingly (either to separate into different jobs or do all callouts and then make db changes) [2] Scheduled job can start 20 other queueable jobs and one queueable job can start one other queueable job. This allows you to chain your jobs.