liveBook · Manning

Kafka transaction

As explained in Kafka for Architects

A Kafka transaction is an atomic operation that groups record production and related offset handling so their effects can be committed or aborted together.

A Kafka transaction groups a stream-processing operation so a service can read an event, process it, and publish related results atomically. This addresses the architectural risk of partial downstream updates when failures or retries occur. section 7.4.2

Unlike a general database transaction, Kafka transactions target read-process-write applications. Their central guarantee is exactly-once processing: outputs appear once even when the service fails or retries, rather than exposing duplicated or skipped results. section 7.4.2

Order processing

An OrderService reads an event from ORDERS and produces corresponding events to SHIPMENTS, BILLING, and INVENTORY. A transaction keeps these effects together, preventing one downstream topic from receiving an update while another misses it. section 7.4.2

A Kafka transaction is useful when:

  • A single input event must produce a consistent set of outputs across multiple topics. section 7.4.2
  • Retries or service failures could otherwise duplicate results or leave downstream data incomplete. section 7.4.2
  • Consumers need isolation choices that determine whether uncommitted messages are visible. section 7.4.2
Figure 7.24 OrderService reads, processes, and writes each event atomically.
A white rectangle with black text

AI-generated content may be incorrect.

Use the event-flow diagram to trace one input through processing and atomic publication of its results. section 7.4.2

How Kafka for Architects covers it

How deep it goes
Defines the Kafka-specific exactly-once model and consumer isolation, without providing a low-level implementation walkthrough.
Examples
Uses an OrderService that reads ORDERS and writes SHIPMENTS, BILLING, and INVENTORY atomically.
What it assumes
Builds from database ACID properties and assumes a Kafka pipeline that reads, processes, and produces events.
What you can do after
Apply Kafka transactions to read-process-write workflows requiring exactly-once results across multiple output topics.
How it connects
Connects transactions with stream processing, ACID properties, exactly-once semantics, retries, failures, and consumer isolation levels.

Also explained in

Compare how 3 books explain Kafka transaction →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka for Architects. The section links point to the parts of the book it draws on.