Code an die aktualisierten Versionen von Java und Spring Kafka angepasst spring/spring-consumer--kafkalistener--BRANCH-ENDE
authorKai Moritz <kai@juplo.de>
Thu, 14 Nov 2024 20:21:58 +0000 (21:21 +0100)
committerKai Moritz <kai@juplo.de>
Thu, 14 Nov 2024 20:26:41 +0000 (21:26 +0100)
src/main/java/de/juplo/kafka/ApplicationProperties.java
src/main/java/de/juplo/kafka/ExampleConsumer.java

index b8caf5c..22c755e 100644 (file)
@@ -1,13 +1,12 @@
 package de.juplo.kafka;
 
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
 import lombok.Getter;
 import lombok.Setter;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.validation.annotation.Validated;
 
-import javax.validation.constraints.NotEmpty;
-import javax.validation.constraints.NotNull;
-
 
 @ConfigurationProperties(prefix = "juplo")
 @Validated
index 4aa417b..f669452 100644 (file)
@@ -21,11 +21,11 @@ public class ExampleConsumer
   private void handleRecord(
     @Header(KafkaHeaders.RECEIVED_TOPIC)
     String topic,
-    @Header(KafkaHeaders.RECEIVED_PARTITION_ID)
+    @Header(KafkaHeaders.RECEIVED_PARTITION)
     Integer partition,
     @Header(KafkaHeaders.OFFSET)
     Long offset,
-    @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY)
+    @Header(KafkaHeaders.RECEIVED_KEY)
     String key,
     @Payload
     String value)