Continuation in Salesforce – Asynchronous Callout option for long running requests

While implementing features, we need to write code to call external web services to fetch or update information. But calling external web service doesn’t mean we should wait for the response from the web service. That is a bad design. We should always write code in such a way so that we can call external web service and still continue to do other work and when the response is available from the web service, we will update the page with response. This way of calling web service is known as Asynchronous callout.Since in Salesforce, we are living in a multi-tenant architecture, so calling external services synchronously can create issues if the response is taking too much of time to come due to network latency or complex calculation or long running requests. There can be n number of reasons why the response is taking longer time. To make sure System resources are available to all customers, Salesforce introduces limitation on how much synchronous callout you can do from a single organization. Limit is each org can make a maximum of 10 synchronous requests running for more than 5 seconds. When the limit is reached, any subsequent request will fail until and unless an existing request completes successfully.Apex continuation is an architectural design which will allow to call long running external web services in a scalable fashion without blocking any server...

Read More