demos/kafka/chat
19 months agoTMP:Holzweg so, Refaktorisierung nötig rebase--2023-08-18
Kai Moritz [Sat, 22 Apr 2023 10:21:30 +0000 (12:21 +0200)]
TMP:Holzweg so, Refaktorisierung nötig

19 months agoNG
Kai Moritz [Sat, 22 Apr 2023 10:18:53 +0000 (12:18 +0200)]
NG

19 months agoNG
Kai Moritz [Sat, 22 Apr 2023 09:51:48 +0000 (11:51 +0200)]
NG

19 months agoNG
Kai Moritz [Sat, 22 Apr 2023 09:29:39 +0000 (11:29 +0200)]
NG

19 months agoNEU vs. NG ??
Kai Moritz [Fri, 21 Apr 2023 08:28:02 +0000 (10:28 +0200)]
NEU vs. NG ??

Besser:

 - Create-Requests für ChatRoom's auch in den Message-Channel schreiben
 - Dann, wenn sie dort gelesen werden, _zusätzlich nachträglich_ in
   den Chatroom-Channel.
 - Grund: Dann fällt das hier übrig gebliebene _nicht-triviale_
   Problem weg, bzw. löst sich in Wohlgefallen auf, da die Create-Requests
   automatisch in der richtigen Reihenfolge (also vor allen Messages,
   für einen bestimmten ChatRoom) in dem Message-Channel gelesen werden

Außerdem:

 - Der Chatroom-Channel wird ("später") auch als allgemeiner Info-Channel
   benötigt, in den die Instanzen _insbesondere_ auch veröffentlichen,
   welche Partitionen ihnen gerade zugeordnet sind.
 - Der Chatroom-Channel sollte daher auf Dauer Info-Channel heißen und
   der Message-Channel eher allgemeiner Chatroom-Channel (im Sinne von
   hier alles zum Thema ChatRoom und den daran veröffentlichten
   Nachrichten...)

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 20:11:51 +0000 (22:11 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 20:09:16 +0000 (22:09 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 15:36:11 +0000 (17:36 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 15:10:57 +0000 (17:10 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 15:00:20 +0000 (17:00 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 14:57:31 +0000 (16:57 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 12:35:22 +0000 (14:35 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 12:27:48 +0000 (14:27 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 12:27:25 +0000 (14:27 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 12:22:43 +0000 (14:22 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 12:14:40 +0000 (14:14 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 11:37:35 +0000 (13:37 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 09:35:57 +0000 (11:35 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 09:06:29 +0000 (11:06 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 09:04:41 +0000 (11:04 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 08:47:31 +0000 (10:47 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 08:40:02 +0000 (10:40 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 08:13:52 +0000 (10:13 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 07:45:10 +0000 (09:45 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 07:11:16 +0000 (09:11 +0200)]
NEU

19 months agoNEU
Kai Moritz [Thu, 20 Apr 2023 06:50:19 +0000 (08:50 +0200)]
NEU

19 months agoNEU
Kai Moritz [Wed, 19 Apr 2023 19:54:25 +0000 (21:54 +0200)]
NEU

19 months agoNEU
Kai Moritz [Wed, 19 Apr 2023 19:24:17 +0000 (21:24 +0200)]
NEU

19 months agoNEU
Kai Moritz [Wed, 19 Apr 2023 15:33:40 +0000 (17:33 +0200)]
NEU

19 months agoNEU
Kai Moritz [Wed, 19 Apr 2023 15:30:55 +0000 (17:30 +0200)]
NEU

19 months agoNEU
Kai Moritz [Wed, 19 Apr 2023 15:18:57 +0000 (17:18 +0200)]
NEU

19 months agoNEU
Kai Moritz [Wed, 19 Apr 2023 14:59:01 +0000 (16:59 +0200)]
NEU

19 months agoNEU
Kai Moritz [Sun, 16 Apr 2023 18:00:31 +0000 (20:00 +0200)]
NEU

19 months agoNEU
Kai Moritz [Sun, 16 Apr 2023 09:54:37 +0000 (11:54 +0200)]
NEU

19 months agoNEU
Kai Moritz [Sun, 16 Apr 2023 09:25:26 +0000 (11:25 +0200)]
NEU

19 months agoNEU
Kai Moritz [Sat, 15 Apr 2023 13:02:31 +0000 (15:02 +0200)]
NEU

19 months agoNEU
Kai Moritz [Sat, 15 Apr 2023 12:48:22 +0000 (14:48 +0200)]
NEU

19 months agoNEU
Kai Moritz [Sat, 15 Apr 2023 12:28:30 +0000 (14:28 +0200)]
NEU

19 months agoNEU
Kai Moritz [Sat, 15 Apr 2023 09:16:08 +0000 (11:16 +0200)]
NEU

19 months agoNEU
Kai Moritz [Sat, 15 Apr 2023 09:03:49 +0000 (11:03 +0200)]
NEU

19 months agoNEU
Kai Moritz [Sat, 15 Apr 2023 08:13:07 +0000 (10:13 +0200)]
NEU

19 months agoNEU
Kai Moritz [Fri, 14 Apr 2023 09:57:11 +0000 (11:57 +0200)]
NEU

19 months agoNEU
Kai Moritz [Fri, 14 Apr 2023 09:51:40 +0000 (11:51 +0200)]
NEU

19 months agoNEU
Kai Moritz [Fri, 14 Apr 2023 09:46:00 +0000 (11:46 +0200)]
NEU

19 months agoWIP
Kai Moritz [Fri, 14 Apr 2023 08:17:21 +0000 (10:17 +0200)]
WIP

20 months agoWIP
Kai Moritz [Tue, 28 Feb 2023 17:54:37 +0000 (18:54 +0100)]
WIP

20 months agoWIP:TODO
Kai Moritz [Sun, 26 Feb 2023 18:29:29 +0000 (19:29 +0100)]
WIP:TODO

20 months agoWIP:compiles!
Kai Moritz [Sun, 26 Feb 2023 18:26:50 +0000 (19:26 +0100)]
WIP:compiles!

20 months agoWIP
Kai Moritz [Sun, 26 Feb 2023 18:21:47 +0000 (19:21 +0100)]
WIP

20 months agoWIP
Kai Moritz [Sun, 26 Feb 2023 18:13:25 +0000 (19:13 +0100)]
WIP

20 months agoWIP
Kai Moritz [Sun, 26 Feb 2023 18:04:38 +0000 (19:04 +0100)]
WIP

20 months agoWIP
Kai Moritz [Sun, 26 Feb 2023 17:48:39 +0000 (18:48 +0100)]
WIP

20 months agoWIP
Kai Moritz [Sun, 26 Feb 2023 14:48:25 +0000 (15:48 +0100)]
WIP

20 months agoWIP
Kai Moritz [Sun, 26 Feb 2023 14:22:02 +0000 (15:22 +0100)]
WIP

20 months agoWIP:exception
Kai Moritz [Sun, 26 Feb 2023 14:17:21 +0000 (15:17 +0100)]
WIP:exception

20 months agoWIP
Kai Moritz [Sun, 26 Feb 2023 14:13:55 +0000 (15:13 +0100)]
WIP

20 months agoWIP
Kai Moritz [Sun, 26 Feb 2023 14:12:18 +0000 (15:12 +0100)]
WIP

20 months agoWIP
Kai Moritz [Sun, 26 Feb 2023 14:07:22 +0000 (15:07 +0100)]
WIP

20 months agoWIP
Kai Moritz [Sat, 18 Feb 2023 09:25:23 +0000 (10:25 +0100)]
WIP

20 months agoWIP
Kai Moritz [Fri, 17 Feb 2023 18:27:09 +0000 (19:27 +0100)]
WIP

20 months agoWIP
Kai Moritz [Fri, 17 Feb 2023 18:12:27 +0000 (19:12 +0100)]
WIP

20 months agoWIP
Kai Moritz [Fri, 17 Feb 2023 18:11:02 +0000 (19:11 +0100)]
WIP

20 months agoWIP
Kai Moritz [Fri, 17 Feb 2023 18:07:11 +0000 (19:07 +0100)]
WIP

20 months agoWIP
Kai Moritz [Wed, 25 Jan 2023 21:58:54 +0000 (22:58 +0100)]
WIP

20 months agoWIP
Kai Moritz [Wed, 25 Jan 2023 21:56:20 +0000 (22:56 +0100)]
WIP

20 months agoWIP
Kai Moritz [Sun, 22 Jan 2023 17:13:40 +0000 (18:13 +0100)]
WIP

20 months agorefactor: `ChatRoomFactory` returns real `ChatRoom`s
Kai Moritz [Sun, 26 Feb 2023 14:30:20 +0000 (15:30 +0100)]
refactor: `ChatRoomFactory` returns real `ChatRoom`s

- `ChatHomeService` only deals with real `ChatRoom`s.
- Hence, there is no need for `ChatRoomFactory`, to return the simplified
  interface `ChatRoomInfo`.
- This is, because the implementation specific logic is implemented in the
  `ChatHomeService`, not `ChatHome` itself: the actual implementation is
  hidden behind that service (and behind the service `ChatRoomService` in
  the domain-class `ChatRoom`).

21 months agotest: Proofed, that there is an NPE in `ShardedChatHome.getChatRoom()`
Kai Moritz [Sat, 18 Feb 2023 10:07:21 +0000 (11:07 +0100)]
test: Proofed, that there is an NPE in `ShardedChatHome.getChatRoom()`

- Refined `AbstractConfigurationIT` to show, that an NPE can occure in
  `ShardedChatHome.getChatRoom()`.
- Defined the expected behaviour, if the NPE is handled correctly in the
  refined integration-test.

21 months agorefactor: Refined the creation of new `ChatRoom`s
Kai Moritz [Fri, 17 Feb 2023 23:21:50 +0000 (00:21 +0100)]
refactor: Refined the creation of new `ChatRoom`s

- Dropped `ChatHomeService.putChatRoom(ChatRoom)`.
- `ChatRoomFactory.create(UUID, String)` returns `ChatRoomInfo`.

21 months agorefactor: DRY for the configuration of the `AbstractStorageStrategyIT`
Kai Moritz [Fri, 17 Feb 2023 23:10:03 +0000 (00:10 +0100)]
refactor: DRY for the configuration of the `AbstractStorageStrategyIT`

21 months agorefactor: Refined the configuration of `AbstractStorageStrategyIT'
Kai Moritz [Fri, 17 Feb 2023 22:34:55 +0000 (23:34 +0100)]
refactor: Refined the configuration of `AbstractStorageStrategyIT'

22 months agorefactor: `ChatRoomService.persistMessage(..)` returns a `Mono<Message>`
Kai Moritz [Tue, 24 Jan 2023 18:05:18 +0000 (19:05 +0100)]
refactor: `ChatRoomService.persistMessage(..)` returns a `Mono<Message>`

22 months agorefactor: Simplified the handling of `MessageMutationException`
Kai Moritz [Wed, 25 Jan 2023 21:08:11 +0000 (22:08 +0100)]
refactor: Simplified the handling of `MessageMutationException`

22 months agotest: Added a test that assers disjunct chatrooms
Kai Moritz [Sun, 22 Jan 2023 17:34:21 +0000 (18:34 +0100)]
test: Added a test that assers disjunct chatrooms

22 months agochore: Added a Docker-Build
Kai Moritz [Sun, 15 Jan 2023 18:48:34 +0000 (19:48 +0100)]
chore: Added a Docker-Build

22 months agofeat: Reintroduced `ChatRoom.shard`, becaus it is needed as a routing-hint
Kai Moritz [Sat, 14 Jan 2023 18:53:16 +0000 (19:53 +0100)]
feat: Reintroduced `ChatRoom.shard`, becaus it is needed as a routing-hint

- Technically, the attribute is not needed.
- But, to implement the gua/sha-pattern, it is needed as routing-hing.
- Hence, it is reintroduced here and also added to the `ChatRoomTo` to
  be send to the client.

22 months agofix: Fixed a NPE in `ShardedChatHome.getChatRooms()`
Kai Moritz [Sat, 14 Jan 2023 17:09:46 +0000 (18:09 +0100)]
fix: Fixed a NPE in `ShardedChatHome.getChatRooms()`

- When collecting the `ChatRoom`s for all shards, unused shards with a
  `null` value were not skipped.
- Also added log-messages of level `INFO` for the creation of `ChatRoom`,
  `SimpleChatHome` and `ShardedChatHome`.

22 months agofix: Removed unnecessary generic in `ChatHomeService`
Kai Moritz [Sat, 14 Jan 2023 17:11:56 +0000 (18:11 +0100)]
fix: Removed unnecessary generic in `ChatHomeService`

22 months agochore: Switched the default-configuration to sharding `none`
Kai Moritz [Sat, 14 Jan 2023 16:40:21 +0000 (17:40 +0100)]
chore: Switched the default-configuration to sharding `none`

22 months agorefactor: A `ChatRoom` does not have to remember its shard any more
Kai Moritz [Sat, 14 Jan 2023 16:33:02 +0000 (17:33 +0100)]
refactor: A `ChatRoom` does not have to remember its shard any more

- The shard of a `ChatRoom` can be derived from its ID, if the configured
  `ShardingStrategy` is known.
- Because the `ShardingStrategy` is known everywhere, where the shard of a
  `ChatRoom` is needed, it always can be derived dynamically.

22 months agorefactor: Pulled business-logic into class `ShardedChatHome`
Kai Moritz [Sat, 14 Jan 2023 15:47:04 +0000 (16:47 +0100)]
refactor: Pulled business-logic into class `ShardedChatHome`

- Pulled the logic that selects the appropriate shard from the class
  `ChatBackendController` into the newly introduced class
  `ShardedChatHome`.
- Simplified the configuration
  - `InMemoryServicesConfiguration` creates a `ChatHome` of type
    `SimpleChatHome`, if the `sharding-strategy` `none` is choosen.
  - In that case, the values for `num-shards` and `owned-shards` are
    ignored and set to `1` and `0`.
  - If the `sharding-strategy` is set to `kafkalike`, a `ChatHome` of
    type `ShardedChatHome` is instanciated and the configuration
    respects the configured sharding.
- Simplified the configuration of `ChatBackendControllerTest` accordingly.

22 months agorefactor: Made `SimpleChatHome` an implementation of `ChatHome`
Kai Moritz [Sat, 14 Jan 2023 15:07:04 +0000 (16:07 +0100)]
refactor: Made `SimpleChatHome` an implementation of `ChatHome`

22 months agorefactor: Removed `ChatHomeFactory`
Kai Moritz [Sat, 14 Jan 2023 15:01:55 +0000 (16:01 +0100)]
refactor: Removed `ChatHomeFactory`

- `ChatHomeFactory` was only used during initialization.
- By moving the instanciation of `chatHomes` into the implementation-
  specific configuration, the necessity of the factory vanished.

22 months agofeat: Introduced a kafka-like `ShardingStrategy` for `inmemory`
Kai Moritz [Fri, 13 Jan 2023 23:05:31 +0000 (00:05 +0100)]
feat: Introduced a kafka-like `ShardingStrategy` for `inmemory`

- Introduced the `ShardingStrategy`, that picks a shard for a given
  `ChatRoom`-ID.
  - Implemented a `KafkaLikeShardingStrategy`, that reuses the hashing
    algorithm, that is implementd in `Utils.murmur2()` in the
    `org.apache.kafka:kafka-clients` library.
  - The attribute `shard` of the `ChatHome` has to be restored according
    to the configured `ShardingStrategy` when loading the state - it must
    not be safed with the stored data, because it might change due to
    configuration-changes.
- The `ChatBackendController` was not configured correctly, because it
  had consumed the single `ChatHome` from the old configuration as the
  only entry in its `ChatHome[]`-array.
  - Refined the application-properties: Introduced an inner subclass
    `InMemoryServicesProperties` of `ChatBackendProperties`, that
    encapsulates the properties, that only concern the implementation
    `inmemory`.
  - Added the configuration-parameters `numShards` and `ownedShards`,
    that are needed by `inmemory`, to handle the sharding correctly.
- Introduced `ChatHomeFactory`, because the `ChatHome`s are instanciated
  by `ChatBackendConfiguration`, which is not aware of the configured
  implementation.
- Adjusted the test-cases to the changes.
- Added `InMemoryWithFilesAndShardingConfigurationIT`, that asserts,
  that the application works as expected, if sharding is activated.

22 months agotest: Streamlined the config-IT, so that they use the same expectations
Kai Moritz [Fri, 13 Jan 2023 20:44:02 +0000 (21:44 +0100)]
test: Streamlined the config-IT, so that they use the same expectations

- Both tests now use the same data and expect the same results.
- Moved the actual tests and assertions to `AbstractConfigurationIT`.
- Also streamlined `AbstractStorageStrategyIT`, so that it produces
  the exact same data, that the configuration-tests are expecting.
  This is not a necessary change to get the refined coniguration-tests
  running. It just makes it easier, to produce the needed test-data for
  future refinements.
- Also streamlined the naming of the directory, where
  `InMemoryWithFilesStorageIT` stores its data.

22 months agorefactor: Tried to simplify & clearify the naming of the integration-tests
Kai Moritz [Fri, 13 Jan 2023 20:29:29 +0000 (21:29 +0100)]
refactor: Tried to simplify & clearify the naming of the integration-tests

22 months agorefactor: DRY für shard-selection
Kai Moritz [Fri, 13 Jan 2023 19:37:36 +0000 (20:37 +0100)]
refactor: DRY für shard-selection

22 months agofeat: Prepared the application for sharding
Kai Moritz [Thu, 12 Jan 2023 22:40:12 +0000 (23:40 +0100)]
feat: Prepared the application for sharding

- The `ChatBackendController` stores the `ChatHome`s in an array.
- Reintroduced a `ChatRoomFactory`

22 months agotest: Added integration-test `InMemoryWithMongoDbStorageIT`
Kai Moritz [Wed, 11 Jan 2023 22:07:42 +0000 (23:07 +0100)]
test: Added integration-test `InMemoryWithMongoDbStorageIT`

22 months agofix: Supressed mongo-autoconfiguration if `FilesStorageStrategy` is active
Kai Moritz [Thu, 12 Jan 2023 21:58:56 +0000 (22:58 +0100)]
fix: Supressed mongo-autoconfiguration if `FilesStorageStrategy` is active

22 months agorefactor: Renamed the test to `InMemoryWithFilesStorageIT`
Kai Moritz [Thu, 12 Jan 2023 22:06:10 +0000 (23:06 +0100)]
refactor: Renamed the test to `InMemoryWithFilesStorageIT`

22 months agofeat: Refined `ChatBackendApplicationTest`
Kai Moritz [Wed, 11 Jan 2023 20:55:07 +0000 (21:55 +0100)]
feat: Refined `ChatBackendApplicationTest`

- Switched to a full server-startup (no MockMvc).
- Added some requests, that check the availability of the expected data.

22 months agorefactor: refined the endpoint-uri's
Kai Moritz [Wed, 11 Jan 2023 20:41:46 +0000 (21:41 +0100)]
refactor: refined the endpoint-uri's

22 months agofeat: Introduced config switches to choose the used implementations
Kai Moritz [Wed, 11 Jan 2023 18:09:53 +0000 (19:09 +0100)]
feat: Introduced config switches to choose the used implementations

- Switched the existing `@Configuration`-classes into an auto-configuration.
- Added a `@ConditionalOnProperty`, that loades the default-configuration.
- Added an Auto-Configuration for the `MongoDbStorageStrategy`, which is
  inactive by default and can be switched on by the property
  `chat.backend.storage` to `mongodb`.

22 months agofeat: configuration for service & storage lives in the according packages
Kai Moritz [Wed, 11 Jan 2023 17:38:39 +0000 (18:38 +0100)]
feat: configuration for service & storage lives in the according packages

22 months agotest: Activated the maven-failsafe-plugin
Kai Moritz [Tue, 10 Jan 2023 23:18:24 +0000 (00:18 +0100)]
test: Activated the maven-failsafe-plugin

22 months agofix: Added constraints for valid usernames
Kai Moritz [Tue, 10 Jan 2023 22:59:36 +0000 (23:59 +0100)]
fix: Added constraints for valid usernames

- This fix is necessary, because not all usernames can be stored in
  the newly introduced `MongoDbStorageStrategy`.

22 months agofeat: Implemented and tested `MongoDbStorageStrategy`
Kai Moritz [Mon, 9 Jan 2023 21:49:44 +0000 (22:49 +0100)]
feat: Implemented and tested `MongoDbStorageStrategy`

- Beware: The version 4.0.0 of Spring Data MongoDB that is included in
  Spring Boot 3.0.x does not work with version 4.8.1 of the MongoDB drivers
  that are included. Therefore, the version of the drivers was downgraded
  to 4.7.2 - See:
  https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#compatibility.matrix
- Also tried an upgrade of Spring Boot from 3.0.0 to 3.0.1, but without
  luck.
- Beware: Spring Boot 3.x does not include an autoconfigured embedded
  version of MongoDB for testing. It removed the autoconfiguration for
  `de.flapdoodle.embed:de.flapdoodle.embed.mongo` !

22 months agorefactor: Refined (simplified) `StorageStrategy`
Kai Moritz [Mon, 9 Jan 2023 21:46:42 +0000 (22:46 +0100)]
refactor: Refined (simplified) `StorageStrategy`

22 months agorefactor: Moved `FilesStorageStrategy` in its own package -- Rename
Kai Moritz [Mon, 9 Jan 2023 21:42:37 +0000 (22:42 +0100)]
refactor: Moved `FilesStorageStrategy` in its own package -- Rename