I\'m learning Akka and I\'m trying to figure out how to get actors talking to each other (let\'s call them A
and B
). It\'s not a request / response sce
In my humble opinion you have three strategies, which I list from the closer to your problem (but also to me the worst pattern, I am sorry)
Strategy 1: you create actor A and actor B, passing actorRef A to the constructor of actor B. Your ping-pong will start from actor B sending a message to actor A, and actor A can simply reply using the sender reference. (or the other way around)
Strategy 2: you create a layer in your application which takes care of the naming: it assigns the name at creation of the actor, as well as when querying. This centralizes the problem in a single point.
Strategy 3: You wonder if two siblings actors playing ping-pong are not replacing a better, more modular actor hierarchy where basically each actor communicate only with his parent and his children and has no knowledge about his siblings.