From: Kai Moritz Date: Sun, 18 Feb 2024 18:30:06 +0000 (+0100) Subject: WIP:mongodb map vs subscribe X-Git-Tag: rebase--2024-02-19--08-59~4 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=6d3b3dea874215707af96b0d4789aed203087eae;p=demos%2Fkafka%2Fchat WIP:mongodb map vs subscribe --- 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) {