Kafka consumer APIs
Like Kafka producer, Kafka also provides a rich set of APIs to develop a consumer application. In previous sections of this chapter, you have learned about internal concepts of consumer, working of consumer within a consumer group, and partition rebalance. We will see how this concept helps in building a good consumer application.
- Consumer configuration
- KafkaConsumer object
- Subscription and polling
- Commit and offset
- Additional configuration
Consumer configuration
Creating Kafka consumer also requires a few mandatory properties to be set. There are basically four properties:
bootstrap.servers
: This property is similar to what we defined in Chapter 3, Deep Dive intoKafka Producers, for producer configuration. It takes a list of Kafka brokers' IPs.key.deserializer
: This is similar to what we specified in producer. The difference is that in producer, we specified the class that can serialize the key of the message. Serialize means converting a key to a ByteArray. In consumer, we...