Hi Héctor, You should take a look at MergeHub [1]. You could then wrap each incoming message into a Source.single and send it through the hub into the intended consumer.
Alternatively you could create a Source.actorPublisher, and pass the ActorRef produced by materialization of your flow to the route. You'd have to implement an ActorPubslisher then and it's not trivial, so unless you have to process thousands of such messages per second, MergeHub would be preferable. Cheers, Rafał [1] http://doc.akka.io/docs/akka/2.4/scala/stream/stream-dynamic.html#Dynamic_fan-in_and_fan-out_with_MergeHub_and_BroadcastHub W dniu czwartek, 27 października 2016 00:11:44 UTC+2 użytkownik Héctor Veiga napisał: > > Hi, > > I am trying to figure out if it is possible to use an HTTP Akka Source as > a Source in a Graph DSL. > My main problem is how to reference the next element in the graph in the > akka route. > > When you are not using it as a Source you can do the following: > > private def route(someActor: ActorRef) = > post { > entity(as[String]) { message => > someActor ! message > complete("") > } > } > > Then you call Http().bind(...) but you need to pass an ActorRef to the > route(). > > However, I would like to do something like: > > private def route() = > post { > entity(as[String]) { message => > *nextElement* ! message > complete("") > } > } > > val g = RunnableGraph.fromGraph(GraphDSL.create() { implicit builder: > GraphDSL.Builder[NotUsed] => > import GraphDSL.Implicits._ > val source = Http.bind(...) > val out = Sink.ignore > > val f1 = Flow[Int].map(_ + "something") > > in ~> f1 ~> out > ClosedShape > }) > > "nextElement" is what I am looking for. A way of pushing to the next > element in the graph. > > Thanks, > > Héctor. > > -- >>>>>>>>>> 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
