I need to run a slow part of my application with the click of a button in a screen. I don't want users to have to wait indefinitely - I want them to know when to continue. But my logic is too complex and my request is always timing out.
How can I implement a pattern that addresses this?
The rough guidelines for such a pattern are the following:
- A timer that processes a "queue" of slow requests. Meaning, a queue (typically an entity) with the parameters to be processed, a boolean on whether it's complete, and the a column where the excel is stored there
- The screen places a request in the queue and wakes the timer that processes the queue. It is then sent to a "waiting" screen
- The timer processes the request and places the excel in the result
- The waiting screen (with auto-refresh - say every 10 seconds) looks at the queue (based on an identifier that is given when the request is placed). When the request is processed, the option to download the file is given to the end-user.
- A second timer that runs every hours or so and that deletes all queued requests that have been processed more than say 30 minutes ago.
For inspiration, refer to the Work Queue Sample component in the OutSystems Forge: