What is the difference between hadoop fs, hadoop dfs and hdfs dfs commands?
December 25, 2020How to delete a Kakfa topic?
December 30, 2020The easiest way to purge or delete messages in a Kafka topic is by setting the retention.ms to a low value. retention.ms configuration controls how long messages should be kept in a topic. Once the age of the message in a topic hits the retention time the message will be removed from the topic.
Note the below steps delete or purge messages in your topic. Use precaution when executing the below.
Checking the current retention value for a topic
Check and record the current retention value of the topic. You need to know the current retention value for rollback after you purge the messages.
kafka-configs --zookeeper <zkhost>:2181 --describe --entity-type topics --entity-name <topic name>
Update retention value on a topic
-add-config retention.ms=1000 updates the retention time or TTL (Time To Live) of messages in the topic. It is in milliseconds and hence the below command will update the topic with the retention time less than a minute.
After the update, the messages which are older than the retention time in the topic will be deleted or purged.
kafka-configs.sh --zookeeper <zkhost>:2181 --entity-type topics --alter --entity-name <topic name> --add-config retention.ms=10000
3 Comments
[…] Click here if you want to purge the messages in the topic before deleting this topic. […]
[…] Read more.. […]
[…] https://www.bigdatainrealworld.com/how-to-purge-or-delete-messages-in-a-kafka-topic/ […]