ROT: Korrigierten/Verbesserten Test und Überarbeitetes Setup gemerged
[demos/kafka/training] / src / main / java / de / juplo / kafka / ApplicationConfiguration.java
index b58295f..f83661e 100644 (file)
@@ -1,5 +1,6 @@
 package de.juplo.kafka;
 
+import org.apache.kafka.clients.consumer.Consumer;
 import org.apache.kafka.clients.consumer.KafkaConsumer;
 import org.apache.kafka.common.serialization.StringDeserializer;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -33,6 +34,7 @@ public class ApplicationConfiguration
       ApplicationRecordHandler recordHandler,
       AdderResults adderResults,
       StateRepository stateRepository,
+      Consumer<String, String> consumer,
       ApplicationProperties properties)
   {
     return new ApplicationRebalanceListener(
@@ -40,8 +42,10 @@ public class ApplicationConfiguration
         adderResults,
         stateRepository,
         properties.getClientId(),
+        properties.getTopic(),
         Clock.systemDefaultZone(),
-        properties.getCommitInterval());
+        properties.getCommitInterval(),
+        consumer);
   }
 
   @Bean
@@ -77,8 +81,8 @@ public class ApplicationConfiguration
     props.put("partition.assignment.strategy", "org.apache.kafka.clients.consumer.CooperativeStickyAssignor");
     props.put("group.id", properties.getGroupId());
     props.put("client.id", properties.getClientId());
+    props.put("enable.auto.commit", false);
     props.put("auto.offset.reset", properties.getAutoOffsetReset());
-    props.put("auto.commit.interval.ms", (int)properties.getCommitInterval().toMillis());
     props.put("metadata.max.age.ms", "1000");
     props.put("key.deserializer", StringDeserializer.class.getName());
     props.put("value.deserializer", StringDeserializer.class.getName());