Hi,
I'm new to akka and I have some questions regarding supervisors and
fault tolerance.
I'm trying to test out some retry functionality on a pool of workers
using a round robin router, but I'm not sure how I can achieve the
behaviour I want.
The behaviour I want is the following:
1) If a worker request fails, resend the message to the failed worker
until maxNrOfRetries is reached as specified by supervisorStrategy
2) If the worker has failed "maxNrOfRetries" times (worker terminated)
I want to stop all the other routees in the router as I would need the
results from all the workers to compute the final answer.
I have attached some test code below where I have a supervisor that
creates a router with some worker threads. I override the router
supervisor strategy and set the maxNrOfRetries to 2. I handle the
retry in the preRestart hook of the worker. Is this the right way to
handle retries? Seems to work at least.
The part that I'm missing is a way to terminate all the routees when 1
(or more) worker has been terminated. I have a timeout that waits for
the futures to complete, but in cases of failure I want to throw an
exception without waiting for the timeout if just one of the workers
has terminated. I know I can can use: sender !
akka.actor.Status.Failure(ex) to complete the future with an
exception. But I only really want to do this after I have retried for
the last time.
I guess I could implement this using a retry counter inside the Worker
actor and just send: sender ! akka.actor.Status.Failure(ex) when max
retries has been reached. This would throw an exception in the
supervisor thread would it not?
Whats the best way of implementing this behaviour in Akka?
Rune
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
Patrik Nordwall
Typesafe - The software stack for applications that scale
Twitter: @patriknw
Nice example Patrik.
Why not add to the docs?