---
schema_version: "1"
id: 2c6574f9daea211fe8d546b88f28976efbb05a624022caf7b136950d5aff02f4
title: Monitoring the Apex Flex Queue
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/code_apex_flex_queue.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.code_apex_flex_queue.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 901fd0c90be394d895022b5e0a3b8e74ec669d6da1e2fd1bed6d94947f03ba5a
description: 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.
products:
  - Salesforce Platform
release: "264"
---
# 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

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Salesforce Classic (<a href="https://help.salesforce.com/s/articleView?id=xcloud.overview_edition_lex_only.htm&amp;type=5&amp;language=en_US" target="_blank">not available in all orgs</a>) and Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Enterprise</strong>, <strong>Performance</strong>, <strong>Unlimited</strong>, <strong>Developer</strong>, and <strong>Database.com</strong> Editions</td></tr></tbody></table>

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](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_code-264-0-0-production-enus/789bc523-706b-4ae4-8fe9-be6322e38b6b/images/icon_note.png)

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.

#### See Also

- [_Apex Reference Guide_: FlexQueue Class](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_FlexQueue.htm)
- [_Apex Reference Guide_: `enqueueBatchJobs(numberOfJobs)`](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_test.htm#apex_System_Test_enqueueBatchJobs)
- [_Apex Reference Guide_: `getFlexQueueOrder()`](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_test.htm#apex_System_Test_getFlexQueueOrder)