Vorlage
[demos/kafka/training] / src / main / java / de / juplo / kafka / ApplicationConfiguration.java
index 753422e..a580eb0 100644 (file)
@@ -8,7 +8,7 @@ import org.apache.kafka.common.serialization.StringSerializer;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-
+import org.springframework.kafka.support.serializer.JsonSerializer;
 import java.util.Properties;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -19,11 +19,11 @@ import java.util.concurrent.Executors;
 public class ApplicationConfiguration
 {
   @Bean
-  public SumUpRecordHandler sumUpRecordHandler(
-      KafkaProducer<String, String> kafkaProducer,
+  public ApplicationRecordHandler recordHandler(
+      KafkaProducer<String, Object> kafkaProducer,
       ApplicationProperties properties)
   {
-    return new SumUpRecordHandler(
+    return new ApplicationRecordHandler(
         kafkaProducer,
         properties.getClientId(),
         properties.getTopicOut());
@@ -33,7 +33,7 @@ public class ApplicationConfiguration
   public EndlessConsumer<String, Integer> endlessConsumer(
       KafkaConsumer<String, Integer> kafkaConsumer,
       ExecutorService executor,
-      SumUpRecordHandler sumUpRecordHandler,
+      ApplicationRecordHandler recordHandler,
       ApplicationProperties properties)
   {
     return
@@ -42,7 +42,7 @@ public class ApplicationConfiguration
             properties.getClientId(),
             properties.getTopicIn(),
             kafkaConsumer,
-            sumUpRecordHandler);
+            recordHandler);
   }
 
   @Bean
@@ -70,7 +70,7 @@ public class ApplicationConfiguration
   }
 
   @Bean(destroyMethod = "close")
-  public KafkaProducer<String, String> kafkaProducer(ApplicationProperties properties)
+  public KafkaProducer<String, Object> kafkaProducer(ApplicationProperties properties)
   {
     Properties props = new Properties();
     props.put("bootstrap.servers", properties.getBootstrapServer());
@@ -82,7 +82,7 @@ public class ApplicationConfiguration
     props.put("linger.ms", properties.getLingerMs());
     props.put("compression.type", properties.getCompressionType());
     props.put("key.serializer", StringSerializer.class.getName());
-    props.put("value.serializer", StringSerializer.class.getName());
+    props.put("value.serializer", "TODO: JsonSerializer konfigurieren");
 
     return new KafkaProducer<>(props);
   }