Search code examples
scalaakkaactorakka.netactor-model

Actor references in scala


What is the difference between /user/master/"+startID and /user/master/*? Im assuming the * means that the StartRouteProcess message is going to sent to all the actors. Is this correct? Whereas, /user/master/"+startID sends the Task message to the actor with the given startID

      case JoinNode =>
        val startID = Nodelist(Random.nextInt(numJoined))
        context.system.actorSelection("/user/master/" + startID) ! Task("Join", startID, Nodelist(numJoined), -1)

      case BeginRouting =>
        println("Node Join Finished.\n")
        println("Routing started.")
        context.system.actorSelection("/user/master/*") ! StartRouteProcess

Solution

  • According to akka document https://doc.akka.io/docs/akka/2.5/general/addressing.html#querying-the-logical-actor-hierarchy:

    Selections may be formulated using the ActorSystem.actorSelection and ActorContext.actorSelection methods and do support sending messages:

    context.actorSelection("../*") ! msg

    will send msg to all siblings including the current actor.

    So you're correct.