If Apex Flex Queue is enabled in your organization, you can submit up to 100 batch jobs without getting an error.
The outcome of Database.executeBatch is as follows:
- The batch job is placed in the Apex flex queue and its status is set to Holding as long as the number of jobs in the flex queue hasn’t reached the maximum of 100.
- If the Apex flex queue has the maximum number of jobs, Database.executeBatch throws a LimitException and doesn’t add the job to the queue.
This example is an implementation of the Queueable interface. The execute method in this example inserts a new account.
public class AsyncExecutionExample implements Queueable {
public void execute(QueueableContext context) {
Account a = new Account(Name='Acme',Phone='(415) 555-1212');
insert a;
}
}
To add this class as a job on the queue, call this method:
ID jobID = System.enqueueJob(new AsyncExecutionExample());
by both these options we can use add batch or job in queue. Please provide details.