From 0dbfbd9f64b9d9415a65a41457c757c928307994 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 10 Jan 2023 21:29:58 +0100 Subject: [PATCH] WIP:fix-async --- .../persistence/storage/mongodb/MongoDbStorageStrategy.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/MongoDbStorageStrategy.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/MongoDbStorageStrategy.java index 73f5e8a3..8cbbb556 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/MongoDbStorageStrategy.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/MongoDbStorageStrategy.java @@ -4,6 +4,7 @@ import de.juplo.kafka.chat.backend.domain.ChatRoom; import de.juplo.kafka.chat.backend.persistence.StorageStrategy; import de.juplo.kafka.chat.backend.persistence.storage.files.ChatRoomServiceFactory; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import reactor.core.publisher.Flux; import java.time.Clock; @@ -11,6 +12,7 @@ import java.util.UUID; @RequiredArgsConstructor +@Slf4j public class MongoDbStorageStrategy implements StorageStrategy { private final ChatHomeRepository repository; @@ -25,7 +27,9 @@ public class MongoDbStorageStrategy implements StorageStrategy chatroomFlux .log() .map(ChatRoomTo::from) - .subscribe(chatroom -> repository.save(chatroom)); + .flatMap(chatroom -> repository.save(chatroom)) + .doOnNext(chatRoomTo -> log.debug("Written: {}", chatRoomTo)) + .blockLast(); } @Override -- 2.20.1