FlexQueue Class
Namespace
Usage
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.
Use this class’s methods to reorder your Holding jobs in the flex queue. As best practice and for safe usage, a FlexQueue reorder method must be the final statement in a transaction.
Example
ID highPriorityJobId = Database.executeBatch(new HighPriorityBatchClass(), 200);
boolean jobMovedToFrontOfQueue = FlexQueue.moveJobToFront(highPriorityJobId);
FlexQueue Methods
The following are methods for FlexQueue.
moveAfterJob(jobToMoveId, jobInQueueId)
Signature
public static Boolean moveAfterJob(Id jobToMoveId, Id jobInQueueId)
Parameters
Return Value
Type: Boolean
moveBeforeJob(jobToMoveId, jobInQueueId)
Signature
public static Boolean moveBeforeJob(Id jobToMoveId, Id jobInQueueId)
Parameters
Return Value
Type: Boolean
moveJobToEnd(jobId)
Signature
public static Boolean moveJobToEnd(Id jobId)
Parameters
- jobId
- Type: Id
- The ID of the job to move.
Return Value
Type: Boolean
moveJobToFront(jobId)
Signature
public static Boolean moveJobToFront(Id jobId)
Parameters
- jobId
- Type: Id
- The ID of the job to move.
Return Value
Type: Boolean