test: HandoverIT-POC - FIX: `TestWriter` must use `Flux#concatMap()`
authorKai Moritz <kai@juplo.de>
Fri, 15 Mar 2024 15:10:31 +0000 (16:10 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 22 Mar 2024 16:39:20 +0000 (17:39 +0100)
* `Flux#flatMap()` executes in parallel. Hence, the enqueued messages
  are _not_ send in the order, that they were enqueued.
* Therefore, the `TestWriter` was refactored to use `Flux#concatMap()`,
  which executes serially.

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

index a6ac569..aa3c6c1 100644 (file)
@@ -44,8 +44,9 @@ public class TestWriter
         })
         .delayElements(Duration.ofMillis(ThreadLocalRandom.current().nextLong(500, 1500)))
         .map(i -> "Message #" + i)
-        .flatMap(message -> sendMessage(chatRoom, message)
-            .retryWhen(Retry.fixedDelay(30, Duration.ofSeconds(1))))
+        .concatMap(message -> sendMessage(chatRoom, message)
+            .log(user.getName())
+            .retryWhen(Retry.fixedDelay(60, Duration.ofSeconds(1))))
         .doOnNext(message ->
         {
           numSentMessages++;