WIP
[demos/kafka/chat] / src / test / java / de / juplo / kafka / chat / backend / TestListener.java
index b74b8e8..3f282ee 100644 (file)
@@ -12,20 +12,20 @@ import org.springframework.http.codec.ServerSentEvent;
 import org.springframework.web.reactive.function.client.WebClient;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
+import reactor.core.scheduler.Schedulers;
 
 import java.util.*;
 
 
 @Slf4j
-public class TestListener implements Runnable
+public class TestListener
 {
   static final ParameterizedTypeReference<ServerSentEvent<String>> SSE_TYPE = new ParameterizedTypeReference<>() {};
 
 
-  @Override
-  public void run()
+  public Mono<Void> run()
   {
-    Flux
+    return Flux
         .fromArray(chatRooms)
         .flatMap(chatRoom ->
         {
@@ -54,8 +54,10 @@ public class TestListener implements Runnable
               .take(30);
         })
         .takeUntil(message -> !running)
-        .then()
-        .block();
+        .doOnComplete(() -> log.info("TestListener is done"))
+        .parallel()
+        .runOn(Schedulers.parallel())
+        .then();
   }
 
   Flux<ServerSentEvent<String>> receiveMessages(ChatRoomInfoTo chatRoom)