apache-kafka

Apache Kafka list all Topics


Is this any bug with the Apache Kafka 0.9.0.0? I'm using the following command to list the topics and I get nothing even though the server was started with a topic being created!

Joes-MacBook-Pro:kafka_2.11-0.9.0.0 joe$ bin/kafka-topics.sh --list --zookeeper localhost:2181
Joes-MacBook-Pro:kafka_2.11-0.9.0.0 joe$ 

Here is the command that I used to start Apache Kafka:

bin/kafka-server-start.sh config/server.properties & bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test_topic

It is getting harsh for me to just try out the basic stuff around the much hyped Apache Kafka. Here is one another example where I'm pretty much stuck!

Apache Kafka 0.9.0.0 Show all Topics with Partitions


Solution

  • I don't see the zookeeper started in your code. Please start zookeeper and then kafka in the same order.

    bin/zookeeper-server-start.sh config/zookeeper.properties &
    bin/kafka-server-start.sh config/server.properties &
    

    Try to list the topics with the below command.

    bin/kafka-topics.sh --list --zookeeper localhost:2181
    

    You can create the topic with the below command

    bin/kafka-topics.sh --zookeeper localhost:2181 --create --topic test --partitions 1 --replication-factor 1
    

    Once the topic is created, you get a message saying "test" created. Now you can try list command to see your topic listed.

    Note: The replication factor depends upon the number of brokers that you run on a single server.