From 8b87f6dc6958b8622c37f7154e57abb0672ffa16 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 9 Jun 2023 11:16:42 +0200 Subject: [PATCH] Beispiele verwenden das Interface, um die erzeugte Instanz abzulegen --- src/main/java/de/juplo/kafka/SimpleConsumer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/juplo/kafka/SimpleConsumer.java b/src/main/java/de/juplo/kafka/SimpleConsumer.java index 9741e67..cee2165 100644 --- a/src/main/java/de/juplo/kafka/SimpleConsumer.java +++ b/src/main/java/de/juplo/kafka/SimpleConsumer.java @@ -3,6 +3,7 @@ package de.juplo.kafka; import lombok.extern.slf4j.Slf4j; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.apache.kafka.clients.consumer.Consumer; import org.apache.kafka.clients.consumer.KafkaConsumer; import org.apache.kafka.common.errors.WakeupException; import org.apache.kafka.common.serialization.StringDeserializer; @@ -17,7 +18,7 @@ public class SimpleConsumer { private final String id; private final String topic; - private final KafkaConsumer consumer; + private final Consumer consumer; private volatile boolean running = false; private long consumed = 0; @@ -33,10 +34,9 @@ public class SimpleConsumer props.put("key.deserializer", StringDeserializer.class.getName()); props.put("value.deserializer", StringDeserializer.class.getName()); - consumer = new KafkaConsumer<>(props); - - this.topic = topic; this.id = clientId; + this.topic = topic; + consumer = new KafkaConsumer<>(props); } -- 2.20.1