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?

  • 1
    Do you require all the data in one callout? Can you batch the returned data? Aug 13, 2015 at 15:29

1 Answer 1


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.

  • Looks awesome, let me try and come back with a feedback!
    – ParoTech
    Aug 19, 2015 at 7:37
  • Hi, I have been in a scenario we do post operation, but as we have 120 sec timelimit in HTTP, we ended up not knowing whether the request is a success or failure. In case we have to retrigger the request, then it ends up as a duplicate in the targer system. Is there a way to overcome this in apex..
    – kso
    Nov 10, 2016 at 16:01
  • @karti There are ways to overcome this. I suggest you ask a new question so it will get the attention it merits. Be sure to post the details of how you're currently making the requests and how they're being returned. In essence, you need to do some "accounting" to track those.
    – crmprogdev
    Nov 10, 2016 at 17:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .