WIP
authorKai Moritz <kai@juplo.de>
Wed, 24 Jan 2024 22:34:14 +0000 (23:34 +0100)
committerKai Moritz <kai@juplo.de>
Wed, 24 Jan 2024 22:34:14 +0000 (23:34 +0100)
src/main/java/de/juplo/kafka/SimpleProducer.java

index 3cf1128..b1b1992 100644 (file)
@@ -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());