Question

Hello! Let me first say that we are new in Akka

Issue

We are at a weird situation where we would like to resolve an actor using its path with actorSelection method but the path is being resolved in many occasions inside source code except a particular one. We are in android and we have a Receiver which activates a procedure of actors sending various message. At some time this sequence of messages is finished but we are not terminating the actor system.

Then there is another Receiver that is being called. Inside that receiver the actor system still exists because it has been saved in an object var. Using that actor system we are trying to resolve the actor but, no matter how big the resolve timeout is, the actor cannot be found. We are not sure if actor has died, but code is pretty clean so probably no exceptions have been thrown inside that actor.

Note: the children of an actor are being created as private val ... inside the constructor of the parent actor (not sure if this is the best policy either)

What has been tried so far

First of all because actorSelection returns a future we use Await.result method in order to get the value of this future. Secondly we tried in many different devices with various android apis and tried different versions of akka-library.

Do you have any idea what might be happening or any idea of how I could get to know what is happening exactly and this actor resolve fails?

Edit #1

Trying from inside a BroadcastReceiver was doomed to fail from the beginning because of the lifecycle of a broadcast receiver. So at first Android seemed to be the culprit and we have to create two services. A remote Service (sticky) to be used as the process which stores the ActorSystem. But because binding to a service from inside a BroadcastReceiver is impossible we had to create an IntentService just to intermediate between BroadCastReceiver and IntentService.
Unfortunately, the results are still the same. Everything works fine except the fact that the actor cannot be resolved..

Edit #2

We placed a death watch on the actor that could not be resolved but the result was still the same and we could not receive any Terminated messages. After above failed attempts we tried to create an entire new project trimmed of all the unnecessary code. The result of that effort was that the error was gone! (probably). Therefore we must conclude that some of our original code is to be blamed of the destroyed actor at the first place.

Was it helpful?

Solution

Your question is lacking a lot of useful information (e.g. about which actor at which path looks up which other actor path), but my prime suspect is that you are using Await.result in a parent of the actor to be looked up, which blocks the message on its way to that actor (since every parent needs to forward the message under the hood—this is improved in 2.3.0).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top