I studied the Accu Graceful Stop for actors and created a small test app for testing.
The app shows that "Graceful Stop" is mentioned in http://doc.akka.io/docs/akka/snapshot/scala/actors.html#Graceful_Stop does not always guarantee that you can reuse the actor's gracefully stopped name.
The following exception appears from time to time:
Exception in thread "main" akka.actor.InvalidActorNameException: actor name [DummyActor] is not unique!
Why? How can I fix the application so that InvalidActorNameExceptions do not appear every time?
Here is the code:
main class ...
import akka.actor._ import akka.pattern.gracefulStop import DummyActor.Stop import DummyActor import scala.concurrent.duration._ import scala.concurrent.{Await, Future} object AkkaTest { def main(args: Array[String]) { val actorsystem = ActorSystem("testSystem") 1 to 5 foreach { _ =>
and the actor ...
import akka.actor.Actor import DummyActor.Stop object DummyActor { case object Stop } class DummyActor extends Actor { override def receive: Receive = { case Stop => context stop self } }
I have Scala 2.11.7 with both Java 8 and Akka 2.4.0.
source share