refactor: One stream -> using `flatMap` instead of an inner `subscribe`
[demos/kafka/chat] / src / main / java / de / juplo / kafka / chat / backend / ChatBackendApplication.java
index 15f8ae1..76debbe 100644 (file)
@@ -1,7 +1,7 @@
 package de.juplo.kafka.chat.backend;
 
-import de.juplo.kafka.chat.backend.domain.ChatHome;
-import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
+import de.juplo.kafka.chat.backend.domain.ChatHomeService;
+import de.juplo.kafka.chat.backend.implementation.StorageStrategy;
 import jakarta.annotation.PreDestroy;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.SpringApplication;
@@ -16,7 +16,7 @@ public class ChatBackendApplication implements WebFluxConfigurer
        @Autowired
        ChatBackendProperties properties;
        @Autowired
-       ChatHome chatHome;
+       ChatHomeService chatHomeService;
        @Autowired
        StorageStrategy storageStrategy;
 
@@ -32,7 +32,9 @@ public class ChatBackendApplication implements WebFluxConfigurer
        @PreDestroy
        public void onExit()
        {
-               storageStrategy.write(chatHome);
+               storageStrategy
+                               .write(chatHomeService)
+                               .subscribe();
        }
 
        public static void main(String[] args)