.flatMap(message -> sendMessage(chatRoom, message)
.delayElement(Duration.ofMillis(ThreadLocalRandom.current().nextLong(500, 1500)))
.retryWhen(Retry.fixedDelay(10, Duration.ofSeconds(1))))
+ .doOnNext(message -> log.info(
+ "{} sent a message to {}: {}",
+ user,
+ chatRoom,
+ message))
.doOnError(throwable ->
{
WebClientResponseException e = (WebClientResponseException)throwable.getCause();
user,
e.getResponseBodyAsString(Charset.defaultCharset()));
})
- .doOnNext(message -> log.info(
- "{} sent a message to {}: {}",
- user,
- chatRoom,
- message))
.then()
.block();
}