ConsumerConfig — Configuration Properties for KafkaConsumer

ConsumerConfig is a Apache Kafka AbstractConfig for the configuration properties of a KafkaConsumer.

import org.apache.kafka.clients.consumer.ConsumerConfig

val conf = new java.util.Properties()
conf.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, ":9092,localhost:9192")
import org.apache.kafka.common.serialization.Serdes
conf.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, Serdes.String.deserializer.getClass)
conf.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, Serdes.String.deserializer.getClass)

import org.apache.kafka.clients.consumer.KafkaConsumer
val consumer = new KafkaConsumer[String, String](conf)
Table 1. ConsumerConfig’s Configuration Properties
Name, Property, Default Value Description

BOOTSTRAP_SERVERS_CONFIG

GROUP_ID_CONFIG

METADATA_MAX_AGE_CONFIG

metadata.max.age.ms

Default: 5 mins

The period of time (in milliseconds) after which we force a refresh of metadata even if we haven’t seen any partition leadership changes. That is to proactively discover any new brokers or partitions.

PARTITION_ASSIGNMENT_STRATEGY_CONFIG

partition.assignment.strategy

Default: RangeAssignor

The class name of the partition assignment strategy that the client will use to distribute partition ownership amongst consumer instances when group management is used

Tip
Read up Kafka Client-side Assignment Proposal on the group management in Apache Kafka’s Consumer API.

Used when:

  • KafkaConsumer is created

  • Kafka Streams' StreamsConfig is requested to getMainConsumerConfigs

Note
Required for KafkaConsumer to subscribe to topics

results matching ""

    No results matching ""