top10: 1.2.1 - (GREEN) Made the aggregation state accessible
[demos/kafka/wordcount] / src / main / java / de / juplo / kafka / wordcount / top10 / Top10ApplicationConfiguration.java
index 000db01..6e1f93f 100644 (file)
@@ -3,6 +3,8 @@ package de.juplo.kafka.wordcount.top10;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.kafka.clients.consumer.ConsumerConfig;
 import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.state.KeyValueBytesStoreSupplier;
+import org.apache.kafka.streams.state.Stores;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.ConfigurableApplicationContext;
@@ -55,12 +57,14 @@ public class Top10ApplicationConfiguration
        public Top10StreamProcessor streamProcessor(
                        Top10ApplicationProperties applicationProperties,
                        Properties streamProcessorProperties,
+                       KeyValueBytesStoreSupplier storeSupplier,
                        ConfigurableApplicationContext context)
        {
                Top10StreamProcessor streamProcessor = new Top10StreamProcessor(
                                applicationProperties.getInputTopic(),
                                applicationProperties.getOutputTopic(),
-                               streamProcessorProperties);
+                               streamProcessorProperties,
+                               storeSupplier);
 
                streamProcessor.streams.setUncaughtExceptionHandler((Throwable e) ->
                {
@@ -75,4 +79,10 @@ public class Top10ApplicationConfiguration
 
                return streamProcessor;
        }
+
+       @Bean
+       public KeyValueBytesStoreSupplier storeSupplier()
+       {
+               return Stores.persistentKeyValueStore("top10");
+       }
 }