I have sort of a queue of requests to which I'm able to add new ones from various parts of the application.
My JavaFX-Service should then process these requests in an asynchronous, but coordinated manner.
My current approach is to use an ObservableList for the queue. I have a listener on its emptyProperty and trigger the service restart everytime it changes from empty to not empty.
In my service's task I take the first element of the list, process it and when the processing succeeded (or failed), remove it from the list.
Then however I have to check in the succeeded() and failed() methods whether there are more elements and restart the service in case there are.
It feels needlessly complicated and potentially error-prone. Isn't there a simpler approach I'm missing?