Hi All,
I am trying to mimic a continuously running scheduler/batch process or a setInterval method that runs every 20 seconds and checks the DB for any outstanding records. If there are, it processes them and then waits for 20 seconds before starting over.
The above is the setup i have which achieves what i want. I just want to post it out there to see if there is a better way to do it . I am also not sure of the memory footprint for this setup. I also clear the payload in the msg object that i used for storing db records.
The above is not a working version. But an outline of what i want to achieve.
There are 2 node.js processes. 1 REST service will accept inbound requests and insert into the DB.
The 2nd process is the node-red process that acts as a scheduler and process those inserted records.
There is a possibility that a single fetch from the DB would be 20 records. The processing for 20 records might take more time. Thats why injecting every 20 seconds constantly irrespective of whether the previous flow ended, will not work in this case.
Something like a recurring setTimeout than a setInterval
Its just that, the process keeps running continuously unlike conventional rest service which wakes up only by incoming requests. Just worried if the node-red process will ever have time free for garbage collection. Wanted to know if there is a better way out there.
It won't be running continuously, you have 20 second gaps in it. Anyway, the garbage collection will happen if it needs to, holding up the flow if necessary.