Search code examples
scalapathakkaactor

How get actor physical path from akka actor?


Here is the actor code:

import akka.actor.Actor

class OneActor extends Actor {
    def receive = {
        //what I should call here to get ?
        case _  => println(physicalPaht)
    }
}

I can use some "build-in" variables:

  • context - but it do not contains any usefull method about path
  • actorPath - contains only local path

Any ideas?

Updated

Also thre is a self.path.address but it returns only path to root actor.


Solution

  • akka.serialization.Serialization.serializedActorPath(self) should be used.

    import akka.actor.Actor
    
    class OneActor extends Actor {
        def receive = {
            case _  => println(akka.serialization.Serialization.serializedActorPath(self))
        }
    }