0

Want to restart actor after exception with previous state by supervisor strategies.

For example

Actor supervisor saves some parameter from his children. Also supervisor has next strategy:

     override val supervisorStrategy =
            OneForOneStrategy(maxNrOfRetries = 10) {

              case e : ActorKilledException     => {
                log.info("Restart === " + e)
                Restart

//TODO HOW TO SEND SOME PARAMETER TO THE ACTOR, AFTER RESTART ? 
              }
              case _: Exception                => Escalate
            }

How can I set previous parameter of actor "before crash" by supervisorStrategy. ?

I could not find it by http://doc.akka.io/docs/akka/2.4.2/general/supervision.html

Any links, examples ?

Thanks!

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343

1 Answers1

3

Whenever you think "keep previous state" you want the Resume strategy. Restart specifically means "give me a fresh Actor, without the (possibly) corrupted state".

It's documented in the page you're linking: "Resume the subordinate, keeping its accumulated internal state".

halfer
  • 19,824
  • 17
  • 99
  • 186
Konrad 'ktoso' Malawski
  • 13,102
  • 3
  • 47
  • 52