Loading
Salesforce now sends email only from verified domains. Read More
Enhance Salesforce with Code
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Monitoring the Apex Flex Queue

          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.

          Note
          Note In the Salesforce user interface, the job at the top of the flex queue is in position 1. However, when you work with the flex queue programmatically, the first position in the flex queue is at index 0.

          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 getFlexQueueOrder() and enqueueBatchJobs(numberOfJobs) methods in the System.Test class.

           
          Loading
          Salesforce Help | Article