public AkkaHubProxy(ActorMaterializer mat) { this.mat = mat; // Obtain a Sink and Source which will publish and receive from the "bus" respectively. Pair<Sink<Object, NotUsed>, Source<Object, NotUsed>> sinkAndSource = MergeHub.of(Object.class, 16) .toMat(BroadcastHub.of(Object.class, 256), Keep.both()) .run(mat); Sink<Object, NotUsed> sink = sinkAndSource.first(); source = sinkAndSource.second().takeWhile((Predicate<Object>) o -> o != Done.getInstance()); //source.runWith(Sink.ignore(), mat); busFlow = Flow.fromSinkAndSource(sink, source) .joinMat(KillSwitches.singleBidi(), Keep.right()); }