We have an actor that takes a long time to initialise, and this is carried out on receiving the Started message. If too long is taken a timeout exception can be thrown during initialisation. We would like to see restart attempts, but until the actor has returned from processing a Started message without exception, we don't want it to process any user messages.
However the actor does receive other user messages in between Started and Restarting messages. I wrote a quick test to demonstrate this:
fun test() {
val prop = fromFunc { msg ->
println("Mssg Received " + msg.toString())
when (msg) {
is Started -> {
Thread.sleep(1000)
throw Exception()
}
else -> {
}
}
}
val pid = spawn(prop)
for (i in 1..2) {
send(pid, "Proto.Actor")
}
Thread.sleep(5000)
}
Gives this:
Mssg Received actor.proto.Started@2f386338
Handling root failure for nonhost/$1
Restarting nonhost/$1 Reason java.lang.Exception
Mssg Received actor.proto.Restarting@379abc62
Mssg Received actor.proto.Started@2f386338
Handling root failure for nonhost/$1
Restarting nonhost/$1 Reason java.lang.Exception
Mssg Received Proto.Actor
Mssg Received actor.proto.Restarting@379abc62
Not sure what the intended behaviour is.
We have an actor that takes a long time to initialise, and this is carried out on receiving the Started message. If too long is taken a timeout exception can be thrown during initialisation. We would like to see restart attempts, but until the actor has returned from processing a Started message without exception, we don't want it to process any user messages.
However the actor does receive other user messages in between Started and Restarting messages. I wrote a quick test to demonstrate this:
Gives this:
Mssg Received actor.proto.Started@2f386338 Handling root failure for nonhost/$1 Restarting nonhost/$1 Reason java.lang.Exception Mssg Received actor.proto.Restarting@379abc62 Mssg Received actor.proto.Started@2f386338 Handling root failure for nonhost/$1 Restarting nonhost/$1 Reason java.lang.Exception Mssg Received Proto.Actor Mssg Received actor.proto.Restarting@379abc62