Scala/Akka problem: In some situations you can’t pass an ActorRef to another actor, so you want to see how to “look up” an Akka Typed actor so you can send a message to it.
Solution
There are at least two ways to find other Akka Typed actors, and both involve using the Akka Receptionist
. The example shown here in the solution shows how to find an actor asynchronously, and the example shown in the Discussion shows how to use the ask
method to find another actor synchronously.
In both examples I’ll use the idea of creating an actor system that works like Amazon Echo devices. The basic idea is that a device like this has ears to listen to you, a mouth to speak to you, and a brain to do all of its work. In these examples the Brain
actor will need to discover the Mouth
actor.