Vorlage simple-consumer-vorlage
authorKai Moritz <kai@juplo.de>
Tue, 2 Aug 2022 17:39:55 +0000 (19:39 +0200)
committerKai Moritz <kai@juplo.de>
Sat, 24 Sep 2022 18:25:49 +0000 (20:25 +0200)
src/main/java/de/juplo/kafka/SimpleConsumer.java

index cab2fb8..d5290bb 100644 (file)
@@ -45,28 +45,16 @@ public class SimpleConsumer
     try
     {
       log.info("{} - Subscribing to topic test", id);
-      consumer.subscribe(Arrays.asList("test"));
+      // TODO: subscribe!
       running = true;
 
       while (true)
       {
-        ConsumerRecords<String, String> records =
-            consumer.poll(Duration.ofSeconds(1));
-
-        log.info("{} - Received {} messages", id, records.count());
-        for (ConsumerRecord<String, String> record : records)
-        {
-          consumed++;
-          log.info(
-              "{} - {}: {}/{} - {}={}",
-              id,
-              record.offset(),
-              record.topic(),
-              record.partition(),
-              record.key(),
-              record.value()
-          );
-        }
+        // TODO:
+        // * Poll for new records
+        // * Loop through received records
+        // * Count received records in the variable `consumed`
+        // * "Work" with the data: Log partition/offset/key/value
       }
     }
     catch(WakeupException e)