We have a system that publishes requests for processing into a database table. We also have a scheduled task that runs every minute and looks for pending requests in that table. If a request is found, the task processes it, marks it as complete, then picks up the next pending request, if any, and so on. If there are no more requests, the task terminates. A next task instance is started at the top of the next minute.
That all works fine, but we now have a requirement to process all of the requests as soon they are added to the database table, i.e., with a minimum delay. Which means we need to be able to process them in parallel, not one by one.
I am seeking ideas on how to implement this. One approach would be to have a monitoring thread in the task that would query the table for new requests periodically, and when a new request is found, span a processing thread for that request. Or, taking a similar approach, split the task in two executables - one for monitoring and another for processing. The former will start instances of the latter on demand.