* Switched from `Flux.flatMap(Mono.delay()..)` to
`Flux.from(..).delayElements()`FIX:delay_vs_delayElements.
* This delays eache element of the `Flux` by the same amount.
* The requests are made, when the according element of the flux is
executed - not when the `Flux` is created, as before.
return i++;
}
})
+ .delayElements(Duration.ofMillis(ThreadLocalRandom.current().nextLong(500, 1500)))
.map(i -> "Message #" + i)
- .flatMap(message -> Mono
- .delay(Duration.ofMillis(ThreadLocalRandom.current().nextLong(500, 1500)))
- .thenMany(sendMessage(chatRoom, message).retryWhen(Retry.fixedDelay(10, Duration.ofSeconds(1)))))
+ .flatMap(message -> sendMessage(chatRoom, message)
+ .retryWhen(Retry.fixedDelay(10, Duration.ofSeconds(1))))
.doOnNext(message ->
{
sentMessages.add(message);