1

I am working on Spring cloud stream kafka streams binder. In my consumer bean method, I want to return KStream with List of String as value -

@Bean
public Function<KStream<Object, String>, KStream<String, List<String>>> method() {
        return input -> {
        /* business logic */
        return KStream<String, List<String>>;
        };
}

Is it possible to have a KStream with collection as its value? If so can anyone explain how to create it ?

shreyas.k
  • 181
  • 1
  • 2
  • 15

1 Answers1

1

For this case, you could call mapValues():

return input -> {
    return input.mapValues(v -> {
        List<String> list = new LinkedList(); // or any other list implementation
        list.add(v); // or any other logic
        return list;
    }
};
Matthias J. Sax
  • 59,682
  • 7
  • 117
  • 137