liveBook · Manning

Topic

As explained in Kafka for Architects

A Kafka topic is a named, append-oriented stream of records that Kafka stores and makes available to consumers.

A Kafka topic is a named destination that groups related messages. A producer names the topic when sending a message; a consumer subscribes to the topics it wants to read. A common design is one topic per message type, so services can select the data they need without sharing a single undifferentiated stream. section 2.2

Separate customer data by type

For a customer dashboard, one service sends financial transactions to a Transactions topic and another sends profile updates to a Profiles topic. A consuming service reads both to assemble a customer view. The separation makes each topic’s purpose clear while allowing one application to combine their data. section 2.2

Figure 2.3 Kafka topics, where each distinct type of message is segregated into its designated topic. Here, we have two services functioning as producers, each sending data to its respective topic. Additionally, a single consumer service subscribes to and consumes data from both topics.
A diagram of a diagram

AI-generated content may be incorrect.

Shows two producers sending distinct message types to separate topics, with one consumer reading both. section 2.2

A topic is divided into partitions, which enable parallel processing. Message order is guaranteed within a partition, not across an entire multi-partition topic. A message key can route related messages to the same partition when their order matters. Consumers pull messages from subscribed topics; within a consumer group, each partition is assigned to one consumer at a time. section 2.7 section 4.1

Choose retention for the job. A topic can delete older messages under a time or size policy. A compacted topic instead retains at least the latest message for each key, making it useful for current state, such as account balances or customer records. Compaction does not turn the topic into a quick key lookup: a consumer still reads the log sequentially to build its view. Older values may remain until cleanup, but their complete history is not guaranteed. section 2.0 section 2.5.1

Topic design follows business requirements. Decide whether related events need ordering, whether consumers need history or only current state, and how critical or sensitive the data is. Those answers shape keys, partitioning, retention, replication and access controls; Kafka is not automatically the right fit for every workflow. section 10.1.3

How Kafka for Architects covers it

How deep it goes
Explains naming, subscriptions, partitions, ordering, retention and compaction, including the limits of cross-partition order and key lookup.
Examples
Uses separate transaction and profile topics for a customer dashboard and a compacted account-balance topic for current state.
What it assumes
Assumes possible familiarity with messaging destinations while defining Kafka topic names and producer-consumer interactions explicitly.
What you can do after
Operate/configure Kafka topics by choosing keys, partitioning and retention policies to meet ordering, history and current-state needs.
How it connects
Connects topics to producers, consumers, partitions, message keys, consumer groups, log compaction and retention policies.

Also explained in

Compare how 5 books explain topic →

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.