]> juplo.de Git - demos/kafka/chat/commitdiff
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 2df7573cc684c27497d4f00b2ab6a62930c308f8..f5d5253c15ddd4b437c273d61428422150d7a6b9 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 b5a442f8df86b01e7153aec818ba458bffff55c1..5a41ebcc65c41575371bee7a13f4c887574d064a 100644 (file)
@@ -130,6 +130,7 @@ public class KafkaServicesConfiguration
         properties.getKafka().getInfoChannelTopic(),
         producer,
         infoChannelConsumer,
+        properties.getKafka().getNumPartitions(),
         properties.getKafka().getInstanceUri());
   }