fix: GREEN - Implemented activation/deactivation of `ChatRoomData`
authorKai Moritz <kai@juplo.de>
Mon, 11 Mar 2024 12:08:21 +0000 (13:08 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 22 Mar 2024 16:39:20 +0000 (17:39 +0100)
commit11fb12dd3b76efc8c47066331a55392f8b1eb4d9
tree77902c8874453aeb339329314bcfb7e3029b549f
parentd529ca4347dea9bdd6c7f5efbcc3547f547ddb92
fix: GREEN - Implemented activation/deactivation of `ChatRoomData`

* Introduced `volatile ChatRoomData#active`, which initially is `false`.
* `ChatRoomData#listen()` throws `ChatRoomInactiveException` if inactive.
* `ChatRoomData#addMessage(..)` throws `ChatRoomInactiveException` if
  inactive.
* `SimpleChatHomeService` explicitly activates restored and newly created
  instances of `ChatRoomData`.
* `DataChannel` explicitly activates instances of `ChatRoomData`, if
  they are restored during partition-assignment or, if a new chat-room
  is created.
* `DataChannel` explicitly _deactivates_ instances of `ChatRoomData`,
  if the associated partition is revoked.
* Also: Introduced `ChatMessageService#getChatRoomId()`.
src/main/java/de/juplo/kafka/chat/backend/domain/ChatMessageService.java
src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomData.java
src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/ChatRoomInactiveException.java [new file with mode: 0644]
src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/InMemoryChatMessageService.java
src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/SimpleChatHomeService.java
src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/DataChannel.java
src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatMessageService.java