Merge der Refaktorisierung des EndlessConsumer (Branch 'stored-state')
[demos/kafka/training] / src / main / java / de / juplo / kafka / ApplicationConfiguration.java
index f228d85..54e9b89 100644 (file)
@@ -19,7 +19,7 @@ import java.util.function.Consumer;
 public class ApplicationConfiguration
 {
   @Bean
-  public Consumer<ConsumerRecord<String, String>> consumer()
+  public Consumer<ConsumerRecord<String, Long>> consumer()
   {
     return (record) ->
     {
@@ -28,15 +28,17 @@ public class ApplicationConfiguration
   }
 
   @Bean
-  public EndlessConsumer endlessConsumer(
-      KafkaConsumer<String, String> kafkaConsumer,
+  public EndlessConsumer<String, Long> endlessConsumer(
+      KafkaConsumer<String, Long> kafkaConsumer,
       ExecutorService executor,
-      Consumer<ConsumerRecord<String, String>> handler,
+      Consumer<ConsumerRecord<String, Long>> handler,
+      PartitionStatisticsRepository repository,
       ApplicationProperties properties)
   {
     return
-        new EndlessConsumer(
+        new EndlessConsumer<>(
             executor,
+            repository,
             properties.getClientId(),
             properties.getTopic(),
             kafkaConsumer,
@@ -50,13 +52,14 @@ public class ApplicationConfiguration
   }
 
   @Bean(destroyMethod = "close")
-  public KafkaConsumer<String, String> kafkaConsumer(ApplicationProperties properties)
+  public KafkaConsumer<String, Long> kafkaConsumer(ApplicationProperties properties)
   {
     Properties props = new Properties();
 
     props.put("bootstrap.servers", properties.getBootstrapServer());
     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("metadata.max.age.ms", "1000");
     props.put("key.deserializer", StringDeserializer.class.getName());