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>
Sun, 15 Jan 2023 18:32:56 +0000 (19:32 +0100)
commit974327a0e3a970af36e3ace4a8fb17d8a800b4a3
tree86718849635ea9a6d8b866e880dab2e6b4e905dc
parenta8164a477f0aa94f5c6e21dcf5c2ef8a8627402b
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