I have the following test setup which does not seem to work as I expect it
to:
class A extends Actor {
override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 2) {
case _ => println("An actor has been killed"); Restart
}
val b = context.system.actorOf(Props[B], "b")
def receive = {
case _ => context.system.scheduler.schedule(5 seconds, 5 seconds) {
println("Sending request"); b ! true }
}
}
class B extends Actor {
def receive = { case true => println("Executing request"); self ! Kill }
}
I then instantiate 'A' and send it an arbitrary message to get a scheduler
started.
I expect that supervisorStrategy would be catching ActorKilledException but
it does not happen, the output looks like this:
Sending request
Executing request
[ERROR] ... Kill (akka.actor.ActorKilledException)
Sending request
[INFO] ... dead letters encountered
It looks like supervisorStrategy override just does not work, I can even
comment it out and output would stay the same.
Could someone shed some light on why it's happening this way?
================
And while we're at it, here's another situation that puzzles me:
class A extends Actor {
val b = context.system.actorOf(Props[B], "b")
def receive = {
case _ => context.system.scheduler.schedule(5 seconds, 5 seconds) {
println("Sending request"); b ! true }
}
}
class B extends Actor {
override def postRestart(reason: Throwable) = println("Post restart")
def receive = { case true => println("Executing request"); throw new
Exception }
}
Output is:
Sending request
Executing request
Post restart
[ERROR] ... java.lang.Exception
<sequence above repeats indefinitely>
Is actor 'B' being terminated and restarted after an Exception being
thrown? If yes, why is it being restarted given that I don't have any
supervisorStrategy at all in this case?
Is actor 'B' not being terminated and keeps working normally after an
Exception being thrown? If yes, why is postRestart being called each time?
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.