Apache Kafka is a distributed message broker built for scalable, resilient event streaming. It organizes publish/subscribe messaging through replicated topics divided across partitions and brokers. section 9.3
Kafka’s cluster model provides several important building blocks:
- Clusters contain multiple brokers, with each node leading one or more topics or partitions. section 9.3
- Topics are replicated across brokers for resilience and divided into partitions for distributed responsibility. section 9.3
- Kafka uses topics for publish/subscribe messaging rather than the exchange-and-queue model associated with RabbitMQ. section 9.3
Sending orders with Spring
Add the spring-kafka dependency to a Spring application, configure one or more bootstrap servers, and inject KafkaTemplate<String, TacoOrder>. Calling kafkaTemplate.send("tacocloud.orders.topic", order) publishes a TacoOrder directly to the named topic. During local development, KafkaTemplate defaults to localhost:9092; production configuration should provide the cluster’s bootstrap servers. section 9.3.1 section 9.3.2
Figure 9.3 A Kafka cluster is composed of multiple brokers, each acting as a leader for partitions of the topics.
Use the cluster diagram to see how brokers lead different topic partitions while replicating topic data across the cluster. section 9.3





