2 First steps with Kafka

 

This chapter covers

  • Introducing the book’s use case
  • Creating a topic with the kafka-topics.sh command
  • Producing messages with the kafka-console -producer.sh command
  • Consuming messages with the kafka-console -consumer.sh command

In this chapter, we’ll delve into the realm of Apache Kafka, gaining our initial insights into its functionality. Our journey begins with the creation of a primary topic, followed by the production of messages directed to this topic. Ultimately, we’ll complete the loop by consuming these messages once more, providing a comprehensive exploration of Kafka’s fundamental operations. We assume that Kafka is already installed. We’ve described the exact installation instructions to create a Kafka cluster with three brokers in appendix B.

2.1 Introducing our use case

Throughout this book, we’ll use a consistent use case to illustrate how Kafka can be effectively used in real-world scenarios. Our chosen use case revolves around an e-commerce platform, as shown in figure 2.1, which serves as a practical example to demonstrate Kafka’s capabilities.

Figure 2.1 The high-level IT architecture for our online shopping platform
A group of colorful rectangular buttons

AI-generated content may be incorrect.

2.2 Producing messages

2.3 Consuming messages

2.4 Consuming and producing messages in parallel

2.5 Graphical user interfaces for Kafka

Summary