我正在尝试从父级Actor向子Actor发送消息,但是该消息直到父Actor完成onReceive块后才到达。
是否有一种方法可以向子Actor发送消息并在父Actor上等待结果。
如上所述,在onChildOrder方法中,对象result = Await.result(future, timeout.duration())总是超时,并且当父级的onReceive方法完成时,消息ChildOrder到达子级的onReceive方法。
似乎子级在父级完成之前无法处理任何消息。
是否有办法发送消息给子级并等待结果?
Parent:
onReveive(message) {
if(message instanceof ChildOrder) {
onChildOrder(message);
}
}
onChildOrder(message) {
Future<Object> future = Patterns.ask(childActorRef, order, timeout);
Object result = Await.result(future, timeout.duration()); /* this always times out */
}
Child:
onReveive(message) {
do stuff
}
如上所述,在onChildOrder方法中,对象result = Await.result(future, timeout.duration())总是超时,并且当父级的onReceive方法完成时,消息ChildOrder到达子级的onReceive方法。
似乎子级在父级完成之前无法处理任何消息。
是否有办法发送消息给子级并等待结果?