Is there functionality built into Kafka Streams that allows for dynamically connecting a single input stream into multiple output streams? KStream.branch
allows branching based on true/false predicates, but this isn't quite what I want. I'd like each incoming log to determine the topic it will be streamed to at runtime, e.g., a log {"date": "2017-01-01"}
will be streamed to the topic topic-2017-01-01
and a log {"date": "2017-01-02"}
will be streamed to the topic topic-2017-01-02
.
I could call forEach
on the stream, then write to a Kafka producer, but that doesn't seem very elegant. Is there a better way to do this within the Streams framework?
KStream.branch
takes multiple predicates (your question indicates you missed this). Sobranch
should allow to do what you want. Maybe you can give a data example? – Matthias J. Saxfoo-{date}
. – kellanburket