Reputation: 579
I have implemented a Notify/Listen mechanism, so when a special request is sent to the web server, using notify I can notify the workers (in Python) that there's a pending request waiting to be processed. The implementation works fine, but the problem is that if the workers server is restarting, the notification gets lost, since at that particular time there's no listener. I can implement a service like MQRabbit or similar, but my needs are so simple that implement such a monster is too much. Is there any way, a configuration variable perhaps, that can give some persistence to the notification mechanism?
Thanks in advance
Upvotes: 2
Views: 1634
Reputation: 9157
I don't think there is a way to persist notification channels, but you can simply store the pending requests to a table, and have the worker check for any missed work on startup.
Either a timestamp or a pending/completed flag would work, depending on what kind of work it's doing.
For consistency, you can have the NOTIFY
fire from an INSERT
trigger on the queue table, and have the worker always check for any remaining work (not just a specific request) when notified.
Upvotes: 1