Complete the code to create a Kafka consumer with the correct group ID.
Properties props = new Properties(); props.put("bootstrap.servers", "localhost:9092"); props.put("group.id", "[1]"); props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
Complete the code to subscribe the consumer to a topic named 'test-topic'.
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props); consumer.[1](Collections.singletonList("test-topic"));
Fix the error in the code to correctly poll messages from Kafka.
ConsumerRecords<String, String> records = consumer.[1](100);
Fill both blanks to process each record and print its key and value.
for (ConsumerRecord<String, String> record : records) { System.out.println("Key: " + record.[1]() + ", Value: " + record.[2]()); }
Fill all three blanks to commit offsets synchronously after processing records.
try { consumer.[1](); } catch ([2] e) { e.[3](); }
