I have a Spring Boot service that is deployed in multiple instances. I want to have a continuously running "daemon thread" in exactly one of the instances. Should that instance go down, the thread should eventually (after a timeout) become active on some other instance.
The service uses a common MongoDB database, which can in principle provide the locking, but I am looking for a pattern or library that does this properly.
I looked at Shedlock, but it seems to be intended only for short-running jobs with a somewhat predictable duration, instead of long-running daemon threads.