问题
I'm trying to delete an entire topic and a single record in a topic from the stateStore (Not at the same time) based on the key provided. So if key that I passed in equals a key in the stream, turn that key's value to null.
StreamsBuilder streamsBuilder = new StreamsBuilder();
KStream kStream =
streamsBuilder.stream(
inputTopic,
Consumed.with(Serdes.String(), /* key serde */
Serdes.ByteArray() /* value serde */))
.map((key1, value) -> {
.map((key1, value) -> {
if(key1.equals(key)){
return new KeyValue<String, byte[]>(key, null);
}
return new KeyValue<>(key1, value);
});
});
This is what I have so far, but I'm not sure map is the right way to go, I had groupByKey() previously. My direction was to put a message on the topic key:null. I'm not sure if that will only remove that specific record from the topic or destroy the topic itself. I only want to null the keys that correspond to the key I passed in. Thoughts?
来源:https://stackoverflow.com/questions/59204839/delete-entire-topic-from-state-store