Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
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
1ID highPriorityJobId = Database.executeBatch(new HighPriorityBatchClass(), 200);
2boolean 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