Reputation: 562
I am trying to create an spring boot app(java) that that must be able to delete a message from a kafka topic by giving its offset number and partition. I have been I have been researching the java or spring boot package classes that can do this, but I only have found something like this: Delete Messages from a Topic in Apache Kafka there is a java kafka client that have a method to delete ALL messages BEFORE an offset, but I just one to delete one. It is that possible?
thanks in advance
Upvotes: 0
Views: 3943
Reputation: 17864
If you only have the offset number and partition, and you could just delete the record at that offset, you can't guarantee that all consumers will have an eventually-consistent view, so that's why it's not a standard operation.
The suggestion: write a new record with the same key and a null body can serve as an event to tell all consumers the record is deleted.
The record with the null body will stay in the topic as configured in the delete retention time. This is usually longer than the normal retention time, to make sure consumers have enough time to delete obsolete records. After the delete retention time expires, both the original record and the null record will be removed by log compaction.
Upvotes: 3