From: Kai Moritz Date: Tue, 22 Nov 2022 18:29:32 +0000 (+0100) Subject: Vorlage X-Git-Tag: simple-consumer--vorlage---lvm-2-tage--easy-path X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=67892121b7727035089952bf65e0713f44a1b167;p=demos%2Fkafka%2Ftraining Vorlage --- diff --git a/pom.xml b/pom.xml index 2217d9b..e80e98c 100644 --- a/pom.xml +++ b/pom.xml @@ -34,10 +34,6 @@ - - pl.project13.maven - git-commit-id-plugin - org.apache.maven.plugins maven-dependency-plugin diff --git a/src/main/java/de/juplo/kafka/SimpleConsumer.java b/src/main/java/de/juplo/kafka/SimpleConsumer.java index 9741e67..880ed78 100644 --- a/src/main/java/de/juplo/kafka/SimpleConsumer.java +++ b/src/main/java/de/juplo/kafka/SimpleConsumer.java @@ -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 records = - consumer.poll(Duration.ofSeconds(1)); - - log.info("{} - Received {} messages", id, records.count()); - for (ConsumerRecord 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 {