recorder: 1.1.0 - recordings are sent as JSON
[demos/kafka/wordcount] / src / main / java / de / juplo / kafka / wordcount / recorder / RecorderController.java
index f7e32e2..c9d2109 100644 (file)
@@ -18,10 +18,12 @@ import jakarta.validation.constraints.NotEmpty;
 public class RecorderController
 {
   private final String topic;
-  private final KafkaProducer<String, String> producer;
+  private final KafkaProducer<String, Recording> producer;
 
 
-  public RecorderController(RecorderApplicationProperties properties, KafkaProducer<String,String> producer)
+  public RecorderController(
+      RecorderApplicationProperties properties,
+      KafkaProducer<String,Recording> producer)
   {
     this.topic = properties.getTopic();
     this.producer = producer;
@@ -44,7 +46,11 @@ public class RecorderController
   {
     DeferredResult<ResponseEntity<RecordingResult>> result = new DeferredResult<>();
 
-    ProducerRecord<String, String> record = new ProducerRecord<>(topic, username, sentence);
+    ProducerRecord<String, Recording> record = new ProducerRecord<>(
+        topic,
+        username,
+        Recording.of(username, sentence));
+
     producer.send(record, (metadata, exception) ->
     {
       if (metadata != null)