任何已知的情況下TypedActor.getContext().sender()
按預期不表現?阿卡(Java)的發送器()方法奇怪的行爲
我知道,在發射後不管模式,默認爲deadLetters
,但我遇到了一些不同的東西:
// inside MainActor
IPrintingActor printingActor = create(IPrintingActor.class, PrintingActor.class);
printingActor.blockingPrintln("foo");
其中上述create
簡直就是通常typedActorOf
呼叫
// inside PrintingActor
@Override
public boolean blockingPrintln(String string)
{
System.out.println(TypedActor.context().sender() + " says " + string);
return true;
}
輸出是
演員[阿卡://MySystem/user/$ b]表示foo
但是,此actor實際上與TypedActor.context()。self()相同。
任何理由發送者()調用將返回相同的自我()?在主要演員打印報表打印
演員[阿卡:// MySystem /用戶/ $ A]
爲的MainActor和
演員[阿卡:// MySystem /用戶/ $ b]
的PrintingActor。內PrintingActor,然而,它們都打印爲
演員[阿卡:// MySystem /用戶/ $ B]
幫助非常感謝!
我不是在阿卡的專家,因爲我的背景是從二郎的一面,但如果我沒有記錯的話,你直接調用類的方法,但實際上沒有將消息發送到演員。我認爲你應該使用bang(!)運算符來發送消息給演員 – aseychell 2013-03-16 01:11:29
感謝您研究這個,但我使用的是類型演員。因此,我在做什麼其實是一個閉塞消息發送 http://doc.akka.io/docs/akka/snapshot/java/typed-actors.html – dow 2013-03-16 01:24:57