Vorlage supersimple-producer--vorlage supersimple-producer--vorlage---lvm-2-tage--easy-path
authorKai Moritz <kai@juplo.de>
Sat, 12 Nov 2022 11:35:27 +0000 (12:35 +0100)
committerKai Moritz <kai@juplo.de>
Wed, 23 Nov 2022 03:27:20 +0000 (04:27 +0100)
pom.xml
src/main/java/de/juplo/kafka/Application.java

diff --git a/pom.xml b/pom.xml
index ccab861..7c45311 100644 (file)
--- a/pom.xml
+++ b/pom.xml
           </execution>
         </executions>
       </plugin>
-      <plugin>
-        <groupId>pl.project13.maven</groupId>
-        <artifactId>git-commit-id-plugin</artifactId>
-      </plugin>
       <plugin>
         <groupId>io.fabric8</groupId>
         <artifactId>docker-maven-plugin</artifactId>
index b304fa9..a44415e 100644 (file)
@@ -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<SendResult<String, String>> 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[]