From: Kai Moritz Date: Sat, 3 Feb 2024 23:37:23 +0000 (+0100) Subject: WIP:mongodb map vs subscribe X-Git-Tag: rebase--2024-02-18--18-12~3 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=443be2b6cb083c9042820ab05ab9fdd885b022aa;p=demos%2Fkafka%2Fchat WIP:mongodb map vs subscribe --- 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 2989d55f..3f9ff209 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 @@ -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