From b2af3675686e5ba93bd1e3998c26a30880407483 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 4 Feb 2024 00:37:23 +0100 Subject: [PATCH] WIP:mongodb map vs subscribe --- .../backend/storage/mongodb/MongoDbStorageStrategy.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/juplo/kafka/chat/backend/storage/mongodb/MongoDbStorageStrategy.java b/src/main/java/de/juplo/kafka/chat/backend/storage/mongodb/MongoDbStorageStrategy.java index b1bead9b..16bde247 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/storage/mongodb/MongoDbStorageStrategy.java +++ b/src/main/java/de/juplo/kafka/chat/backend/storage/mongodb/MongoDbStorageStrategy.java @@ -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 @@ -45,7 +46,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 -- 2.20.1