我在akka(java)中遇到了一个问题,发件人的引用在未来一段时间后消失了。这是代码:
class MyActor extends UntypedActor {
@Override
public void onReceive(Object msg){
Future<Integer> future = Futures.future(new Callable<Integer>(){
@Override
public Integer call() throws Exception {
System.out.println(getSender()); //works fine
Thread.sleep(1000);
System.out.println(getSender()); //show deadLetter
return 42;
}
},getContext().dispatcher());
//do something with the future, pipe it or whatever
Patterns.pipe(future,getContext().dispatcher(),getSender());
}
}
我可能错过了文档中的某些内容。