WIP
authorKai Moritz <kai@juplo.de>
Mon, 5 Feb 2024 19:19:44 +0000 (20:19 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 18 Feb 2024 16:41:00 +0000 (17:41 +0100)
src/main/java/de/juplo/kafka/chat/backend/implementation/StorageStrategy.java
src/test/java/de/juplo/kafka/chat/backend/InMemoryWithMongoDbConfigurationIT.java

index 868ae11..98db975 100644 (file)
@@ -9,6 +9,7 @@ import reactor.core.publisher.Flux;
 
 import java.util.UUID;
 import java.util.concurrent.Phaser;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.BiConsumer;
 import java.util.function.Consumer;
@@ -18,8 +19,17 @@ public interface StorageStrategy
 {
   Logger log = LoggerFactory.getLogger(StorageStrategy.class.getCanonicalName());
 
+  AtomicBoolean running = new AtomicBoolean(true);
+
+
   default void write(ChatHomeService chatHomeService)
   {
+    if (!running.getAndSet(false))
+    {
+      log.info("{} is not running, skip write...", chatHomeService);
+      return;
+    }
+
     Phaser writtenChatRooms = new Phaser(1);
     AtomicInteger numErrors = new AtomicInteger();
 
index 6937736..c7ede36 100644 (file)
@@ -37,7 +37,7 @@ class InMemoryWithMongoDbConfigurationIT extends AbstractConfigurationIT
        @DynamicPropertySource
        static void addMongoPortProperty(DynamicPropertyRegistry registry)
        {
-               registry.add("spring.data.mongodb.port", () -> CONTAINER.getMappedPort(27017));
+               registry.add("spring.data.mongodb.port", () -> CONTAINER.getMappedPort(MONGODB_PORT));
        }
 
        @BeforeEach