From 62422d8b5ac2e569587bd9d659a8aea8dae51246 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 30 Jan 2021 16:45:34 +0100 Subject: [PATCH] Enabled idempotence for the producer --- .../java/de/juplo/kafka/outbox/delivery/OutboxProducer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/delivery/src/main/java/de/juplo/kafka/outbox/delivery/OutboxProducer.java b/delivery/src/main/java/de/juplo/kafka/outbox/delivery/OutboxProducer.java index 999883f..165e8e2 100644 --- a/delivery/src/main/java/de/juplo/kafka/outbox/delivery/OutboxProducer.java +++ b/delivery/src/main/java/de/juplo/kafka/outbox/delivery/OutboxProducer.java @@ -18,8 +18,7 @@ import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.PreDestroy; import static org.apache.kafka.clients.CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG; -import static org.apache.kafka.clients.producer.ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG; -import static org.apache.kafka.clients.producer.ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG; +import static org.apache.kafka.clients.producer.ProducerConfig.*; public class OutboxProducer @@ -48,6 +47,7 @@ public class OutboxProducer props.put(BOOTSTRAP_SERVERS_CONFIG, properties.bootstrapServers); props.put(KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); props.put(VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); + props.put(ENABLE_IDEMPOTENCE_CONFIG, true); this.producer = new KafkaProducer<>(props); this.topic = properties.topic; -- 2.20.1