Queueable is an asynchronous apex which runs in the background without having you to wait for the task to finish. Queueable is an enhanced and advance version of future apex. It has the simplicity of future method but the power of batch apex. It supports both primitive and non-primitive datatypes. Unlike batch apex It has simplified syntax without start and finish methods.
Syntax:
Example:
Let's update Account object's description using queueable apex.
Chaining of queueable:
Chaining of queueable apex is the practice of enqueuing multiple queueable jobs sequentially. This practice is useful for scenarios where you want to perform multiple actions in a sequence. Chaining allows us to execute series of code one after other which helps in maintaining a clear order and dependency between them.
below is the example for chaining of queueable apex,
Advantages:
- Since queueable apex run in their own thread, governor limits are higher than synchronous apex.
- When we queue our job using system.enqueue method, this method returns an Id which can be used to monitor the queued job. We can monitor the job using user Interface in Apex job or by querying the object AsyncApexJob.
- We can chain queueable jobs.
- We can implement Database.AllowCallouts which enables making callouts to external services.
Note:
- Each org can have up to 50 jobs in a queue at a time.
- Maximum chain depth is 5.
- You can create only one child for one queueable.
- Total heap size for queueable job is 12MB.
- You can only send up to 10 email per transaction using queueable.

.png)
.png)
Comments
Post a Comment