From 4ac822b94baf88166e2acd158da8386edce2b865 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 12 Nov 2022 12:35:27 +0100 Subject: [PATCH] Vorlage --- src/main/java/de/juplo/kafka/Application.java | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) 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[] -- 2.20.1