test: HandoverIT-POC - not working fix: using `delay()`
authorKai Moritz <kai@juplo.de>
Sat, 2 Mar 2024 17:21:44 +0000 (18:21 +0100)
committerKai Moritz <kai@juplo.de>
Thu, 14 Mar 2024 08:11:21 +0000 (09:11 +0100)
* Switched from `Mono.from(..).delayElement()` to `Mono.delay().then()`.
* This does _not_ solve the problem, that all delays are calculated and
  scheduled, when the `Flux` is created.

src/test/java/de/juplo/kafka/chat/backend/TestWriter.java

index 61516b0..133a768 100644 (file)
@@ -43,9 +43,9 @@ public class TestWriter
           }
         })
         .map(i -> "Message #" + i)
-        .flatMap(message -> sendMessage(chatRoom, message)
-            .delayElement(Duration.ofMillis(ThreadLocalRandom.current().nextLong(500, 1500)))
-            .retryWhen(Retry.fixedDelay(10, Duration.ofSeconds(1))))
+        .flatMap(message -> Mono
+            .delay(Duration.ofMillis(ThreadLocalRandom.current().nextLong(500, 1500)))
+            .thenMany(sendMessage(chatRoom, message).retryWhen(Retry.fixedDelay(10, Duration.ofSeconds(1)))))
         .doOnNext(message ->
         {
           sentMessages.add(message);