WIP:mongodb map vs subscribe
authorKai Moritz <kai@juplo.de>
Sun, 18 Feb 2024 18:30:06 +0000 (19:30 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 18 Feb 2024 18:30:06 +0000 (19:30 +0100)
src/main/java/de/juplo/kafka/chat/backend/storage/files/FilesStorageStrategy.java

index cb7dd31..7e04a96 100644 (file)
@@ -74,18 +74,20 @@ public class FilesStorageStrategy implements StorageStrategy
               throw new RuntimeException(e);
             }
           })
-          .subscribe(chatRoomInfo ->
+          .map(chatRoomInfo ->
           {
             try
             {
               ChatRoomInfoTo chatRoomInfoTo = ChatRoomInfoTo.from(chatRoomInfo);
               generator.writeObject(chatRoomInfoTo);
+              return chatRoomInfo;
             }
             catch (IOException e)
             {
               throw new RuntimeException(e);
             }
-          });
+          })
+          .subscribe();
     }
     catch (IOException e)
     {
@@ -160,18 +162,20 @@ public class FilesStorageStrategy implements StorageStrategy
               throw new RuntimeException(e);
             }
           })
-          .subscribe(message ->
+          .map(message ->
           {
             try
             {
               MessageTo messageTo = MessageTo.from(message);
               generator.writeObject(messageTo);
+              return message;
             }
             catch (IOException e)
             {
               throw new RuntimeException(e);
             }
-          });
+          })
+          .subscribe();
     }
     catch (IOException e)
     {