2

In my supervisor actor a message is sent by child actor to indicate its completed. I then stop this actor within the onReceive method :

@Override
public void onReceive(Object msg) {
    if (msg == Messages.SUCCESS) {          
        getContext().stop(getSender());
    } 
}

But this results in following message being printed :

 [INFO] [10/24/2014 12:12:43.102] [Main-akka.actor.default-dispatcher-6] [akka://Main/user/app/$l] Message [akka.dispatch.sysmsg.Terminate] from Actor[akka://Main/user/app/$l#1444168887] to Actor[akka://Main/user/app/$l#1444168887] was not delivered. [6] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.

Is this expected behaviour ? Can these messages be ignored ? Is it required to explicitly stop the actor or will it just stop once its run to completion and become eligible for garbage collection?

Update : it is required to explicitly stop an actor as it will not be stopped by akka framework :

Akka: Cleanup of dynamically created actors necessary when they have finished?

Community
  • 1
  • 1
blue-sky
  • 51,962
  • 152
  • 427
  • 752
  • 1
    It seems like the child actor at path Actor[akka://Main/user/app/$l#1444168887] may be watching itself, so when the supervisor stops it a Terminated message is sent to itself, but because it has been stopped it ends up in the "dead letters". It's difficult to say without seeing the full implementation of both actors. – nickebbitt Oct 24 '14 at 12:54

1 Answers1

0

The actor (akka://Main/users/app/$1#14441688887) being reported has watched itself since it sent itself the Terminated message. While that is fine to do, you should expect this deadletter message as normal in such situations.

You asked:

Is this expected behaviour ?

Yes.

Can these messages be ignored ?

Yes. They can even be prevented by setting akka.log-dead-letters to false in your configuration.

Is it required to explicitly stop the actor or will it just stop once its run to completion and become eligible for garbage collection?

You must stop an actor if you want it to be gone. The normal way to do this is to send it the PoisonPill message which, by default, causes all existing messages in the queue to be processed and then when PoisonPill is reached, the actor is stopped and discarded.

Reid Spencer
  • 2,776
  • 28
  • 37