From e2933c8acd7ffd1c3a8530b0d34621c183ef09fa Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 24 Feb 2024 12:56:24 +0100 Subject: [PATCH] fix: The number of chards is the number of partitions of the `data_channel` --- .../kafka/chat/backend/implementation/kafka/InfoChannel.java | 5 ++--- .../implementation/kafka/KafkaServicesConfiguration.java | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/InfoChannel.java b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/InfoChannel.java index 2df7573c..f5d5253c 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/InfoChannel.java +++ b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/InfoChannel.java @@ -48,6 +48,7 @@ public class InfoChannel implements Runnable String topic, Producer producer, Consumer infoChannelConsumer, + int numShards, URI instanceUri) { log.debug( @@ -58,9 +59,7 @@ public class InfoChannel implements Runnable this.producer = producer; this.chatRoomInfo = new HashMap<>(); - this.numShards = consumer - .partitionsFor(topic) - .size(); + this.numShards = numShards; this.shardOwners = new String[numShards]; this.currentOffset = new long[numShards]; this.nextOffset = new long[numShards]; diff --git a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesConfiguration.java b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesConfiguration.java index b5a442f8..5a41ebcc 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesConfiguration.java +++ b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesConfiguration.java @@ -130,6 +130,7 @@ public class KafkaServicesConfiguration properties.getKafka().getInfoChannelTopic(), producer, infoChannelConsumer, + properties.getKafka().getNumPartitions(), properties.getKafka().getInstanceUri()); } -- 2.20.1