I want to know the difference of reusing streams using .through() over stream reference from .toStream() + .to()
Using .through()
KStream<String, String> subStream = mainStream
.groupByKey(..)
.aggregate(..)
.toStream(..);
.through("aggregate-topic", ..);
// Then use the (new) stream from .through() to create another topic
vs Using .toStream() + .to()
KStream<String, String> subStream = mainStream
.groupByKey(..)
.aggregate(..)
.toStream(..);
subStream.to("aggregate-topic", ..);
//reuse the existing subStream from toStream() to create another topic
I have implemented a feature that uses the latter because that's what made sense before I learned the through() method.
What I'm curious now is the internal stuff that happens for both options; are there any benefits/disadvantages for choosing one option over the other?