gpt4 book ai didi

scala - 值(value) !不是 akka.routing.Router 的成员

转载 作者:行者123 更新时间:2023-12-02 09:31:28 25 4
gpt4 key购买 nike

我一直在努力让一些 Akka 示例启动并运行,但遇到了一个给我带来很大麻烦的问题。让我感到奇怪的是,直接从文档中得出的代码不起作用。

import akka.actor._
import akka.routing.{ ActorRefRoutee, RoundRobinRoutingLogic, Router, Broadcast }


object TransformationManager {
case class ProcessFile(fileIt:Iterator[String])
case class ProcessLines(lines:List[List[String]], last:Boolean = false)
case class LinesProcessed(lines:List[List[String]], last:Boolean = false)

case object WorkAvailable
case object WorkRequest
}

class TransformationManager extends Actor {
import TransformationManager._

val workChunkSize = 10
val workersCount = 10

def receive = {
case ProcessFile(fileIt) =>
var router = {
val routees = Vector.fill(workersCount) {
val r = context.actorOf(Props[SampleWorker])
context watch r
ActorRefRoutee(r)
}
Router(RoundRobinRoutingLogic(), routees)
}
router ! Broadcast(WorkAvailable) //error here !!!!!!!!!
}
}

最后一行代码,

router ! Broadcast(WorkAvailable)

我收到错误,

value ! is not a member of akka.routing.Router

我不知道为什么这不起作用。

最佳答案

引用文档路由器可以是一个参与者,然后 ! 应该可以工作,但它不一定是这样,取决于你如何创建它。在这里阅读更多内容: http://doc.akka.io/docs/akka/snapshot/scala/routing.html#A_Router_Actor

关于scala - 值(value) !不是 akka.routing.Router 的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32748412/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com