0

I have seen Apex Batch Job Chaining Limits, but my questions is little bit different so still wanted to confirm. I was looking to chain 3 batch classes.

Below would be number of batch classes.

  1. BatchCls1
  2. BatchCls2
  3. BatchCls3

I want to call Batch 1 will be called from ScheduleApex class and BatchCls2 will be called from BatchCls1 finish method and BatchCls3 will be called from BatchCls2 finish method.

In above case would there be any stack depth issue or any other limitations that i should keep in mind as I'm going 3 levels deep?

Note: I don't have any code yet as I'm still in the design phase and wanted see foreseeable limitations

  • 1
    "stack depth" is a real thing, but it has to do with the depth of execution calls within a single context. If you don't understand it, try reading about the call stack. – sfdcfox Aug 29 '18 at 23:33
  • @sfdcfox Sorry for the confusion my main idea here is to understand if the chain length blows any limits! Thanks for the resource. – codeyinthecloud Aug 30 '18 at 0:10
3

By "stack depth" I presume you mean "chain length"; each start/execute/finish runs in its own transaction and so has its own stack.

I know of no absolute limit: chaining is very kind to the platform because things run in a sequence rather than in parallel. But worth some approximate calculations to see if you will run anywhere near this limit recognizing that each start/execute/finish counts as one of these:

Description
The maximum number of asynchronous Apex method executions (batch Apex, future methods, Queueable Apex, and scheduled Apex) per a 24-hour period

Limit
250,000 or the number of user licenses in your org multiplied by 200, whichever is greater

PS

I'd forgotten about the limit in tests that sfdcfox comments about. One way around that is shown in Testing a Database.Batchable implementation.

| improve this answer | |
  • I’m aware of the asynchronous daily limit. Thanks for pointing it. End of the day it doesn’t matter how long the chain length is it simply falls into the above limit bucket is that correct? – codeyinthecloud Aug 30 '18 at 0:09
  • 2
    @codeyinthecloud note that sandboxes do have a chain limit (not that you'd hit it with just 3 classes), but production orgs can chain indefinitely until they reach the daily limit. – sfdcfox Aug 30 '18 at 0:12

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.