-
- Mono<ChatRoomInfo> sendCreateChatRoomRequest(
- UUID chatRoomId,
- String name)
- {
- int shard = this.shardingStrategy.selectShard(chatRoomId);
- ChatRoomTo chatRoomTo = ChatRoomTo.of(chatRoomId, name, shard);
- return Mono.create(sink ->
- {
- ProducerRecord<Integer, ChatRoomTo> record =
- new ProducerRecord<>(
- topic,
- shard,
- chatRoomTo);
-
- producer.send(record, ((metadata, exception) ->
- {
- if (metadata != null)
- {
- log.info("Successfully send chreate-request for chat room: {}", chatRoomTo);
- sink.success(chatRoomTo.toChatRoomInfo());
- }
- else
- {
- // On send-failure
- log.error(
- "Could not send create-request for chat room (id={}, name={}): {}",
- chatRoomId,
- name,
- exception);
- sink.error(exception);
- }
- }));
- });
- }