I have created 3 levels of actors. Level 1 is the supervisor actor. Supervisor actor will trigger message to Level2 actor and will also take action based on the responses back from the child actors (Level1 and Level2) based on the type of message received. Below is the code of supervisor
if (message instanceof OutBoundDataExportDTO) {
// This to trigger query processor
OutBoundDataExportDTO data = OutBoundDataExportDTO.class.cast(message);
LOGGER.info("Received: " + data.toString());
ActorRef ruleInstExportActor = actorSystem
.actorOf(Props.create(OutboundsQueryActor.class, applicationContext)
.withRouter(new RoundRobinPool(5)));
ruleInstExportActor.tell(data, getSelf());
} else if (message instanceof TaskCompleteMsg) {
TaskCompleteMsg taskCompleteMsg= TaskCompleteMsg.class.cast(message);
taskService.update(taskCompleteMsg);
}
In Level 2 actor, the work is delegated to some Processor. This processor will spawn another actor (Level3 actor). Now, I need to return the response of taskcomplete from Level3 actor back to Level1 actor (supervisor actor) for it to take action based on the response.
Below is the sample code of Level2 actor:
if (message instanceof Level1ActorMessage) {
OutboundQueryProcessor queryProcessor = queryProcessorFactory
.getQueryProcessor(queryName);
response = queryProcessor.executeQuery(templateId, queryData, task);
} else if (message instanceof Level3ActorTaskCompleteMsg) { // This is the response from Level 3 actor, once it has completed
ActorRef parent = getContext().parent(); // This gives me the parent(Level2)
// How do i send it back to its parent
// parent.tell(returnResponse, parent);
}
How can I send the response back from 3rd level actor (child) to grandparent (1st level).