Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Make Long-Running Callouts with Continuations
Using continuations has some advantages, including the capability to make callouts in parallel.
The framework queues up actions before sending them to the server. This mechanism is largely transparent to you when you’re writing code but it enables the framework to minimize network traffic by batching multiple actions into one request (XHR). The batching of actions is also known as boxcar’ing, similar to a train that couples boxcars together. Since continuations can be long-running requests, the framework essentially treats continuations as background actions. Continuations aren't boxcar'ed with other requests so they don't block other actions while they are running.
An asynchronous callout made with a continuation doesn’t count toward the Apex limit of synchronous requests that last longer than five seconds. Since Winter ’20, all callouts are excluded from the long-running request limit so continuations no longer offer an advantage for working with limits compared to regular callouts. However, we recommend using continuations to manage callouts due to the improved user experience.