fix: The number of chards is the number of partitions of the `data_channel`
authorKai Moritz <kai@juplo.de>
Sat, 24 Feb 2024 11:56:24 +0000 (12:56 +0100)
committerKai Moritz <kai@juplo.de>
Sat, 24 Feb 2024 11:56:24 +0000 (12:56 +0100)
src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/InfoChannel.java
src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesConfiguration.java

index 2df7573..f5d5253 100644 (file)
@@ -48,6 +48,7 @@ public class InfoChannel implements Runnable
     String topic,
     Producer<String, AbstractMessageTo> producer,
     Consumer<String, AbstractMessageTo> 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];
index b5a442f..5a41ebc 100644 (file)
@@ -130,6 +130,7 @@ public class KafkaServicesConfiguration
         properties.getKafka().getInfoChannelTopic(),
         producer,
         infoChannelConsumer,
+        properties.getKafka().getNumPartitions(),
         properties.getKafka().getInstanceUri());
   }