'图表必须连接' with Flow从Publisher + Subscriber actor创建

时间:2015-02-19 06:49:52

标签: scala akka actor akka-stream

class ActorPubSub extends ActorSubscriber with ActorPublisher[Int] {
  var events = Seq.empty[Int]

  override protected def requestStrategy: RequestStrategy = OneByOneRequestStrategy
  override def receive: Actor.Receive = {
    case OnNext(e: Int) => events = e +: events
    case Request(cnt) => events.take(cnt.toInt).foreach(onNext)
  }
}

val pubsubRef = system.actorOf(Props(new ActorPubSub))
val pub = ActorPublisher[Int](pubsubRef)
val sub = ActorSubscriber[Int](pubsubRef)
val pubsubFlow = Flow(Sink(sub), Source(pub))

FlowGraph { implicit b =>
  import akka.stream.scaladsl.FlowGraphImplicits._

  Source((1 to 10).toList) ~> pubsubFlow ~> Sink.foreach[Int](e =>
    println("Got a number " + e)
  )
}.run()

根据Flow.apply(Sink, Source) doc:

  

从看似断开的Source和Sink对创建一个Flow。

如果这是真的,为什么图表仍然没有连接?

1 个答案:

答案 0 :(得分:0)

Endre@akka-user

  

这是一个已知问题,将在M4中完全修复。