I have the following issue in Akka-Java.
I have one Parent Actor `MainActor.class` and this parent has 5 child routes. Following is the hierarchy:
My App => Main Actor => [Child Route-1,Child-Route-2,..]
Simple Use case is String input is parsed to Integer as output:
MyApp ===ask[string input]===> Main Actor ==route==> Child(parses to Integer) === integer result===> Main Actor ===result==> MyApp
Here is the Main Actor snippet:
class MainActor extends UntypedActor{
Router router;
{
// ...routes are configured here
}
public void onReceive(Object message){
if(message instanceof String){
router.route(message,self()); // route it to child
}else if(message instanceof Integer){
// received from child, 'tell' this result to actual sender/parent i.e, MyApp
sender().tell(message,self());
}else unhandled(message);
}
}
And Child Actor does nothing but String parsing to Integer and takes the result and sends it back to it's sender by `sender().tell(result,getContext().parent())`
Issue
MainActor is sending the Parsed integer result sent by child back to child itself instead of `MyApp`. I also tried replacing `sender()` to `getContext().parent()` in `MainActor` but still it did not work.