From: Kai Moritz Date: Sun, 3 Mar 2024 09:08:36 +0000 (+0100) Subject: test: HandoverIT-POC - working fix: using `delayElements()` X-Git-Tag: rebase--2024-03-05--09-07~19 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=78cda5eb4761c62f5de1a84a68698bd01e607bdb;p=demos%2Fkafka%2Fchat test: HandoverIT-POC - working fix: using `delayElements()` * 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. --- diff --git a/src/test/java/de/juplo/kafka/chat/backend/TestWriter.java b/src/test/java/de/juplo/kafka/chat/backend/TestWriter.java index 133a7689..0d2c41e7 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/TestWriter.java +++ b/src/test/java/de/juplo/kafka/chat/backend/TestWriter.java @@ -42,10 +42,10 @@ public class TestWriter 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);