Can't get Supervisor Strategy to work in Akka.NET
<p>I am trying to Supervisor Strategy to work. Here is an illustration of the scenario.</p>

<p><a href="https://i.stack.imgur.com/k9gqh.jpg" rel="nofollow noreferrer">A diagram of a demo app the implements a SupversiorStrategy</a></p>

<p>I have an actor, FloorTrader that upon OnReceive(object message), creates a FederalRegulator Actor:</p>

<pre><code>var regulator = Context.ActorOf(Props.Create(() =&gt; new FederalRegulator("EAST_USA",trade)), "EastFedRegulator");
</code></pre>

<p>Then, upon construction, FederalRegulator creates StateRegulators</p>

<pre><code>public class FederalRegulator : RegulatorBase
{
    public FederalRegulator(string name, Trade trade) : base(name, trade)
    {

        StateRegulate(trade);
    }

    protected override void OnReceive(object message)
    {
        var msg = message as string;

        if(!string.IsNullOrEmpty(msg) &amp;&amp; msg.ToUpper().Equals("STOP"))throw new TradeException("No Trading Today");
    }

    private static void StateRegulate(Trade trade)
    {
       Context.ActorOf(Props.Create(() =&gt; new StateRegulator("NY", trade)), "NYRegulator");
       Context.ActorOf(Props.Create(() =&gt; new StateRegulator("MA", trade)), "MARegulator");
       Context.ActorOf(Props.Create(() =&gt; new StateRegulator("CT", trade)), "CTRegulator");
    }
}
</code></pre>

<p>All the Regulators emit Console.Write() behavior upon construction like so:</p>

<pre><code>public abstract class RegulatorBase : UntypedActor
{
    protected RegulatorBase(string name, Trade trade)
    {
        Name = name;
        Trade = trade;
        Regulate(Name, Trade);
    }

    public string Name { get; private set; }
    public Trade Trade { get; private set; }

    protected void Regulate(string name, Trade trade)
    { // Create a timer
        var myTimer = new System.Timers.Timer();
        // Tell the timer what to do when it elapses
        myTimer.Elapsed += delegate { Console.WriteLine("{0} is regulating the trade for, {1} ", Name,Trade.Ticker); };
        // Set it to go off every 1/2 second,
        myTimer.Interval = 500;
        // And start it        
        myTimer.Enabled = true;

    }

    protected override void OnReceive(object message)
    {
       //put stuff in later
     }
}
</code></pre>

<p>The implementation of SupervisionStrategy() in the FloorTrader actor is:</p>

<pre><code>protected override SupervisorStrategy SupervisorStrategy()
{
    return new OneForOneStrategy(
        0, // maxNumberOfRetries
        TimeSpan.FromSeconds(1), // duration
        x =&gt;
          {
            if (x is TradeException)
              {
                  Console.WriteLine("---BLOW UP-----");
                  return Directive.Stop;
              }
            return Directive.Restart;
            });
}
</code></pre>

<p>When the FederalRegulator receives a STOP message, it fires a custom exception, TradeException, as is shown above in the FederalRegulator code.</p>

<p>The output before a fire the STOP message is the expected:</p>

<pre><code>EAST_USA is regulating the trade for, HP
MA is regulating the trade for, HP
NY is regulating the trade for, HP
CT is regulating the trade for, HP
EAST_USA is regulating the trade for, HP
MA is regulating the trade for, HP
CT is regulating the trade for, HP
NY is regulating the trade for, HP
EAST_USA is regulating the trade for, HP
CT is regulating the trade for, HP
NY is regulating the trade for, HP
MA is regulating the trade for, HP
EAST_USA is regulating the trade for, HP
MA is regulating the trade for, HP
CT is regulating the trade for, HP
NY is regulating the trade for, HP
EAST_USA is regulating the trade for, HP
MA is regulating the trade for, HP
CT is regulating the trade for, HP
NY is regulating the trade for, HP
EAST_USA is regulating the trade for, HP
MA is regulating the trade for, HP
CT is regulating the trade for, HP
NY is regulating the trade for, HP
EAST_USA is regulating the trade for, HP
</code></pre>

<p>My thinking is that because I am using a OneForOneStrategy, once I fire the STOP message, the FederalRegulator actor, the one emitting , <code>EAST_USA is regulating the trade for, HP</code> should stop, but its children, the StateRegulators should keep on going.</p>

<p>HOWEVER, when I fire the STOP message using: <code>regulator.Tell("STOP");</code>
TradeException gets thrown, but the FederalRegulator keeps emitting. In addition, I am getting Dead Letter messages:</p>

<pre><code>EAST_USA is regulating the trade for, HP
CT is regulating the trade for, HP
NY is regulating the trade for, HP
MA is regulating the trade for, HP
---BLOW UP-----
[ERROR][2/27/2016 12:18:49 AM][Thread 0011][akka://TradingSystem/user/MyBroker/SellFloorTrader/EastFedRegulator] No Trading Today
Cause: AkkaNetDemo.Exceptions.TradeException: No Trading Today
   at AkkaNetDemo.Regulators.FederalRegulator.OnReceive(Object message) in c:\Users\Bob\Documents\GitHub\AkkaNetDemo\AkkaNetDemo\Regulators\FederalRegulator.cs:line 20
   at Akka.Actor.UntypedActor.Receive(Object message)
   at Akka.Actor.ActorBase.AroundReceive(Receive receive, Object message)
   at Akka.Actor.ActorCell.ReceiveMessage(Object message)
   at Akka.Actor.ActorCell.Invoke(Envelope envelope)
[INFO][2/27/2016 12:18:49 AM][Thread 0013][akka://TradingSystem/user/MyBroker/SellFloorTrader/EastFedRegulator] Message DeathWatchNotification from akka://TradingSystem/user/MyBroker/SellFloorTrader/EastFedRegulator to akka://TradingSystem/user/MyBroker/SellFloorTrader/EastFedRegulator was not delivered. 1 dead letters encountered.
[INFO][2/27/2016 12:18:49 AM][Thread 0012][akka://TradingSystem/user/MyBroker/SellFloorTrader/EastFedRegulator] Message DeathWatchNotification from akka://TradingSystem/user/MyBroker/SellFloorTrader/EastFedRegulator to akka://TradingSystem/user/MyBroker/SellFloorTrader/EastFedRegulator was not delivered. 2 dead letters encountered.
[INFO][2/27/2016 12:18:49 AM][Thread 0011][akka://TradingSystem/user/MyBroker/SellFloorTrader/EastFedRegulator] Message DeathWatchNotification from akka://TradingSystem/user/MyBroker/SellFloorTrader/EastFedRegulator to akka://TradingSystem/user/MyBroker/SellFloorTrader/EastFedRegulator was not delivered. 3 dead letters encountered.
EAST_USA is regulating the trade for, HP
CT is regulating the trade for, HP
MA is regulating the trade for, HP
NY is regulating the trade for, HP
Enter Trade: EAST_USA is regulating the trade for, HP
CT is regulating the trade for, HP
MA is regulating the trade for, HP
NY is regulating the trade for, HP
EAST_USA is regulating the trade for, HP
CT is regulating the trade for, HP
NY is regulating the trade for, HP
MA is regulating the trade for, HP
EAST_USA is regulating the trade for, HP
CT is regulating the trade for, HP
NY is regulating the trade for, HP
MA is regulating the trade for, HP
EAST_USA is regulating the trade for, HP
CT is regulating the trade for, HP
NY is regulating the trade for, HP
MA is regulating the trade for, HP
EAST_USA is regulating the trade for, HP
</code></pre>

<p>Can anybody help me figure out the error of my ways. From what I have been reading, when one uses a <code>OneForOneStrategy()</code>, the parent should stop and the children will continue.</p>