Kafkacat:如何删除主题或其所有消息?

1Z1*_*Z10 7 apache-kafka kafkacat

我正在寻找一种使用kafkacat. 是否可能或唯一的方法是通过此处列出的脚本?

bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic mytopic
Run Code Online (Sandbox Code Playgroud)

Hic*_*TTA 5

根据man page和github源代码,kafkacat现阶段没有删除主题功能。所以唯一的方法是使用 kafka-topics 脚本。

github源代码

手册页

kafkacat 是 Apache Kafka 0.8 的通用非 JVM 生产者和消费者,可以将其视为 Kafka 的 netcat。

 In producer mode ( -P ), kafkacat reads messages from stdin, delimited with a configurable
 delimeter and produces them to the provided Kafka cluster, topic and partition. In consumer
 mode ( -C ), kafkacat reads messages from a topic and partition and prints them to stdout
 using the configured message delimiter.

 If neither -P or -C are specified kafkacat attempts to figure out the mode automatically
 based on stdin/stdout tty types.

 kafkacat also features a metadata list mode ( -L ), to display the current state of the
 Kafka cluster and its topics and partitions.
Run Code Online (Sandbox Code Playgroud)