From: Kai Moritz Date: Sat, 12 Nov 2022 11:35:27 +0000 (+0100) Subject: Vorlage X-Git-Tag: spring/supersimple-producer--vorlage---2023-06-signal X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=4ac822b94baf88166e2acd158da8386edce2b865;p=demos%2Fkafka%2Ftraining Vorlage --- diff --git a/src/main/java/de/juplo/kafka/Application.java b/src/main/java/de/juplo/kafka/Application.java index 240f7d0..f6d6181 100644 --- a/src/main/java/de/juplo/kafka/Application.java +++ b/src/main/java/de/juplo/kafka/Application.java @@ -7,11 +7,8 @@ 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 @@ -24,21 +21,7 @@ public class Application implements ApplicationRunner { for (int i = 0; i < 100; i++) { - // end::supersimple[] - // 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[] - // tag::supersimple[] + kafkaTemplate.send("test", Long.toString(i%10), Long.toString(i)); } } @@ -47,4 +30,3 @@ public class Application implements ApplicationRunner SpringApplication.run(Application.class, args); } } -// end::supersimple[]