X-Git-Url: http://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Fkafka%2FApplicationConfiguration.java;h=2cf263e9f1ec4d1f0afeec13676d090aa49890c1;hb=a6a0a22a5fa34a01b0e8b2bc1e0e2b82d7b60f33;hp=9b06b09367f7cf748dd6d770bd517ee4fcbede38;hpb=ecd63311e0b6af698185bcf1e085f2b3237bd264;p=demos%2Fkafka%2Ftraining diff --git a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java index 9b06b09..2cf263e 100644 --- a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java +++ b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java @@ -2,7 +2,6 @@ package de.juplo.kafka; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.KafkaConsumer; -import org.apache.kafka.common.serialization.LongDeserializer; import org.apache.kafka.common.serialization.StringDeserializer; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -20,32 +19,21 @@ import java.util.function.Consumer; public class ApplicationConfiguration { @Bean - public Consumer> consumer() - { - return (record) -> - { - // Handle record - }; - } - - @Bean - public EndlessConsumer endlessConsumer( - KafkaConsumer kafkaConsumer, + public EndlessConsumer endlessConsumer( + KafkaConsumer kafkaConsumer, ExecutorService executor, - Consumer> handler, PartitionStatisticsRepository repository, ApplicationProperties properties) { return - new EndlessConsumer<>( + new EndlessConsumer( executor, repository, properties.getClientId(), properties.getTopic(), Clock.systemDefaultZone(), properties.getCommitInterval(), - kafkaConsumer, - handler); + kafkaConsumer); } @Bean @@ -55,7 +43,7 @@ public class ApplicationConfiguration } @Bean(destroyMethod = "close") - public KafkaConsumer kafkaConsumer(ApplicationProperties properties) + public KafkaConsumer kafkaConsumer(ApplicationProperties properties) { Properties props = new Properties(); @@ -67,7 +55,7 @@ public class ApplicationConfiguration props.put("auto.offset.reset", properties.getAutoOffsetReset()); props.put("metadata.max.age.ms", "1000"); props.put("key.deserializer", StringDeserializer.class.getName()); - props.put("value.deserializer", LongDeserializer.class.getName()); + props.put("value.deserializer", StringDeserializer.class.getName()); return new KafkaConsumer<>(props); }