Reputation: 15345
I have a Supervisor actor that creates a couple of child actors. I have also defined a Supervision strategy that does a OneToOne handling:
override val supervisorStrategy =
OneForOneStrategy() {
case _ =>
logger.info("doing restart")
Restart
}
I would like to know how could I introduce a Timeout to this Restart so that I want for let's say 5 seconds before I restart the children? I do not see any Akka documentation pointing me to any configurable timeouts. Any clues? I do not want to have Thread.sleep(...). It is definitely out of the equation. Any other suggestions?
Upvotes: 0
Views: 931
Reputation: 15345
How about overriding the OneForOneStrategy with the parameters as:
OneForOneStrategy(maxNrOfRetries = 6, withinTimeRange = 1.minute) {
...
...
}
This would ensure that the child actors are restarted only 6 times within a span of 1 minute!
Upvotes: 1
Reputation: 2095
You could use a backoff supervisor that is configured with a min and max backoff being equal to each other.
Note that there are two different kinds of backoff instances. One for onStop
and one for onFailure
. In your case I'd use the onFailure
as this is the supervisor that is configured to handle exception cases.
Upvotes: 0