I have a scenario where I have to restart a child Actor from within a parent actor. The restart should happen with the following rules:
1. The start should happen only after stop has been completed 2. Both the stop and start should happen asynchronously I now have the following scenario: In my parent Actor, I have a Monix Observable which is pushing events as below: class ParentActor extends Actor { ... override def preStart(): Unit = { super.preStart() // Observable to stream events regarding PowerPlant's val powerPlantEventObservable = // For every config.database.refreshInterval in seconds Observable.interval(config.database.refreshInterval) // We ask the actor for the latest messages .map(_ => (dbServiceActor ? DBServiceActor.PowerPlantEvents).mapTo[PowerPlantEventsSeq]) .concatMap(Observable.fromFuture(_)) .concatMap(Observable.fromIterable(_)) // Subscriber that pipes the messages to this Actor cancelable := powerPlantEventObservable.subscribe { update => (self ? update).map(_ => Continue) } } } So what happens above is that, I'm asking another Actor called DBServiceActor for a List of events and when these events are available, I'm piping it to the ParentActor (self ? update). The receive method of the ParentActor looks like this and this is where I want to restart my child actor . asynchronously: override def receive: Receive = { case PowerPlantUpdateEvent(id, powerPlantCfg) => log.info(s"Re-starting PowerPlant actor with id = $id and type ${powerPlantCfg.powerPlantType}") // I want to stop the actor first by finding it from the actor system // If it exists, do a context.stop on the Actor instance // Once it is stopped, I want to start it again by creating a new instance of this Actor // Once this new Actor instance is created, I want to signal my Monix Observer to send me the next event } Any suggestions? -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.