Why this matters
- Prerequisite for Kafka transactions and EOS pipelines at VaultCommerce.
enable.idempotence=truesets safe defaults: acks=all, retries>0, max.in.flight=5.- Without idempotence, network retries after timeout create duplicate order events.
- PID (producer id) persists for transactional.id lifetime — don't recycle randomly.
Sequence numbers and PID
On first send to a partition, broker assigns a producer ID (PID). Each message gets a monotonic sequence per PID-partition pair. If broker sees duplicate sequence, it acks without appending. VaultCommerce enables idempotence on every production producer.
Key points
- enable.idempotence — turns on PID and sequence dedup at broker
- Producer ID (PID) — broker-assigned identifier per producer instance
- Sequence number — per-partition ordering of sends from one PID
- max.in.flight.requests.per.connection=5 — safe with idempotence (was 1 pre-KIP-98)
- Transactional producer — extends idempotence with transaction coordinator
Limits and scope
Idempotence covers producer retries within delivery.timeout.ms — not application-level duplicate publishes from two different producer instances with the same payload. Consumer idempotency keys still required for end-to-end safety.
VaultCommerce rollout checklist
Before promoting changes that touch vaultcommerce.orders.placed.v1 and vaultcommerce.payments.captured.v1, run the staging KRaft cluster (Kafka 3.7+, Schema Registry 7.x) through a 10k events/min soak test. Compare producer request latency p99 and consumer lag per group against the pre-deploy baseline. enable.idempotence=true prevents log duplicates on retry. Document the change in the internal topic registry, attach Grafana screenshots to the change ticket, and keep an engineer on lag dashboards for 30 minutes after production rollout — roll back the service release before altering broker-level settings if lag or under-replicated partitions spike.
// VaultCommerce — idempotent producer (required before transactions)
props.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true);
// Implicit: ACKS_CONFIG=all, RETRIES_CONFIG=Integer.MAX_VALUE,
// MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION=5
try (KafkaProducer<String, PaymentCaptured> producer = new KafkaProducer<>(props)) {
producer.send(new ProducerRecord<>("vaultcommerce.payments.captured.v1",
orderId, new PaymentCaptured(orderId, txnId, amount)));
// Retry after timeout will not duplicate on the log
}
Quick recall
Everything you need if you only revisit this box.
- enable.idempotence=true prevents log duplicates on retry.
- Does not dedup across separate producer instances.
- Required foundation for EOS transactions.
Test yourself
Answer these before moving on — recall is what makes it stick.