I have a child "consumer" actor that connects to some external data stream, parses its messages and forwards them further inside the application. This "producer" system has a pub-sub architecture, but does not restore subscriptions after reconnect. Currently I store these subscriptions in parent actor and resend them in supervisor, but the problem is that while the child is restarting, they get forwarded to dead letter queue. I could have tried scheduling these to parent after some delay, but this may interfere with subscription order, which is important.
So how do I do deliver these "resubscription" messages to the child while it's restarting?
You can use Restart Hooks (http://doc.akka.io/docs/akka/snapshot/scala/actors.html#Restart_Hooks): preRestart and postRestart api.
on preRestart on the child actor, you need to inform the supervisor that child actor will be restarting and supervisor should suspend it's sending of message.
on postRestart on the child actor, you need to inform the supervisor that child is available and supervisor should resume sending message.