Manas
Manas

Reputation: 519

What happens to the future that has been spawned off by my actor that restarts

I have an Akka Actor(ARCWorker) that has a one-to-one supervisor strategy to restart upon any exception.

def idle: Receive = {
    case UnitOfWork(data, service) =>
      {
        data.HelperRef = Some(ftpHelper)
        val futurework = service(data)
        futurework pipeTo self
        context.become(busy)
      }
}

This futurework take some time to complete. My ARCWorker watches the master and if the master dies it restarts itself and goes to un-initialized state. At that point I don't want my ARCWorker to receive the result of the futurework.

So my questions:
1) What happens to my futurework if I throw an exception and let supervisor take care of restarting ARCWorker? 2) What happens if I do a context.stop of the ARCWorker? ( I think supervisor won't deal with but want to confirm) 3) Is there a way to cancel my futurework in case no other option is available to me?

Thanks Manas

Upvotes: 4

Views: 148

Answers (1)

Randall Schulz
Randall Schulz

Reputation: 26486

A Future created by an actor is unaffected by the subsequent restart or death of the actor whose receive function created it.

Upvotes: 1

Related Questions