From: Kai Moritz Date: Sat, 12 Nov 2022 11:35:27 +0000 (+0100) Subject: Vorlage X-Git-Tag: supersimple-producer--vorlage X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=f7c73046c9b8e47da9ac7d0ca55fcf4d6bb13956;p=demos%2Fkafka%2Ftraining Vorlage --- diff --git a/pom.xml b/pom.xml index ccab861..7c45311 100644 --- a/pom.xml +++ b/pom.xml @@ -64,10 +64,6 @@ - - pl.project13.maven - git-commit-id-plugin - io.fabric8 docker-maven-plugin diff --git a/src/main/java/de/juplo/kafka/Application.java b/src/main/java/de/juplo/kafka/Application.java index b304fa9..a44415e 100644 --- a/src/main/java/de/juplo/kafka/Application.java +++ b/src/main/java/de/juplo/kafka/Application.java @@ -7,10 +7,9 @@ import org.springframework.boot.ApplicationRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.kafka.core.KafkaTemplate; -import org.springframework.kafka.support.SendResult; -import org.springframework.util.concurrent.ListenableFuture; +// tag::supersimple[] @Slf4j @SpringBootApplication public class Application implements ApplicationRunner @@ -23,19 +22,7 @@ public class Application implements ApplicationRunner { for (int i = 0; i < 100; i++) { - // tag::callback[] - ListenableFuture> listenableFuture = - kafkaTemplate.send("test", Long.toString(i%10), Long.toString(i)); - - listenableFuture.addCallback( - result -> log.info( - "Sent {}={} to partition={}, offset={}", - result.getProducerRecord().key(), - result.getProducerRecord().value(), - result.getRecordMetadata().partition(), - result.getRecordMetadata().offset()), - e -> log.error("ERROR sendig message", e)); - // end::callback[] + kafkaTemplate.send("test", Long.toString(i%10), Long.toString(i)); } } @@ -44,3 +31,4 @@ public class Application implements ApplicationRunner SpringApplication.run(Application.class, args); } } +// end::supersimple[]