Skip to content

Commit

Permalink
Single instance per topic rather than per worker
Browse files Browse the repository at this point in the history
Signed-off-by: Chase Engelbrecht <[email protected]>
  • Loading branch information
engechas committed Oct 25, 2023
1 parent 22b33ac commit abb69fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public List<KafkaCustomConsumer> createConsumersForTopic(final KafkaConsumerConf

try {
final int numWorkers = topic.getWorkers();
final TopicEmptinessMetadata topicEmptinessMetadata = new TopicEmptinessMetadata();
IntStream.range(0, numWorkers).forEach(index -> {
KafkaDataConfig dataConfig = new KafkaDataConfigAdapter(keyFactory, topic);
Deserializer<Object> keyDeserializer = (Deserializer<Object>) serializationFactory.getDeserializer(PlaintextKafkaDataConfig.plaintextDataConfig(dataConfig));
Expand All @@ -93,7 +94,7 @@ public List<KafkaCustomConsumer> createConsumersForTopic(final KafkaConsumerConf
final KafkaConsumer kafkaConsumer = new KafkaConsumer<>(consumerProperties, keyDeserializer, valueDeserializer);

consumers.add(new KafkaCustomConsumer(kafkaConsumer, shutdownInProgress, buffer, kafkaConsumerConfig, topic,
schemaType, acknowledgementSetManager, byteDecoder, topicMetrics, new TopicEmptinessMetadata()));
schemaType, acknowledgementSetManager, byteDecoder, topicMetrics, topicEmptinessMetadata));

});
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void start(Buffer<Record<Event>> buffer) {
int numWorkers = topic.getWorkers();
executorService = Executors.newFixedThreadPool(numWorkers);
allTopicExecutorServices.add(executorService);
final TopicEmptinessMetadata topicEmptinessMetadata = new TopicEmptinessMetadata();

IntStream.range(0, numWorkers).forEach(index -> {
while (true) {
Expand All @@ -140,7 +141,7 @@ public void start(Buffer<Record<Event>> buffer) {

}
consumer = new KafkaCustomConsumer(kafkaConsumer, shutdownInProgress, buffer, sourceConfig, topic, schemaType,
acknowledgementSetManager, null, topicMetrics, new TopicEmptinessMetadata());
acknowledgementSetManager, null, topicMetrics, topicEmptinessMetadata);
allTopicConsumers.add(consumer);

executorService.submit(consumer);
Expand Down

0 comments on commit abb69fa

Please sign in to comment.