1
votes

I have a flow:

A +----> B +----> D
  |        |
  |        +----> E
  |
  +----> C +----> G
           |
           +----> H

I want implement this flow by Akka Stream. Output of Node B and C is a List and input of D,E,G,H is an element in the List. I have tried: - Create a Source from Sink of Flow A ---> B or A --->C

But i am not lucky. Do you have any suggestion?

1
@RamanMishra: Thanks for your suggestion but I want to implement this tructure on Akka Stream.Toan Nguyen
you can have a source two flow and for each flow 2 different sink what is the problem?Raman Mishra
My problem is i cann't create a Source from Sink or Flow of A--->B and A--->CToan Nguyen
Where you need to create Source from sink? B and C will be flow and D, E and G, H will be sink @Toan NguyenRaman Mishra

1 Answers

0
votes

As mentioned in the comments, you need to use the graph functions: https://doc.akka.io/docs/akka/2.5/stream/stream-graphs.html

For instance after A, you need to add a Broadcaster with 2 outputs to pass the messages to both B and C. Same after B and C.

val g = RunnableGraph.fromGraph(GraphDSL.create() { implicit builder: GraphDSL.Builder[NotUsed] =>
  import GraphDSL.Implicits._
  val a = Source(1 to 10)

  val bcast = builder.add(Broadcast[XXX](2))
  val b = builder.add(...)
  val c = builder.add(...)

  a ~> bcast ~> b
  a ~> bcast ~> c
  ...
})