Open ingted opened 1 year ago
According to fault-tolerance
If the strategy is declared inside the supervising actor (as opposed to within a companion object) its decider has access to all internal state of the actor in a thread-safe fashion, including obtaining a reference to the currently failed child (available as the Sender of the failure message).
Workaround:
derive the SupervisorStrategy class and put the error handler inside it...
type SS () =
inherit SupervisorStrategy ()
override u.Decider :IDecider =
//Unchecked.defaultof<IDecider>
SupervisorStrategy.DefaultDecider
override u.Handle(child:IActorRef, exn:Exception) =
//Unchecked.defaultof<Directive>
Directive.Restart
override u.ProcessFailure(
context:IActorContext,
restart:bool,
child:IActorRef,
cause:Exception,
stats:ChildRestartStats,
children:IReadOnlyCollection<ChildRestartStats>) =
printfn "====> %A" child
override u.HandleChildTerminated(
actorContext:IActorContext,
child:IActorRef,
children:IEnumerable<IInternalActorRef>) =
printfn "====> %A" child
override u.ToSurrogate(system:ActorSystem) =
Unchecked.defaultof<ISurrogate>
<| [ SpawnOption.SupervisorStrategy (SS ()) ]
It seems like we can override the method to send the IActorRef back to parent's mailbox... But this is not convinient like the Sender() method... (illustrated in the document)
======================================== Version of Akka.NET? 1.5.0-Alpha Which Akka.NET Modules? Akka or Akka.FSharp
The IActorRef of a child dies or restarts could not be retrieve by mailbox.Sender() in parent
======================================== Reproduce
Example Code File Location
=> See "Notice this sender()"
Expected behavior
The parentMailbox.Sender() should give us the IActorRef of child
Actual behavior
The parentMailbox.Sender() is null
Environment
Windows Server 2019 + .NET 7.0