Vorlage simple-consumer--vorlage---lvm-2-tage--easy-path
authorKai Moritz <kai@juplo.de>
Tue, 22 Nov 2022 18:29:32 +0000 (19:29 +0100)
committerKai Moritz <kai@juplo.de>
Tue, 22 Nov 2022 18:29:32 +0000 (19:29 +0100)
pom.xml
src/main/java/de/juplo/kafka/SimpleConsumer.java

diff --git a/pom.xml b/pom.xml
index 2217d9b..e80e98c 100644 (file)
--- a/pom.xml
+++ b/pom.xml
 
   <build>
     <plugins>
-      <plugin>
-        <groupId>pl.project13.maven</groupId>
-        <artifactId>git-commit-id-plugin</artifactId>
-      </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
index 9741e67..880ed78 100644 (file)
@@ -45,28 +45,16 @@ public class SimpleConsumer
     try
     {
       log.info("{} - Subscribing to topic {}", id, topic);
-      consumer.subscribe(Arrays.asList(topic));
+      // 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)
@@ -76,7 +64,6 @@ public class SimpleConsumer
     catch(Exception e)
     {
       log.error("{} - Unexpected error: {}, unsubscribing!", id, e.toString());
-      consumer.unsubscribe();
     }
     finally
     {