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




