I'm struggling with picking up the right way to poll server with constant interval (eg ~1 second).
The flow goes as follows
- client application receives message, that indicates the polling could start with provided parameters (it doesn't poll when there is no need to)
- client application starts polling the http endpoint every ~1second with parameters arrived with message (like query parameter)
- server application responds with status pending so that indicates the client should continue polling
- server application responds with status finished and returns the result - there is no need to keep polling.
We can have multiple threads, as the client application might receive multiple message in the short time - polling should start immediately
I don't want to reinvent the wheel, maybe there is a proper tool that works with java/spring that I can use?
Key features
- poll only when there is a need to
- poll with custom parameters (custom params in a query string)
- scale polling as the application could poll multiple endpoints simultaneously with the same interval
I was going through various libs like Apache Camel or Spring Integration PollableChannel, but I feel like none of these is going to give me the right solution out of the box.
If there is no lib like this - I'm going to write it on my own using redis and simple loop, but maybe someone has faced similar problem.