I create a thread that will continue to pull a piece of records from the database and put them in the queue. This thread will start when the server boots. I want this thread to be active all the time. If there are no entries in the database, I want it to wait and check again after a while. I was thinking about the spring task scheduler to schedule this, but not sure if this is correct, because I only want my task to run once. What would be a good way to implement this in spring?
In addition, I need to have a border check that if my thread does not work (due to any errors or exception conditions), it should be re-created after some time.
I can do all of this in java using thread communication methods, but just try if there is something in spring or Java for such scenarios.
Any suggestions or pointers will help.
source share