标签云

微信群

扫码加入我们

WeChat QR Code

There is a configured ActorSystem with actors organized hierarchically as the following:/user/processes/process1/process2/process3To generate this scheme I use the next C# code:// in entry pointIActorRef processesCoordinatorActorRef = ActorSystem.ActorOf(Props.Create<ProcessesCoordinatorActor>(), "processes");// in ProcessesCoordinatorActor.cs:IActorRef processOneActorRef = Context.ActorOf(Props.Create<ProccessActor>(), "process1");IActorRef processTwoActorRef = Context.ActorOf(Props.Create<ProccessActor>(), "process2");IActorRef processThreeActorRef = Context.ActorOf(Props.Create<ProccessActor>(), "process3");My problem is that I want to add a child actor to process1, process2 or process3 from the entry point code (outside of ProcessActor).But now my hands are tied, because IActorRef hides certain actor instance from me.How do I solve it?


wow. Your answer really gave me a point to understand the underlying mechanisms. Unfortunately I didn't catch the idea of tell-to-create-child while reading the corresponding section of github.com/petabridge/akka-bootcamp/tree/master/src/Unit-1/… ;)

2019年04月22日24分14秒

I'm glad it was helpful. Yeah, at lesson 1.4 you're still early in things. But you could have anything you want trigger the creation of a child (message, callback, change in state, etc). Just keep in mind that you want to let actors do their job and isolate knowledge of the hierarchy. Actors way up top in hierarchy probably shouldn't be coupled to knowledge of actor details way down the hierarchy.

1970年01月01日00分03秒