Difficulty: beginner
Estimated Time: 15 minutes
  • Educational Objective
  • What You Need To Know Before You Start
  • Working with Kafka
  • Scenario Contents

IMPORTANT: You need to do the steps in sequence in order for the state of the lesson's learning environment to be consistent. Otherwise, you'll get behaviors that might be confusing.


Educational Objective

The objective of this scenario os to show you how to install a Apache Kafka message broker in the Katacoda interactive learning environment. Also, the scenario will walk you through the steps of setting a topic and then publishing a message into that topic. Finally, you'll create a consumer to retrieve all the messages submitted to the topic.

What You Need To Know Before You Start

In order to get full benefit from the concepts and tasks presented in this scenario you need to have basic understanding of how to enter commands in the Katacoda interactive learning environment. Each step has commands that can be entered into the interactive terminal automatically by clicking on the command.

There is no need to type directly into the terminal window. Clicking on a command will automatically execute it.

Working with Kafka

Apache Kafka is a platform for persistent messaging at web scale. You use Kafka to create topics and publish messages and message streams into the given topic. Then you create consumers against the given topic to receive messages.

Apache Kafka Architecture

Scenario Contents

Step 1 - Setting Up Apache Kafka

Step 2 - Starting Kafka

Step 3 - Creating and Writing to a Topic

Step 4 - Getting Messages Using a Consumer

You've crossed the finish line!

In this scenario you learned:

  • How to set up Kafka
  • How to start up Zookeeper and Kafka
  • How to create a topic and publish messages into the topic we've created
  • How to consume messages from a topic

Setting Up Apache Kafka to Run on KataCoda

Step 1 of 4

Step 1 - Setting Up Apache Kafka

To download and install Kafka, do the following tasks.

Task 1: Download the code from the mirror site:

curl -O http://apache.mirrors.lucidnetworks.net/kafka/2.2.0/kafka_2.12-2.2.0.tgz

Task 2: Unzip the Tar Ball

tar -xzf kafka_2.12-2.2.0.tgz

Task 3: Go into the Kafka directory

cd kafka_2.12-2.2.0

Task 4: Become super user

sudo su

Task 5:: Make a change in bin/kafka-run-class.sh so that Kafka will run in Katacoda. (NOTE: This step is special for running in the Katacoda interactive learning environment.)

sed -i 's#$JAVA_HOME/bin/java#$JAVA_HOME/java#' bin/kafka-run-class.sh