Date: 7th May 2020
This blog post displays a method for writing long running tasks for a web application. It is aimed at long running tasks that are composite of many long repetitive actions. Examples of such are: sending a lot of emails, paying staff salaries etc.
This approach is more comfortable than the usual method of creating a separate server for long running tasks.
The demo here doesn't do anything with the id. Instead it delays for 3 seconds to simulate real life situations.
The demo doesn't show how to get the ids from a database. These you could look up online. In the demo the ids were randomly created and placed in an array.
A real life situation should store the ids that has been worked on. This is necessary in case of any network interruption.
Web workers are needed here because if AJAX requests are made synchronously the page might start hanging. The web workers seems like threading in the browser.
Synchronous requests were preferred here since the script would be easier to write.
The final demo
If you have any comments or objections or complaints or contributions please mail us