Previously, you could submit only up to five batch jobs simultaneously. The Apex flex queue enables you to submit up to 100 additional batch jobs for execution. Any jobs that are submitted for execution are in holding status and are placed in the Apex flex queue. Up to 100 batch jobs can be in the holding status. When system resources become available, the system picks up jobs from the top of the Apex flex queue and moves them to the batch job queue. The system can process up to five queued or active jobs simultaneously. The status of these moved jobs changes from Holding to Queued. Queued jobs get executed when the system is ready to process new jobs.
Administrators can modify the order of jobs that are held in the Apex flex queue to control when they get processed by the system. For example, administrators can move a batch job up to the first position in the holding queue so that it’s the first job that gets processed when the system fetches the next held job from the flex queue. Without administrator intervention, jobs are processed first-in first-out—in the order in which they’re submitted. To monitor and reorder held batch jobs in the Salesforce user interface, from Setup click .
Submitting Jobs by Calling Database.executeBatch
When you submit batch jobs by calling Database.executeBatch, the system places your batch job in Holding status before processing the job.
- The batch job is placed in the Apex flex queue, and its status is set to Holding.
- If the Apex flex queue has the maximum number of 100 jobs, Database.executeBatch throws a LimitException and doesn’t add the job to the queue.
When system resources become available, the system picks up the next job from the top of the flex queue for processing and changes its status to Queued.
New AsyncApexJob Status Field Value
The AsyncApexJob object, which represents a batch job, has a new Status field value of Holding. This new status indicates that the job is placed in the flex queue and is waiting to be processed when system resources become available.