【问题标题】:'Graph must be connected' with Flow created from Publisher+Subscriber actor'Graph must be connected' 与从 Publisher+Subscriber 演员创建的 Flow
【发布时间】:2015-04-20 10:25:45
【问题描述】:
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 对创建流。

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

【问题讨论】:

    标签: scala akka actor akka-stream


    【解决方案1】:

    Endre@akka-user:

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

    【讨论】:

      猜你喜欢
      • 2021-02-11
      • 2013-12-26
      • 2022-08-16
      • 1970-01-01
      • 1970-01-01
      • 2015-12-11
      • 1970-01-01
      • 1970-01-01
      • 2022-11-07
      相关资源
      最近更新 更多