I’m already using BackgrounDRb to execute a long-running job on an
application, which is ideal because all it needs to do at the end of the
job is to e-mail the user telling them the URL to download the results
of their query. When they start the job a page telling them to wait for
the e-mail is rendered.
However, before that stage users will need to do a database search and
view the results in the browser, so that they may choose what data
they’d like to send to the really long process. That query has taken to
running for 2-3 minutes, during which time the browser will time out.
I’d like to do something like this:
- Send the job to a worker whilst rendering the “please wait” message
that I currently have. - When the job from (1) is complete, have the worker inform the browser
so that the user can be re-directed to view the results of their search.
What’s the best way of performing step (2)? Would it be some sort of
javascript embedded in the “please wait” view that queries the worker,
and if so could anyone point me in the direction of an example of how
this might be set up?
The other thing is that this worker will need access to session[] to
store the id of the models it finds and I’d also have to pass a very
large hash of params[] to it in order for the search to be carried out.
Is that possible?