I am trying to figure out the best way to handle a failure of a future in
an Actor.
My use case is interacting with a database, which as you can expect is
asynch / Future based.
Ideally, I want the actor to restart.
Here is a relevant code snippet:
def running: Receive = {
case "do something" =>
println("\r\n!!!LOADS STUFF DOING SOMETHING!!!")
Future {
Thread.sleep(100); throw new RuntimeException("I CANT DO ANYTHING :(")
} pipeTo self
The problem is that the result here is that an `akka.status.Failure` is
sent to the same actor, so I am forced to add something like this in the
receive block:
case Failure(e) =>
println("\r\n\r\neeeeeeeeeeeeeeeeeeee")
throw e
This looks unsavory. I have to wrap the exception in an
akka.status.Failure and sent it as a normal message to myself.
It feels like I should be able to say "if this future fails, then force a
restart on this actor"
Is there an idiomatic way in Akka to achieve what I am looking for?
--
>>>>>>>>>> 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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.