From 489d4c545a614142b022b9da0eeaa3b0a0179797 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Wed, 24 Jan 2024 23:34:14 +0100 Subject: [PATCH] WIP --- src/main/java/de/juplo/kafka/SimpleProducer.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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()); -- 2.20.1