IKH

Using CLI to Start Producers and Consumers

After creating the topic, the producer and consumer need to be started. The consumer will start listening to the topic and wait for the messages to be written into the topic. The producer will be responsible for sending the messages to the topic.

Please note that you need to have the Zookeeper and the Kafka server running before starting a producer or consumer.

In the next video, you will learn how to use Kafka CLI to start the consumer that will start listening to the topic that was created in the previous segment.

In the previous video, you learnt how to start a consumer that will listen to the topic that was created.

The command used to start the consumer is as follows:

Note:

Ensure that you run this command from inside the Kafka folder that is present in the downloads directory.

Now that you started the consumer, you need to start the producer that will push the messages to the topic named ‘test’, and our consumer will listen to it.

To start the producer, please open a new terminal window and log in to the EC2 instance. In the next video, you will learn how to start pushing messages to a Kafka topic.

In the previous video, we started a producer using the following command:

Note:

Ensure that you run this command from inside the Kafka folder that is present in the downloads directory.

Once this was complete, we pushed some messages to the topic named ‘test’. We returned to the terminal window in which we had started our consumer and saw that the consumer was able to read the messages that were being pushed by the producer.

To navigate out of the consumer shell, press Ctrl+C.

Once you are out of the consumer shell, in the next video, you will learn how to delete any topic along with the command for the same.

In the previous video, you learnt about the command used to delete a Kafka topic. The command for the same is as follows:

Note:

Ensure that you run this command from inside the Kafka folder that is present in the downloads directory.

The name of the topic that you provide needs to be a valid name, i.e., a topic with that name should be present.

In the upcoming video, Vishwa will summarise all the steps that we took so far.

In the previous video, Vishwa summed up the steps that we followed. We first started the Zookeeper and the Kafka servers. Next, we created a topic named ‘test’.

Then, we started a consumer that started listening to the messages that were being pushed to this Kafka. Initially, since there was no message written inside that topic, the consumer was not consuming any messages. As we started to push the messages using a producer, we saw that the consumer was able to consume those messages. You also learnt how to delete a topic.

Report an error