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

REQUEST_TIMEOUT_MS_CONFIG

request.timeout.ms

Default: 30000 ms

How long (in millis) a Kafka client waits for a response to a request.

If the response is not received before the timeout elapses the client will resend the request if necessary or fail the request if retries are exhausted.

Must be at least 0

results matching ""

    No results matching ""