This Guide is for the linux based OS & directories in the Kafka setup can be slightly different in the windows setup.
Mainly we deal with the
- for mac -
- for Windows -
Note : Every command must be executed in a separate terminal or console except for creating the topic and ending a server.
Step 1 - Download the source code & extract it
Download Apache kafka from here
Navigate to the downloaded directory &
Step 2 - Starting the Server
You first need to start a ZooKeeper serve, since Kafka uses Zookeeper for the tasks such as Electing a controller, Topic configuration, ACLs & for many more.
As you are now in the
kafka_2.10-0.10.2.0directory execute the following command
- Starting the Kafka Server
Step 3 - Creating a Topic
- Creating a topic located at zookeeper at the
- To ensure that our topic is created, execute following command
Step 4 - Running the Producer
- This is for feed the
mytopicTopic (do it in a separate console)
- You can send messages to the Kafka cluster from the console even except the standard file inputs. just type the message in the console.
Step 5 - Running the Consumer
- This is for listen to the producer at that port (do it in a separate terminal).
- Following command will listens for the topic inputs and outputs
- If you type messages into the producer terminal you should see them appear in the consumer terminal.