I am using the Spring 5 WebClient to repeatedly fetch some state of a running process from a REST api.
With help from here I for now came to this solution:
webClient.get().uri(...).retrieve.bodyToMono(State.class)
.repeat()
.skipUntil(state -> stateFinished())
.limitRequest(1)
.subscribe(state -> {...});
While this works, the get request is fired at a very high rate. What would be the right way to limit the request rate to let's say 1 request per second?
I tried using delayElements(Duration.ofSeconds(1))
but that only delays the results, not the request itself.