I have a flux that should emit an item almost immediately. After this, it may not emit an item for a long period of time.
I want it to timeout if no item is initially received. But if I use the timeout(Duration)
method, it will timeout every time no item is received in the given period of time.
The code I have now, which does not work for the reason stated above:
messageFlux.timeout(Duration.ofSeconds(30)).doOnError(e -> {
// handle error
}).subscribe(m -> messageService.consumeMessage(m));
Is there even a way to do this efficiently?