1

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?

Toan Nguyen
  • 110
  • 1
  • 8

1 Answers1

0

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
  ...
})
0x26res
  • 11,925
  • 11
  • 54
  • 108