What is the maximum estimated time before execution of an @future
annotated method starts, after the call to the function is made? Is this in the order of seconds? Or can it take up to minutes before the method is started? Are there any guidelines for this?
update; after reading Shailesh Deshpande’s answer, I’m getting to a more discussion prone level: we have been telling some customers that we’re the system responds in real-time. Do we need to notifiy them about this possible “not-real-time”-part of the system, or would you say that an Apex-based system that uses @future
can still be sold as being real-time?
I’m not sure if this is a correct place for this question, feel free to close this if you don’t think it fits here.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
There is an official explanation from Salesforce,
Asynchronous Processing in Force.com
http://www.salesforce.com/us/developer/docs/async_processing/salesforce_async_processing.pdf
Method 2
There are no guarantees, like @Shailesh Deshpande stated.
This Advanced Asynchronous Apex DF 12 session has a good high level overview of how some of the processing prioritization is done.
The lag time can depend on the volume of executions in other orgs in the multi-tenant environment. Salesforce allocates more threads for synchronous processing since that is by far their main use case (e.g., actual SF users). Also, there is a lookahead algorithm for the queue that will move some of your org’s jobs to the back of the queue if your jobs occupy more than a certain percentage (e.g., 60%) of the first X jobs in queue. This is to prevent a single org from monopolizing all asynch processing.
I have never had any issues with @future methods not executing almost immediately.
Method 3
The time is not gauranteed. It usually executes immediately in few seconds, however, as they are executed asynchronously, the time is not gauranteed. Also, remember that any method using the future annotation requires special consideration because the method does not necessarily execute in the same order it is called
Method 4
We intermittently experience delays of over an hour on @future calls. This delay is independent of the number of calls submitted. We opened a ticket and were told that there is no SLA on asynchronus future calls.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0