liveBook · Manning

Apache Kafka

As explained in Spring in Action, Sixth Edition

Apache Kafka is a distributed event-streaming platform for publishing, storing, and consuming ordered message streams.

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

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains cluster, topic and partition architecture, then demonstrates Spring-based sending without detailing consumer implementation.
Examples
Uses a Kafka cluster diagram, TacoOrder payloads, the tacocloud.orders.topic topic and localhost:9092 configuration.
What it assumes
Assumes a Kafka cluster is available and teaches the required Spring dependency, broker configuration and template injection.
What you can do after
Apply Kafka through Spring Kafka by configuring brokers and publishing domain objects with KafkaTemplate.
How it connects
Connects message brokers, pub/sub messaging, topics, partitions, Spring Boot, KafkaTemplate and bootstrap-server configuration.

Also explained in

Compare how 6 books explain Apache Kafka →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.