From: Kai Moritz Date: Sat, 30 Jan 2021 15:45:34 +0000 (+0100) Subject: Enabled idempotence for the producer X-Git-Tag: part-2~3 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=70ec0ac46ecafcd10cb4224c67439f9039067bba;p=demos%2Fkafka%2Foutbox Enabled idempotence for the producer --- 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 49f777f..09c8789 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 @@ -17,8 +17,7 @@ import org.springframework.stereotype.Component; 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.*; @Component @@ -43,6 +42,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;