`Application` in `ExampleProducer` umbenannt -- MOVE
authorKai Moritz <kai@juplo.de>
Tue, 12 Nov 2024 02:33:38 +0000 (03:33 +0100)
committerKai Moritz <kai@juplo.de>
Tue, 12 Nov 2024 02:33:38 +0000 (03:33 +0100)
src/main/java/de/juplo/kafka/Application.java [deleted file]
src/main/java/de/juplo/kafka/ExampleProducer.java [new file with mode: 0644]

diff --git a/src/main/java/de/juplo/kafka/Application.java b/src/main/java/de/juplo/kafka/Application.java
deleted file mode 100644 (file)
index 5e123dd..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-package de.juplo.kafka;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.ApplicationArguments;
-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
-{
-  @Autowired
-  KafkaTemplate<String, String> kafkaTemplate;
-
-  @Override
-  public void run(ApplicationArguments args)
-  {
-    for (int i = 0; i < 100; i++)
-    {
-      // end::supersimple[]
-      // tag::callback[]
-      ListenableFuture<SendResult<String, String>> listenableFuture =
-      // tag::supersimple[]
-          kafkaTemplate.sendDefault(Long.toString(i%10), Long.toString(i));
-      // end::supersimple[]
-
-      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[]
-    }
-  }
-
-  public static void main(String[] args)
-  {
-    SpringApplication.run(Application.class, args);
-  }
-}
-// end::supersimple[]
diff --git a/src/main/java/de/juplo/kafka/ExampleProducer.java b/src/main/java/de/juplo/kafka/ExampleProducer.java
new file mode 100644 (file)
index 0000000..5e123dd
--- /dev/null
@@ -0,0 +1,52 @@
+package de.juplo.kafka;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.ApplicationArguments;
+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
+{
+  @Autowired
+  KafkaTemplate<String, String> kafkaTemplate;
+
+  @Override
+  public void run(ApplicationArguments args)
+  {
+    for (int i = 0; i < 100; i++)
+    {
+      // end::supersimple[]
+      // tag::callback[]
+      ListenableFuture<SendResult<String, String>> listenableFuture =
+      // tag::supersimple[]
+          kafkaTemplate.sendDefault(Long.toString(i%10), Long.toString(i));
+      // end::supersimple[]
+
+      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[]
+    }
+  }
+
+  public static void main(String[] args)
+  {
+    SpringApplication.run(Application.class, args);
+  }
+}
+// end::supersimple[]