Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing one message from a topic in Kafka

I'm new at using Kafka and I have one question. Can I delete only ONE message from a topic if I know the topic, the offset and the partition? And if not is there any alternative?

like image 745
Ander99 Avatar asked Jan 26 '21 13:01

Ander99


1 Answers

It is not possible to remove a single message from a Kafka topic, even though you know its partition and offset.

Keep in mind, that Kafka is not a key/value store but a topic is rather an append-only(!) log that represents a stream of data.

If you are looking for alternatives to remove a single message you may

  1. Have your consumer clients ignore that message

  2. Enable log compaction and send a tompstone message

  3. Write a simple job (KafkaStreams) to consume the data, filter out that one message and produce all messages to a new topic.

like image 158
Michael Heil Avatar answered Sep 18 '22 06:09

Michael Heil