KStream send record to multiple streams (not Branch)

前端 未结 2 1384
情话喂你
情话喂你 2021-01-22 22:40

Is there a way to make branch-like operation but to place record in each output stream which predicate evaluates to true? Brach puts record to first match (documentation: A reco

2条回答
  •  离开以前
    2021-01-22 23:24

    I think you can use something like this:

    KStream inputStream = builder.stream("input");
    List> predicates = new ArrayList<>(); // <-- list of predicates
    List> kStreams = predicates.stream()
            .map(inputStream::branch)
            .map(Arrays::asList)
            .map(listOfOneElementKStreams -> listOfOneElementKStreams.get(0)).collect(Collectors.toList());
    

提交回复
热议问题