liveBook · Manning

Topic

As explained in Kafka Streams in Action, Second Edition

A Kafka topic is a named, append-only stream of records that producers publish to and consumers read from.

A Kafka topic is a named, append-only stream of records: producers write records to a broker, which durably stores them, and consumers read them later. Producers and consumers operate independently; consuming does not determine how long records remain stored. section 4.1 section 2.11

A topic is partitioned into buckets. Partitions spread records across brokers for throughput and load distribution, while brokers replicate data for durable storage. Kafka guarantees record order within a topic partition, not across partitions or across topics. section 2.11 section 4.6

Topics decouple teams that use the same events. A retailer can write sales data once, then let promotions assign rewards, data science derive sales trends into another topic, and inventory systems react independently at their own times. section 1.5

Create and use a topic locally in a short loop:

  • Start a Kafka broker with Docker Compose, then create a topic with a name, bootstrap server, replication factor, and partition count. section 2.5.1
  • For local development, use one partition and replication factor 1; production-oriented partitioning and replication serve throughput and durability needs. section 2.5.1 section 2.11
  • Subscribe a KafkaConsumer to the topic and repeatedly poll records returned from the broker. section 4.3

Keeping related website events together

Login, search, and purchase events can share one topic when their sequence matters. Use a consistent key so related event types arrive in order on the same partition; use Schema Registry to handle multiple event types safely. section 4.6

kafka-topics --create --topic first-topic\
 --bootstrap-server localhost:9092\        #1
 --replication-factor 1\       #2
 --partitions 1      #3

Use the command as a minimal local topic-creation template: supply a topic name, broker address, replication factor, and partition count. section 2.5.1

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Explains topic storage, partitions, replication, ordering, local creation, and consumer polling; defers prior Schema Registry detail.
Examples
Uses retail sales, rewards, sales trends, inventory, and keyed login-search-purchase clickstream events.
What it assumes
Assumes Docker is installed for the local broker and refers readers elsewhere for Schema Registry background.
What you can do after
Operate/configure topics locally, then produce and poll records through Kafka clients.
How it connects
Connects topics to Kafka brokers, partitions, producers, consumers, Kafka Connect, Kafka Streams, and Schema Registry.

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 Streams in Action, Second Edition. The section links point to the parts of the book it draws on.