2017-05-29 581 views
2


有没有什么方法可以查看发送给kafka的消息内容的给定主题?说一些事情,比如查看这个主题的最后5条消息,如果可能的话。如何查看kafka消息

感谢, 桑迪普

回答

7

您可以使用控制台消费者看到一些主题的消息制片人:

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning 
+0

该命令还需要--zookeeper的详细信息,我添加了像./kafka-console-consumer.sh --zookeeper localhost:2181 --bootstrap-server localhost:9092 --topic测试。但现在我得到 - kafka.common.ConsumerRebalanceFailedException:控制台消费18088_sp-1496052524018-50bb9338不能重新平衡后4重 \t在kafka.consumer.ZookeeperConsumerConnector $ ZKRebalancerListener.syncedRebalance(ZookeeperConsumerConnector.scala:660) \t在 – Sandeep

+0

这是一个单独的问题。看看这个:https://stackoverflow.com/questions/22563401/rebalancing-issue-while-reading-messages-in-kafka –

+1

使用bin/kafka-console-consumer.sh - 新消费者--bootstrap -server localhost:9092 - topic test --from-beginning –

0

使用卡夫卡提供的卡夫卡消费者:

bin/kafka-console-consumer.sh --bootstrap-server BROKERS --topic TOPIC_NAME 

它将显示它会收到它的消息。如果您想从头开始,请添加--from-beginning