Overview
Kafka transactions allow atomic writes across multiple partitions and topics. A transactional producer sets transactional.id, which also implies idempotence, and if a producer restarts with the same ID, a transaction left open by the earlier instance is aborted. Consumers with isolation.level=read_committed return only committed transactional messages and filter out aborted ones; messages after an open transaction are held back until it completes, because the consumer is limited to the last stable offset. Transactions are what Kafka Streams uses for exactly-once processing, and the transactional producer and a read_committed consumer can also be used directly for read-process-write cycles on Kafka topics.
Key configuration
transactional.id=my-producer-v1 — unique per producer instance
transaction.timeout.ms — how long a transaction can stay open before the coordinator aborts it
isolation.level=read_committed — consumer side; the default is read_uncommitted
enable.auto.commit=false — consumer side, required for exactly-once consumptionProduction tip
Check yourself
A transactional producer crashes mid-transaction and restarts with the same transactional.id. What happens to the pending transaction?
Sources
- KafkaProducer Javadoc (4.2) (opens in a new tab)
- Design (4.2 documentation) (opens in a new tab)
- Producer configs (4.2 documentation) (opens in a new tab)
- Consumer configs (4.2 documentation) (opens in a new tab)
Checked against Kafka 4.2 documentation on Oct 2026. Draft: not yet reviewed by a Kafka specialist. Releases move on, so confirm against the current documentation before you act on a number.