Hi,
In my application, I'd like to broadcast a time unit every 2 sec to all
actors instances of Worker. The time unit is sent by the master to all the
worker
I am trying to send a broadcast message to set of workers by the master
actor, but it doesn't work with me. I attach my test code here. There is a
compile error in the line
router ! Broadcast("any message")
"Error: value is not a member of akka.routing.Router" Could anyone tell me
what is the problem here.
import akka.actor._
import akka.routing.{ ActorRefRoutee, RoundRobinRoutingLogic, Router }
import akka.routing.Broadcast
import akka.routing.Router
import akka.routing.RouterActor
object Messages{
object Work
object Terminated
}
object MainRouterDriver extends App {
import Messages._
// an actor needs an ActorSystem
val system = ActorSystem("HelloSystem")
// create and start the actor
val routingMaster = system.actorOf(Props[Master], name = "helloactor")
// send the actor two messages
routingMaster ! Work
}
class Worker extends Actor{
def receive = {
case _ =>
println("Hi I am a Worker")
}
}
class Master extends Actor {
var router = {
val routees = Vector.fill(5) {
val r = context.actorOf(Props[Worker])
context watch r
ActorRefRoutee(r)
}
akka.routing.Router(RoundRobinRoutingLogic(), routees)
}
def receive = {
case Work =>
router ! Broadcast("any message")
}
}
--
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.