I have the following situation.
I have my web site written in Tapestry. On one of the pages, I'm required to generate a fairly large Excel or PDF document (around 20 MB). Now, since the entire process takes time, I'm asking my user to wait a bit.
However, when I tried to test the upper limits, I noticed that my entire application (not just the web part) freezes, because the generation eats up all the resources and the rest of the website and application becomes unresponsive.
Here is the flow how I've been doing it so far.
- User clicks a button to request the file on the page
- Data is being fetched from database (this part is quite fast)
- Data is passed to a Tapestry service which prepares it (nothing fancy, also fast)
- Prepared data is sent to EJB service which creates and deploys a visitor which creates the excel/pdf file
- The
InputStream
of the created file is passed all the way up to Tapestry which wraps it inStreamResponse
and offers the download
What would be an appropriate way to handle this problem?
Could I perhaps use Tapestry's ParallelExecutor
from some Tapestry service of mine in a manner like this?
Future<InputStream> future = executor.invoke(new Invokable<InputStream>() { ... });
My main objective is that the application and website keep running, that they do not freeze.
Thank you in advance.