feat: implemented a listen-method for the chat-service based on a Flux
authorKai Moritz <kai@juplo.de>
Wed, 21 Dec 2022 17:57:23 +0000 (18:57 +0100)
committerKai Moritz <kai@juplo.de>
Mon, 26 Dec 2022 12:44:27 +0000 (13:44 +0100)
commit02ebef6224bfd00d74c9a6ccf467f0387a926df1
tree6617e84ea89b924a994f05515174e53cf747c2ef
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