`SimpleConsumer` in `ExampleConsumer` umbenannt -- MOVE
authorKai Moritz <kai@juplo.de>
Thu, 14 Nov 2024 19:42:25 +0000 (20:42 +0100)
committerKai Moritz <kai@juplo.de>
Thu, 14 Nov 2024 19:42:25 +0000 (20:42 +0100)
src/main/java/de/juplo/kafka/ExampleConsumer.java [new file with mode: 0644]
src/main/java/de/juplo/kafka/SimpleConsumer.java [deleted file]

diff --git a/src/main/java/de/juplo/kafka/ExampleConsumer.java b/src/main/java/de/juplo/kafka/ExampleConsumer.java
new file mode 100644 (file)
index 0000000..fe0479f
--- /dev/null
@@ -0,0 +1,36 @@
+package de.juplo.kafka;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.kafka.annotation.KafkaListener;
+import org.springframework.kafka.support.KafkaHeaders;
+import org.springframework.messaging.handler.annotation.Header;
+import org.springframework.messaging.handler.annotation.Payload;
+import org.springframework.stereotype.Component;
+
+
+@Slf4j
+@Component
+public class SimpleConsumer
+{
+  @Value("${spring.kafka.client-id}")
+  private String id;
+  private long consumed = 0;
+
+  @KafkaListener(topics = "${simple.consumer.topic}")
+  private void handleRecord(
+    @Header(KafkaHeaders.RECEIVED_TOPIC)
+    String topic,
+    @Header(KafkaHeaders.RECEIVED_PARTITION_ID)
+    Integer partition,
+    @Header(KafkaHeaders.OFFSET)
+    Long offset,
+    @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY)
+    String key,
+    @Payload
+    String value)
+  {
+    consumed++;
+    log.info("{} - {}: {}/{} - {}={}", id, offset, topic, partition, key, value);
+  }
+}
diff --git a/src/main/java/de/juplo/kafka/SimpleConsumer.java b/src/main/java/de/juplo/kafka/SimpleConsumer.java
deleted file mode 100644 (file)
index fe0479f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package de.juplo.kafka;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.kafka.annotation.KafkaListener;
-import org.springframework.kafka.support.KafkaHeaders;
-import org.springframework.messaging.handler.annotation.Header;
-import org.springframework.messaging.handler.annotation.Payload;
-import org.springframework.stereotype.Component;
-
-
-@Slf4j
-@Component
-public class SimpleConsumer
-{
-  @Value("${spring.kafka.client-id}")
-  private String id;
-  private long consumed = 0;
-
-  @KafkaListener(topics = "${simple.consumer.topic}")
-  private void handleRecord(
-    @Header(KafkaHeaders.RECEIVED_TOPIC)
-    String topic,
-    @Header(KafkaHeaders.RECEIVED_PARTITION_ID)
-    Integer partition,
-    @Header(KafkaHeaders.OFFSET)
-    Long offset,
-    @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY)
-    String key,
-    @Payload
-    String value)
-  {
-    consumed++;
-    log.info("{} - {}: {}/{} - {}={}", id, offset, topic, partition, key, value);
-  }
-}