[SalesForce] How to overcome 120 sec timeout in REST webservice calls

I have a requirement where a user can request some data as an email attachment from one of our visualforce pages.

I am fetching the data over a REST web service call from an external system.
Using that data an Excel document is created and sent as an attachment in an email to the user.
However, to fetch the data in certain scenarios, due to the huge data load, we are getting stuck with the 120 second timeout.

Is there a way I can use @future or any other workaround to overcome this issue?

Best Answer

See this blog article by Jitendra Zaa titled Continuation object in Apex – Asynchronous callouts for long running request – Live Demo where he talks about using the Continuation method to call a web service asynchronously then have it displayed later in a visualforce page. I suspect it may be what you're looking for.

He also references Actionsupport and JS remoting as comparison methods.

Related Topic