I’m trying to debug this code in a service framework class;
consumer = new org.apache.kafka.clients.consumer.KafkaConsumer(props);
consumer.subscribe(java.util.Collections.singletonList(topicName));
try {
while (true) {
org.apache.kafka.clients.consumer.ConsumerRecords records = consumer.poll(100L);
for (org.apache.kafka.clients.consumer.ConsumerRecord record : records) {
// Some more code here
}
}
} finally {
consumer.close();
}
Compilation of this code gives this ‘helpful’ error:
tsource error] ; is missing
The (almost exact) same code in Eclipse works fine:
KafkaConsumer<String, String> consumer = new KafkaConsumer<String, String>(props);
consumer.subscribe(Arrays.asList(topicName));
try {
while (true) {
ConsumerRecords<String, String> records = consumer.poll(100L);
for (ConsumerRecord<String, String> record : records) {
System.out.printf("offset = %d, key = %s, value = %s\n", record.offset(), record.key(), record.value());
}
}
} finally {
consumer.close();
}
The error is triggered by this line:
for (org.apache.kafka.clients.consumer.ConsumerRecord record : records)
Anyone have any idea what the problem might be? Or have some tips on how to pinpoint the issue?