Search code examples
resthttpmessage-queueschedulingcron

How are background workers usually implemented for polling a message queue?


Say you have a message queue that needs to be polled every x seconds. What are the usual ways to poll it and execute HTTP/Rest-based jobs? Do you simply create a cron service and call the worker script every x seconds?

Note: This is for a web application


Solution

  • I would write a windows service which constantly polls/waits for new messages.

    Scheduling a program to run every x min has a number of problems

    1. If your interval is too small the program will still be running with the next startup is triggered.
    2. If your interval is too big the queue will fill up between runs.

    Generally you expect a constant stream of messages, so there is no problem just keeping the program running 24/7