Delete entire topic from State Store

爱⌒轻易说出口 提交于 2019-12-25 00:05:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!