feat: implemented a listen-method for the chat-service based on a Flux master
authorKai Moritz <kai@juplo.de>
Wed, 21 Dec 2022 17:57:23 +0000 (18:57 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 25 Dec 2022 00:13:03 +0000 (01:13 +0100)
commitdb92f29c1ee7e67b8ed9e9cc7eafff00ae4a57f0
tree50d0e3092261411a06b64724068610029d654bf9
parent4ae2e9d8513fa6a774e03d5a6581d6807d9f0720
feat: implemented a listen-method for the chat-service based on a Flux

- Switched the return-type of `Chatroom.addMessage()` to `Mono<Message>`.
- Added an inner method, that "persists" the message and also returns
  `Mono<Message>`.
- `addMessage()` calls `persistMessage()`, peeks into the subscription and
  emits the `Message` to an internal `Sink.multy()` of the `Chatroom`.
- `Chatroom.listen()` creates a `Flux` from the internal Sink, so that
  multiple subscribers can listen on the sink and all retrieve the current
  messages in parallel.
pom.xml
src/main/java/de/juplo/kafka/chatroom/api/ChatroomController.java
src/main/java/de/juplo/kafka/chatroom/domain/Chatroom.java