Hey I have the following situation: a WinService which is processing some stuff from a queue, writing to other tables (during processing) and after it finishes it deletes the entry and moves to the next one.
I would need a mechanism to determine if the instance is alive and going and if not to start or wake up a second instance.
What I've thought so far is to have two instances going on where each tries to pick up stuff from the queue and process it (tries- as in see if it can- like no keepAliveFlag is set or lastUpdateDate of a record is too long ago). There could be the situation when they process the same record- this is the disadvantage.
For this above proposed solution, I would also need a sort of mechanism in the case when an instance tries to write a keepAliveFlag and does not succeed to stop.
Aside from this solution, there is also the solution for the instance to constantly write stuff into db and the second instance to check if new stuff is written and if not wake up or launch the second instance. But several problems may appear: what happens if the former master wakes up? And in general this second scenario seems harder to implement correctly.
Now the question: what would be the correct pattern to implement this?