Class KafkaStreamBrancher<K,V>
- java.lang.Object
-
- org.springframework.kafka.support.KafkaStreamBrancher<K,V>
-
- Type Parameters:
K- Type of keysV- Type of values
public final class KafkaStreamBrancher<K,V> extends java.lang.ObjectProvides a method-chaining way to buildbranchesin Kafka Streams processor topology.Example of usage:
new KafkaStreamBrancher<String, String>() .branch((key, value) -> value.contains("A"), ks->ks.to("A")) .branch((key, value) -> value.contains("B"), ks->ks.to("B")) //default branch should not necessarily be defined in the end .defaultBranch(ks->ks.to("C")) .onTopOf(builder.stream("source"))- Since:
- 2.2.4
- Author:
- Ivan Ponomarev, Artem Bilan
-
-
Constructor Summary
Constructors Constructor Description KafkaStreamBrancher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KafkaStreamBrancher<K,V>branch(org.apache.kafka.streams.kstream.Predicate<? super K,? super V> predicate, java.util.function.Consumer<? super org.apache.kafka.streams.kstream.KStream<K,V>> consumer)Defines a new branch.KafkaStreamBrancher<K,V>defaultBranch(java.util.function.Consumer<? super org.apache.kafka.streams.kstream.KStream<K,V>> consumer)Defines a default branch.org.apache.kafka.streams.kstream.KStream<K,V>onTopOf(org.apache.kafka.streams.kstream.KStream<K,V> stream)Terminating method that builds branches on top of givenKStream.
-
-
-
Method Detail
-
branch
public KafkaStreamBrancher<K,V> branch(org.apache.kafka.streams.kstream.Predicate<? super K,? super V> predicate, java.util.function.Consumer<? super org.apache.kafka.streams.kstream.KStream<K,V>> consumer)
Defines a new branch.- Parameters:
predicate-Predicateinstanceconsumer- The consumer of this branch'sKStream- Returns:
this
-
defaultBranch
public KafkaStreamBrancher<K,V> defaultBranch(java.util.function.Consumer<? super org.apache.kafka.streams.kstream.KStream<K,V>> consumer)
Defines a default branch. All the messages that were not dispatched to other branches will be directed to this stream. This method should not necessarily be called in the end of chain.- Parameters:
consumer- The consumer of this branch'sKStream- Returns:
this
-
-