Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The proper way to handle problems inside akka actors is not to throw an exception but rather to set supervisor hierarchies </p> <blockquote> <p>"Throwing an exception in concurrent code (let’s assume we are using non-linked actors), will just simply blow up the thread that currently executes the actor.</p> <p>There is no way to find out that things went wrong (apart from inspecting the stack trace). There is nothing you can do about it."</p> </blockquote> <p>see <a href="http://akka.io/docs/akka/1.2/scala/fault-tolerance.html">Fault Tolerance Through Supervisor Hierarchies (1.2)</a></p> <p><strong>* note *</strong> the above is true for old versions of Akka (1.2) In newer versions (e.g. 2.2) you'd still set a supervisor hierarchy but it will trap Exceptions thrown by child processes. e.g.</p> <pre><code>class Child extends Actor { var state = 0 def receive = { case ex: Exception ⇒ throw ex case x: Int ⇒ state = x case "get" ⇒ sender ! state } } </code></pre> <p>and in the supervisor:</p> <pre><code>class Supervisor extends Actor { import akka.actor.OneForOneStrategy import akka.actor.SupervisorStrategy._ import scala.concurrent.duration._ override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) { case _: ArithmeticException ⇒ Resume case _: NullPointerException ⇒ Restart case _: IllegalArgumentException ⇒ Stop case _: Exception ⇒ Escalate } def receive = { case p: Props ⇒ sender ! context.actorOf(p) } } </code></pre> <p>see <a href="http://doc.akka.io/docs/akka/2.2.1/scala/fault-tolerance.html">Fault Tolerance Through Supervisor Hierarchies (2.2)</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload