How can I get the name of an Akka actor from within the actor itself?

后端 未结 1 1712
慢半拍i
慢半拍i 2020-12-15 02:14

So, if I have an actor, I can give it a name. But, can I access that name internally? Example:

class Actorz extends Actor with ActorLogging {
   val actorNam         


        
相关标签:
1条回答
  • 2020-12-15 02:51

    From an Actor you can use self to get the ActorRef.

    val actorName = self.path.name
    

    http://doc.akka.io/api/akka/2.2.3/#akka.actor.Actor

    http://doc.akka.io/api/akka/2.2.3/#akka.actor.ActorRef

    http://doc.akka.io/api/akka/2.2.3/#akka.actor.ActorPath

    0 讨论(0)
提交回复
热议问题