WIP:mongodb map vs subscribe
authorKai Moritz <kai@juplo.de>
Sat, 3 Feb 2024 23:37:23 +0000 (00:37 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 18 Feb 2024 16:40:58 +0000 (17:40 +0100)
src/main/java/de/juplo/kafka/chat/backend/storage/mongodb/MongoDbStorageStrategy.java

index 2989d55..3f9ff20 100644 (file)
@@ -25,7 +25,8 @@ public class MongoDbStorageStrategy implements StorageStrategy
   {
     chatRoomInfoFlux
         .map(ChatRoomTo::from)
-        .subscribe(chatroomTo -> chatRoomRepository.save(chatroomTo));
+        .flatMap(chatroomTo -> chatRoomRepository.save(chatroomTo))
+        .subscribe();
   }
 
   @Override
@@ -44,7 +45,8 @@ public class MongoDbStorageStrategy implements StorageStrategy
   {
     messageFlux
         .map(message -> MessageTo.from(chatRoomId, message))
-        .subscribe(messageTo -> messageRepository.save(messageTo));
+        .flatMap(messageTo -> messageRepository.save(messageTo))
+        .subscribe();
   }
 
   @Override