Who could point me to the documentation on how to create and kill actors?
From what I read from the docs I could kill any actor by sending akka.actor.PoisonPill
Then I’m trying, just for experiment, to create and kill the akka.io.IO(akka.io.Dns) actor.
What I’m doing:
def getActor() = {
akka.io.IO(akka.io.Dns) ! akka.actor.PoisonPill // create and kill
akka.io.IO(akka.io.Dns) // create new one and return
}
The problem is that after such manipulation I can not lookup any domains via dns resolver. More over akka.http.client does not work as domanis could not be resolved.
akka.actor.RepointableActorRef - Message [akka.io.dns.DnsProtocol$Resolve] to Actor[akka://grpcServer/system/IO-DNS#1709053396] was not delivered. [3] dead letters encountered. If this is not an expected behavior then Actor[akka://grpcServer/system/IO-DNS#1709053396] may have terminated unexpectedly. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
...akka.stream.StreamTcpException: Tcp command [Connect(google.com:80,None,List(),Some(3 seconds),true)] failed because of akka.io.TcpOutgoingConnection$$anon$2: Connect timeout of Some(3 seconds) expired
Why would you stop that IO actor? Do you try to simulate some real scenario by doing that?
Because of OOM issue. Just want to make a number of lookups, kill it and create again.
Actors are not automatically started again if they are stopped like that.
If I’m not mistaken, I was able to kill Echo actor in such way and then create it again in the same way
var echoActor = system.actorOf(
akka.routing.FromConfig.props(Echo.props(system)), "echo"
)
After it was terminated, just create it again
echoActor = system.actorOf(
akka.routing.FromConfig.props(Echo.props(system)), "echo"
)
They can be restarted (via supervision) if an error occurs (exc thrown).
I suggest that you create an issue that include example code of how to reproduce that problem.
IO(Dns) is an Akka extension that is intended to be started once and then it’s running. You can’t stop it from the outside and expect that it will be started again.
As said, extensions are not designed to be stopped. Your attempt of workaround is wrong way of solving this. Better too find the reason for the leak and fix that.