I have an actor that is created at application startup as a child of another actor and receives a message once per day from the parent to perform operation to fetch some files from some SFTP server.
Now, there might be some minor temporary connection exceptions that cause the operation to fail. In this case, a retry is needed.
But there might be a case in which exception is thrown and is not going to be resolved on a retry (ex: file not found, some configuration is improper etc.)
So, in this case what could be an appropriate retry mechanism and supervision strategy considering that the actor will receive messages after a long interval (once a day).
In this case, the message sent to the actor is not bad input - it is just a trigger. Example:
case object FileFetch
If I have a supervision strategy in the parent like this, it is going to restart the failing child on every minor/major exception without retries.
override val supervisorStrategy =
OneForOneStrategy(maxNrOfRetries = -1, withinTimeRange = Duration.inf) {
case _: Exception => Restart
}
What I want to have is something like this:
override val supervisorStrategy =
OneForOneStrategy(maxNrOfRetries = -1, withinTimeRange = Duration.inf) {
case _: MinorException => Retry same message 2, 3 times and then Restart
case _: Exception => Restart
}