Reputation: 261
I've been working on getting some Akka examples up and running and have run into an issue that is giving me quite a bit of trouble. What's so strange to me is that there is code coming straight out of the documentation that isn't working.
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 !!!!!!!!!
}
}
On the last line of code,
router ! Broadcast(WorkAvailable)
I get the error,
value ! is not a member of akka.routing.Router
I'm at a loss for why this isn't working.
Upvotes: 2
Views: 691
Reputation: 8663
Referring to docs router could be an actor and then !
should work, but it doesn't have to be, depends how you create it. Read more here:
http://doc.akka.io/docs/akka/snapshot/scala/routing.html#A_Router_Actor
Upvotes: 3
Reputation: 7247
There's no !
on Router
. You use router.route
to send a message.
router.route(msg, sender())
Upvotes: 2