Reputation: 654
I have seen similar questions related to this, But didn't find the correct answer. I just want to delete messages from Kafka topic instead of changing the retention timeout. I have installed kafka_2.11-0.8.2.1 and running it on windows using bat files. I want to know if I can delete all the messages published in a topic without deleting the entire topic.
Upvotes: 1
Views: 3686
Reputation:
Kafka is different from other messaging in this aspect. Kafka is not a consume-delete semantic framework. You can't delete but can move ahead your reading offsets and consumer will get the next messages.
It is consumer's responsibility if it wants to read any message from broker again or now. Regardless of consumer consumed message or not, kafka will store the message for configured time and then delete.
One may be able to write some script to achieve this but I strongly advise against it.
Upvotes: 0
Reputation: 10065
You cannot do that with 0.8.2. Starting from 0.11.0 you get a kafka-delete-records.sh tool for doing that. Starting from 1.1 you even have a Java AdminClient API with deleteRecords methods for doing this programmtically.
Upvotes: 1