1

I launch a batch which call a lot of scheduled job. But I reach the governor limit :

Maximum number of Apex classes scheduled concurrently : 100

I'm wondering what happens when this limit is reached. The next scheduled jobs are waiting the number of scheduled jobs is lower than 100 for being executed or are they all cancelled ?

And is there to way to manage the number of scheduled jobs to avoir reaching this limit ? For example wait before schedule a new job if we are near the limit.

  • 1
    Can you elaborate on why you need so many scheduled jobs? – Phil Hawthorn Oct 16 '14 at 9:07
  • I have to update several millions of objects. To do this I need to call an external URL to retreive datas in asynchronous way. I call this URL for each pack of 2000 records. That's why I schedule a lot of jobs. – SF_user Oct 16 '14 at 9:16
  • 1
    Have you considered using Batch Apex and 'daisy chaining' them together? I think that would be more appropriate than scheduling lots of jobs – Phil Hawthorn Oct 16 '14 at 9:39
  • How can I do that ? Because the batch take the several millions objects in entry and then process them 2000 by 2000. How the next batch will know which objects are already processed and which not ? – SF_user Oct 16 '14 at 9:46
  • I think you can update 10,000 at a time (i.e. maximum number of records affected by DML statements). Do you update the record to say that it is updated? If so, you can exclude those records from you Query in the batch start method (i.e. so it doesn't select them for reprocessing). – Phil Hawthorn Oct 16 '14 at 9:51
3

If you get over 100 scheduled jobs limit, the next schedules are being canceled that's why they invented FlexQueue. The way to manage more than 100 jobs scheduled is to use mentioned feature called FlexQueue. It gives you additional 100 jobs to be kept in a queue waiting for execution. Currently this feature is in pilot but it will be released soon (probably Spring'15). For details please check the manual and more generic description about the FQ on Kaplan's blog.

  • this makes sense for the OP's scenario of a batch job launching other jobs, but in cases where you want a job to run on a predefined schedule the flex queue isn't what you want – Ralph Callaway Feb 25 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.