From 6b2877cc6a81e6b925d0347a1fd88a55d92454cb Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 6 Jan 2023 01:33:51 +0100 Subject: [PATCH] feat: Added a POST-mapping to force the storing of the data --- .../kafka/chat/backend/api/ChatBackendController.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java b/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java index 8fccaa9b..4aaf4f57 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java +++ b/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java @@ -2,6 +2,7 @@ package de.juplo.kafka.chat.backend.api; import de.juplo.kafka.chat.backend.domain.ChatHome; import de.juplo.kafka.chat.backend.domain.Chatroom; +import de.juplo.kafka.chat.backend.persistence.StorageStrategy; import lombok.RequiredArgsConstructor; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; @@ -10,7 +11,6 @@ import reactor.core.publisher.Mono; import java.time.Clock; import java.time.LocalDateTime; -import java.util.Collection; import java.util.Optional; import java.util.UUID; import java.util.stream.Stream; @@ -22,6 +22,7 @@ public class ChatBackendController { private final ChatHome chatHome; private final Clock clock; + private final StorageStrategy storageStrategy; @PostMapping("create") @@ -115,4 +116,10 @@ public class ChatBackendController .log() .map(message -> MessageTo.from(message)); } + + @PostMapping("/store") + public void store() + { + storageStrategy.writeChatrooms(Flux.fromStream(chatHome.list())); + } } -- 2.20.1