From: Kai Moritz Date: Wed, 24 Jan 2024 22:34:14 +0000 (+0100) Subject: WIP X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=489d4c545a614142b022b9da0eeaa3b0a0179797;p=demos%2Fkafka%2Ftraining WIP --- diff --git a/src/main/java/de/juplo/kafka/SimpleProducer.java b/src/main/java/de/juplo/kafka/SimpleProducer.java index 3cf1128..b1b1992 100644 --- a/src/main/java/de/juplo/kafka/SimpleProducer.java +++ b/src/main/java/de/juplo/kafka/SimpleProducer.java @@ -22,11 +22,17 @@ public class SimpleProducer private volatile boolean done = false; public SimpleProducer(String broker, String topic, String clientId) + { + this(broker, topic, clientId, null); + } + + public SimpleProducer(String broker, String topic, String clientId, String transactionalId) { Properties props = new Properties(); props.put("bootstrap.servers", broker); props.put("client.id", clientId); // Nur zur Wiedererkennung - props.put("transactional.id", clientId); // Aktiviert außerdem enable.idempotence=true + if (transactionalId != null) + props.put("transactional.id", transactionalId); // Aktiviert außerdem enable.idempotence=true props.put("key.serializer", StringSerializer.class.getName()); props.put("value.serializer", StringSerializer.class.getName());