consumer_config with exact key-value pairsgroup_id with a specific string valueconsumer_config and group_idconsumer_config dictionaryconsumer_config with exact key-value pairsgroup_id with a specific string valueconsumer_config and group_idconsumer_config dictionaryconsumer_config with these exact entries: 'bootstrap.servers': 'localhost:9092', 'auto.offset.reset': 'earliest', and 'enable.auto.commit': False.Use curly braces {} to create a dictionary and separate key-value pairs with commas.
group_id and set it to the string 'my-consumer-group'.Assign the string 'my-consumer-group' to the variable group_id.
'group.id' with the value of the variable group_id to the consumer_config dictionary.Use square brackets [] to add a new key-value pair to the dictionary.
print statement to display the consumer_config dictionary.Use print(consumer_config) to show the dictionary content.
What is the purpose of setting group.id in Kafka consumer configuration?
group.idgroup.id identifies the consumer group that the consumer belongs to, allowing Kafka to coordinate message consumption among multiple consumers.Which of the following is the correct way to set the Kafka consumer's auto.offset.reset property to start reading from the earliest message?
auto.offset.resetGiven the following Kafka consumer configuration snippet, what will be the output behavior when consuming messages?
props.put("enable.auto.commit", "false");
props.put("auto.offset.reset", "earliest");
props.put("group.id", "my-group");Assuming this consumer starts fresh with no committed offsets, what happens?
enable.auto.commit settingauto.offset.reset and group.idIdentify the error in this Kafka consumer configuration snippet:
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("group.id", "test-group");
props.put("enable.auto.commit", true);
props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");You want a Kafka consumer to read messages from multiple topics and manually commit offsets only after processing batches successfully. Which configuration settings should you use?
consumer.subscribe(List.of(...)) allows subscribing to multiple topics easily.consumer.assign() for topics uses latest offset reset which may skip old messages; "enable.auto.commit" = "false" and set auto.offset.reset to "none" sets offset reset to "none" which causes errors if no offset found.consumer.subscribe(List.of(...)) -> Option Dconsumer.subscribe(List.of(...)) [OK]Pass the test and this pattern moves unknown