From badfc4b6fa99dc6f7fa9ffde004a82b8539bc4ec Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Mon, 1 Aug 2022 23:07:55 +0200 Subject: [PATCH] Angleichungen zwischen Producer/Consumer --- .../java/de/juplo/kafka/SimpleProducer.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/juplo/kafka/SimpleProducer.java b/src/main/java/de/juplo/kafka/SimpleProducer.java index fd03d73..9fcaa6e 100644 --- a/src/main/java/de/juplo/kafka/SimpleProducer.java +++ b/src/main/java/de/juplo/kafka/SimpleProducer.java @@ -19,18 +19,18 @@ public class SimpleProducer private volatile boolean running = true; private volatile boolean done = false; - public SimpleProducer(String broker, String topic, String id) + public SimpleProducer(String broker, String topic, String clientId) { Properties props = new Properties(); props.put("bootstrap.servers", broker); - props.put("client.id", id); // Nur zur Wiedererkennung + props.put("client.id", clientId); // Nur zur Wiedererkennung props.put("key.serializer", StringSerializer.class.getName()); props.put("value.serializer", StringSerializer.class.getName()); producer = new KafkaProducer<>(props); this.topic = topic; - this.id = id; + this.id = clientId; } public void run() @@ -124,14 +124,14 @@ public class SimpleProducer broker = args[0]; } - SimpleProducer producer = new SimpleProducer(broker, topic, clientId); + SimpleProducer instance = new SimpleProducer(broker, topic, clientId); Runtime.getRuntime().addShutdownHook(new Thread(() -> { - producer.running = false; - while (!producer.done) + instance.running = false; + while (!instance.done) { - log.info("Waiting for producer..."); + log.info("Waiting for main-thread..."); try { Thread.sleep(1000); @@ -142,10 +142,10 @@ public class SimpleProducer })); log.info( - "Running simple producer: broker={}, topic={}, client-id={}", + "Running SimpleProducer: broker={}, topic={}, client-id={}", broker, topic, clientId); - producer.run(); + instance.run(); } } -- 2.20.1