I mean I did everything as described in docs:
Receive<InitTopicMessage>(m =>
{
parserActor = getParserActor(Context, rootTopicId);
Context.Watch(parserActor);
}
// ...
Receive<Terminated>(t =>
{
if(t == parserActor)
{
// do some stuff
}
}
The problem is that I want to do some stuff only if parser actor was terminated because of error, and not because of ActorSystem termination.
So, is there any way to distinguish the reason of the actor termination?
You will receive a termination message for one of two reasons:
You can distinquish between the two with
Terminated.AddressTerminated
If
Terminated.AddressTerminated == true
then it was a crash or network failure.If you need to to be more precise or handle certain errors then you'll want to use a supervisor strategy on the remote system (which could send the appropriate messages).
Akka is all about fault tolerance and resiliency though so you might be asking the wrong question. If the remote actor goes down, how do you make it recover without the parseActor even caring?