Search code examples
scalaakkaakka-typed

Cluster Communication | How to get an ActorPath including IP & Port


On the same JVM from the Akka example code can we set

"replyTo" via context.self.

final case class Greet(whom: String, replyTo: ActorRef[Greeted])

But to be able to address an actor on another JVM do I exepct an ActorRef like: Actor[akka://shakto@172.31.19.110:25520/user/supervisor#1566727323]

In order to get such an ActorRef did I tried following without success:

context.self: Actor[akka://shakto/user/supervisor#-893416855] | -> Type: ActorRef -> no IP & Port
context.self.ref: Actor[akka://shakto/user/supervisor#-893416855] | -> Type: ActorRef -> no IP & Port
context.self.path: akka://shakto/user/supervisor | -> Wrong Type: ActorPath 
Cluster(context.system).selfMember.address: akka://shakto@172.31.17.16:25520 | -> Wrong Type: Address 
Cluster(context.system).selfMember: Member(address = akka://shakto@172.31.17.16:25520, status = Up) | -> Wrong Type: Member
Cluster(context.system).selfMember.uniqueAddress: UniqueAddress(akka://shakto@172.31.17.16:25520,7005817905428950198) | -> Wrong Type: UniqueAddress 
DistributedData(context.system).selfUniqueAddress: SelfUniqueAddress(UniqueAddress(akka://shakto@172.31.17.16:25520,7005817905428950198)) | -> Wrong Type: SelfUniqueAddress 

How can I get an full ActorRef including IP & Port from inside the actor which I can then pass as "replyTo" to allow different nodes on different JVM's to use this ActorRef to reply back to me inside the same Cluster?



Solution

  • Have you gone through this page? https://doc.akka.io/docs/akka/current/typed/actor-discovery.html

    Recommended way to communicated with remote actor is using akka cluster and Receptionist.

    Are you using akka-remote?