You need to sign in to do that
Don't have an account?
Kendall Buchanan
Asynchronous tasks are often very slow
Our org has one asynchronous task, triggered by a @future. It's simply an HTTP request to an external webservice. Usually the @future processes within a second or two. Often, however, it can take 30, 60, 120 seconds. We've seen it take as long as *three or four minutes* to process!
Is this normal? Is there any way to overcome this?
Here's the relevant code (simplified):
Is this normal? Is there any way to overcome this?
Here's the relevant code (simplified):
public class SyncClass { public static void requestSync() { String endpoint = System.Label.Sponsors_App_Endpoint; HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); req.setEndpoint(endpoint + '/my-endpoint'); req.setMethod('POST'); req.setBody(''); try { res = http.send(req); } catch(System.CalloutException e) { System.debug('Callout error: '+ e); System.debug(res.toString()); } } @future(callout=true) public static void asyncRequestSync() { SyncClass.requestSync(); } }
As per the salesforce documentation, there is no way to control the order of execution of async calls as salesforce picks them up in order they were put through, async calls will be processed when ever there are enough resources to utilize on the saleforce.com server side. Please refer to the below document:
http://www.salesforce.com/us/developer/docs/async_processing/salesforce_async_processing.pdf
Time for execution depends on lot more factors which can be found in the reference link.
Hope that content helps:
Thanks,
Balaji