feat: Added counting of restored instances
[demos/kafka/chat] / src / main / java / de / juplo / kafka / chat / backend / implementation / inmemory / SimpleChatHomeService.java
index 5c3fe2e..d568a9b 100644 (file)
@@ -49,6 +49,9 @@ public class SimpleChatHomeService implements ChatHomeService
 
   Mono<Void> restore(StorageStrategy storageStrategy)
   {
+    chatRoomInfo.clear();
+    chatRoomData.clear();
+
     return storageStrategy
         .readChatRoomInfo()
         .filter(info ->
@@ -82,9 +85,10 @@ public class SimpleChatHomeService implements ChatHomeService
 
           return chatMessageService.restore(storageStrategy);
         })
-        .then()
-        .doOnSuccess(empty -> log.info("Restored {}", this))
-        .doOnError(throwable -> log.error("Could not restore {}", this));
+        .count()
+        .doOnSuccess(count -> log.info("Restored {} with {} chat-rooms", this, count))
+        .doOnError(throwable -> log.error("Could not restore {}", this))
+        .then();
   }