Hi all, I've been looking at MergeHub and BroadcastHub for Akka Stream and I am a bit confused.
In the beginning of the documentation the following is mentioned: It is important to remember that even after constructing the RunnableGraph > by connecting all the source, sink and different operators, no data will > flow through it until it is materialized. Materialization is the process of > allocating all resources needed to run the computation described by a Graph > (in Akka Streams this will often involve starting up Actors). > ... > After running (materializing) the RunnableGraph[T] we get back the > materialized value of type T. > This makes perfect sense. But I'm having issues uniting this with the code sample from the MergeHub documentation. // A simple producer that publishes a new "message" every second val producer : Source[String, Cancellable]= Source.tick(1.second, 1.second, "New message") // Attach a BroadcastHub Sink to the producer. This will materialize to a // corresponding Source. // (We need to use toMat and Keep.right since by default the materialized // value to the left is used) val runnableGraph: RunnableGraph[Source[String, NotUsed]] = producer.toMat(BroadcastHub.sink(bufferSize = 256))(Keep.right) // By running/materializing the producer, we get back a Source, which // gives us access to the elements published by the producer. val fromProducer: Source[String, NotUsed] = runnableGraph.run() // Print out messages from the producer in two independent consumers fromProducer.runForeach(msg => println("consumer1: " + msg)) fromProducer.runForeach(msg => println("consumer2: " + msg)) In the above snippet a Source is created, and that is used as the Source for a runnableGraph (meaning it has a source and a sink). Conceptually I understand that the BroadcastHub is indeed a sink. But what I do not understand is that when you run/materialize that RunnableGraph, you get back a Source. The way I see it, running a graph should return a future of the types of values flowing through that graph. In this case Strings. Can somebody shed some light on this, please? Thanks, Christophe -- ***************************************************************************************************** ** New discussion forum: https://discuss.akka.io/ replacing akka-user google-group soon. ** This group will soon be put into read-only mode, and replaced by discuss.akka.io ** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced ***************************************************************************************************** >>>>>>>>>> >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/akka-user/facaf52d-b49d-4980-93e0-30f9ead85fed%40googlegroups.com.