From 6d3b3dea874215707af96b0d4789aed203087eae Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 18 Feb 2024 19:30:06 +0100 Subject: [PATCH] WIP:mongodb map vs subscribe --- .../backend/storage/files/FilesStorageStrategy.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/juplo/kafka/chat/backend/storage/files/FilesStorageStrategy.java b/src/main/java/de/juplo/kafka/chat/backend/storage/files/FilesStorageStrategy.java index cb7dd31e..7e04a964 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/storage/files/FilesStorageStrategy.java +++ b/src/main/java/de/juplo/kafka/chat/backend/storage/files/FilesStorageStrategy.java @@ -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) { -- 2.20.1