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?
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?
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
Have your consumer clients ignore that message
Enable log compaction and send a tombstone message
Write a simple job (KafkaStreams) to consume the data, filter out that one message and produce all messages to a new topic.
© 2022 - 2025 — McMap. All rights reserved.
<ConsumerNameHere>Failed
event to the end of the topic. This approach involves shifting the pointer within your consumer. The<ConsumerNameHere>Failed
event could encompass a reference to the original unprocessed event along with a record of the attempted actions. This technique allows the consumer's pointer to progress while retaining the means to retry the problematic event :) – Boyar