What does Hangfire offer for single instance, continuous tasks? I have a system that has several jobs that need to always run, and can only have one instance running across all servers. The job executes with an indefinite length, until a change in configuration is required.
My exact case is connecting to a server that streams data to us over a TCP we open to them. I can only have one TCP connection open at any time. So when the process starts up, it connects, sends the config parameters and just receives data “forever”. Until someone adds a new record, at which point I close the connection, and reconnect with new parameters.
Right now I have a hacky system that starts a new thread if the web.config indicates this instance is the chosen one, and a bunch of invasive code to detect changes and restart. It’s basically a while(true) loop.
Can Hangfire make this simpler? For the continuous part, I guess I can just have a job with unlimited retries, no expiration, then just fail/abort every time I need to restart. But, that’s a bit ugly eh? What about notifying the server that’s running that job, what facilities exist for that?
Thanks!