+ ChatHome[] chatHomes = new ChatHome[properties.getInmemory().getNumShards()];
+ storageStrategy
+ .read()
+ .subscribe(chatRoom ->
+ {
+ int shard = chatRoom.getShard();
+ if (chatHomes[shard] == null)
+ chatHomes[shard] = new ChatHome(chatHomeService, shard);
+ });
+ return chatHomes;
+ }
+
+ @Bean
+ InMemoryChatHomeService chatHomeService(
+ ChatBackendProperties properties,
+ StorageStrategy storageStrategy)
+ {
+ return new InMemoryChatHomeService(
+ properties.getInmemory().getNumShards(),
+ properties.getInmemory().getOwnedShards(),
+ storageStrategy.read());