You are here:
Monitoring the Apex Flex Queue
Use the Apex Flex Queue page to view and reorder all batch jobs that have a status of Holding. Or reorder your batch jobs programmatically using Apex code.
Required Editions
| Available in: Salesforce Classic (not available in all orgs) and Lightning Experience |
| Available in: Enterprise, Performance, Unlimited, Developer, and Database.com Editions |
You can place up to 100 batch jobs in a holding status for future execution. When system resources become available, the jobs are taken from the top of the Apex flex queue and moved to the batch job queue. Up to five queued or active jobs can be processed simultaneously for each org. When a job is moved out of the flex queue for processing, its status changes from Holding to Queued. Queued jobs are executed when the system is ready to process new jobs.
You can reorder jobs in the Apex flex queue to prioritize jobs. For example, you can move a batch job up to the first position in the holding queue to be processed first when resources become available. Otherwise, jobs are processed “first-in, first-out”—in the order in which they’re submitted.
Monitoring and Reordering the Apex Flex Queue
The Apex Flex Queue page lists all batch jobs that are in Holding status. You can view information about the job, such as the job ID, submission date, and Apex class. By default, jobs are numbered in the order submitted, starting with position 1, which corresponds to the job that was submitted first. You can change the position of a job by clicking Reorder and entering the new position number. The job is moved to the specified position unless the position number is greater than the number of jobs in the queue. In that case, the job is placed at the end of the queue. When you move a job, all other jobs in the flex queue are reordered and renumbered accordingly.
When the system selects the next job from the Apex flex queue for processing, the job is moved from the flex queue to the batch job queue. You can monitor the moved job in the Apex Jobs page by clicking Apex Jobs.
Alternatively, you can use System.FlexQueue Apex
methods to reorder batch jobs in the flex queue. To test the flex queue, use the and getFlexQueueOrder() methods in the
enqueueBatchJobs(numberOfJobs)System.Test class.

