I have to implement in salesforce many inbound synchronous rest services.
What are the salesforce limits that I have to consider?
I found only the following: API Requests. A long-running API request is one that takes over 20 seconds. Salesforce allows only 25 to run at a time in an org.. For this limit salesforce cannot receive more than 25 concurrent calls with processing longer than 20 seconds. Is it right?
Moreover, can an inbound rest service perform a callout? I know that exists Apex limit of 10 synchronous requests that last longer than five seconds, is it possible to use the Continuation for a callout started from a rest service? Using the Continuation, the callout execution time is added to time execution of the inbound call transaction?
I clarify the scenario: A system "A" calls a Rest Resource on my Salesforce org. In the Rest Resource class I have a method that has to call another system "B" to retrieve some data. Then I have to send a response to the inbound calling system "A" using the data I retieved from "B".
Update: I created the following rest resource in my Developer Edition (where the Concurrent Api request limit is 5). I don't understand why I don't receive the "Concurrent API request limit Exception" by invoking 30 simultaneous post requests with secondSleepTime=100 (I receive every httpresponse after 100 seconds).
@RestResource(urlMapping='/TEST/*') global with sharing class MyRestResource {
@HttpPost
global static String doPost(String secondSleepTime,String callName) {
try{
System.debug('@@@ START callName='+callName);
Long startTime = DateTime.now().getTime();
Integer secSleepTime=Integer.valueOf(secondSleepTime);
MyRestResource.sleep(secSleepTime);
Long finishTime = DateTime.now().getTime();
System.debug('@@@ END callName='+callName);
return String.valueOf(finishTime-startTime);
}
catch (Exception e)
{
System.debug('@@@ Exception callName='+callName+ 'Exception='+e.getStackTraceString());
}
return null;
}
public static void sleep(Integer sleepSeconds) {
Long startTS = System.currentTimeMillis();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://1.cuzillion.com/bin/resource.cgi?sleep=' + sleepSeconds);
req.setMethod('GET');
Http http = new Http();
req.setTimeout(120000);
HTTPResponse res = http.send(req);
Long duration = System.currentTimeMillis() - startTS;
System.debug('Duration: ' + duration + 'ms');
}