+ Start a Discussion

Cumulative timeout and webservice calls for a single transaction

I am calling a webservice on an external system. At first, the webservice took one address as input, did some work in the external system and then returned some data. I need to do this for many addresses in one transaction.

Using the current webservice I cannot do more than 10 callouts however due to the governor limits.
So then after messing around with Batch Apex and future methods (several transactions but in which I run into other issues with other limits and User interaction problems) I figured the best way would be to change the webservice so that it takes a list of addresses instead.

No I can see that there is another limit. The three paragraphs below is directly taken from the apex documentation on salesforce.

- A single Apex transaction can make a maximum of 10 callouts to an HTTP request or an API call.
- The default timeout is 10 seconds. A custom timeout can be defined for each callout. The minimum is 1 millisecond and the maximum is 120,000 milliseconds. See the examples in the next section for how to set custom timeouts for Web services or HTTP callouts.
- The maximum cumulative timeout for callouts by a single Apex transaction is 120 seconds. This time is additive across all callouts invoked by the Apex transaction.

Since I have a problem testing this, can anyone verify if number three above (in bold) means that even if I now make several calls with a list of addresses in each (to avoid timeout for a single call which is for number 2 above), my operation will still fail if the external system all together for all addresses need more than 120 seconds to deliver back the responses to me?

If this is the case I have no idea how to handle this other than to continue with the future method approach which gives me a limit of 10*10 addresses instead and problem rerendering the page for the user since the future calls that I create will have no connection with the page at all since these jobs are asynchronous. I am working with PushTopic as a possible solution and hope that will help me some.

But please first if someone can confirm and translate the above for me about cumulative timeout.

Thanks / Niklas
The following thread might answer your questions