Message.MessageKey key = Message.MessageKey.of(chatMessageTo.getUser(), chatMessageTo.getId());
Message message = new Message(key, offset, timestamp, chatMessageTo.getText());
- ChatRoomData chatRoomData = this.chatRoomData[partition].computeIfAbsent(
- chatRoomId,
- (id) ->
- {
- log.info("Creating ChatRoom {} with buffer-size {}", id, bufferSize);
- KafkaChatMessageService service = new KafkaChatMessageService(this, id);
- return new ChatRoomData(clock, service, bufferSize);
- });
+ ChatRoomData chatRoomData = this
+ .chatRoomData[partition]
+ .computeIfAbsent(chatRoomId, this::computeChatRoomData);
KafkaChatMessageService kafkaChatRoomService =
(KafkaChatMessageService) chatRoomData.getChatRoomService();
return infoChannel
.getChatRoomInfo(id)
- .map(chatRoomInfo -> chatRoomData[shard].computeIfAbsent(
- id,
- computeChatRoomData()));
+ .map(chatRoomInfo ->
+ chatRoomData[shard].computeIfAbsent(id, this::computeChatRoomData));
}
- private Function<UUID, ChatRoomData> computeChatRoomData()
+ private ChatRoomData computeChatRoomData(UUID chatRoomId)
{
- return (chatRoomId) ->
- {
- log.info("Creating ChatRoom {} with buffer-size {}", chatRoomId, bufferSize);
- KafkaChatMessageService service = new KafkaChatMessageService(this, chatRoomId);
- return new ChatRoomData(clock, service, bufferSize);
- };
+ log.info("Creating ChatRoom {} with buffer-size {}", chatRoomId, bufferSize);
+ KafkaChatMessageService service = new KafkaChatMessageService(this, chatRoomId);
+ return new ChatRoomData(clock, service, bufferSize);
}
}