From ceef7f3dbafb263cc649798bfb02706ae93bbf88 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 27 Feb 2024 23:42:27 +0100 Subject: [PATCH] test: HandoverIT-POC - Remodeled sending into a for-loop --- .../juplo/kafka/chat/backend/TestClient.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/test/java/de/juplo/kafka/chat/backend/TestClient.java b/src/test/java/de/juplo/kafka/chat/backend/TestClient.java index 4aad7f81..fe39e441 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/TestClient.java +++ b/src/test/java/de/juplo/kafka/chat/backend/TestClient.java @@ -6,7 +6,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.util.retry.Retry; @@ -18,15 +17,21 @@ public class TestClient { public void run() { - Flux - .range(1, 100) - .flatMap(i -> Flux - .fromArray(chatRooms) - .map(chatRoom -> sendMessage(chatRoom, "Message #" + i)) - .flatMap(result -> result - .map(MessageTo::toString) - .retryWhen(Retry.fixedDelay(10, Duration.ofSeconds(1))))) - .subscribe(result -> log.info("{}", result)); + for (int i = 0; i < 100; i++) + { + String message = "Message #" + i; + for (ChatRoomInfoTo chatRoom : chatRooms) + { + sendMessage(chatRoom, message) + .retryWhen(Retry.fixedDelay(10, Duration.ofSeconds(1))) + .map(MessageTo::toString) + .subscribe(result -> log.info( + "{} sent message \"{}\" to {}", + user, + message, + chatRoom)); + } + } } private Mono sendMessage( -- 2.20.1