I am not able to delete the Kafka topics, they are just marked for deletion. What's the issue? Am I missing something? Any suggestions are highly welcomed.
I tried to delete Kafka topic using both ways:
First, I ran the command:
kafka-topics.bat --delete --zookeeper localhost:2181 --topic Cat
Second, I tried programmatically
public void deleteSomeTopic() throws Exception {
consumer = new SimpleConsumer(host, port, soTimeout, bufferSize,"deleteClient");
List<String> listTopics = new ArrayList<>();
TopicMetadataRequest request = new TopicMetadataRequest(listTopics);
//consumer will send request and get corresponding response
TopicMetadataResponse response = consumer.send(request);
//getting topicMetadata list
List<TopicMetadata> topicMetadataList = response.topicsMetadata();
for (TopicMetadata topicMetadata: topicMetadataList) {
System.out.println("Do you want to delete this Topic: "+ topicMetadata.topic());
String ch = scanner.next();
if(ch.equalsIgnoreCase("y"))
AdminUtils.deleteTopic(zkClient, topicMetadata.topic());
Thread.sleep(2000);
}
}
Both executes successfully, but when I listed topics using command
kafka-topics.bat --list -zookeeper localhost:2181
It gives output looks like
Ape - marked for deletion
Cat - marked for deletion
Dog - marked for deletion
Elephant
apple
carrot
ginger - marked for deletion
guava
mango
My server.properties file also has
controlled.shutdown.enable=true
delete.topic.enable=true
I am using kafka_2.10-0.8.2.2 and my pom.xml file has only two dependencies.
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_2.10</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming-kafka_2.10</artifactId>
<version>1.5.1</version>
</dependency>
</dependencies>
I also checked tmp/kafka-logs directory, topics directories are still there. Any workaround I need to do?