Regarding how groupBy works: yes , maxSubstreams capacity is dynamic, i.e. represents the maximum number of active substreams .
The groupBy stage stores the link to each substream in its internal state, and this is deleted whenever this particular substream terminates.
As for your specific example, I donβt think there is a way to make sure that "the subflow ended in a sink." This is because when using to(Sink.actorRef) after a groupBy all threads will be served by one separate actor.
source share