Akka 2.4.1 Java API here。我現在沒有帶寬學習Scala,所以我會問這裏的代碼示例也使用Java API。如何使阻塞/同步調用進入Akka actor系統?
我有一個現有的ActorSystem
,它充滿了異步的演員,並且工作得很漂亮。我現在有一個需要重用這個演員系統在同步情況下,像這樣:
// Groovy pseudo-code; NOT inside the actor system here!
ComputationRequest request = new ComputationRequest(1, 7, true)
MasterActor master = actorSystem.get(...)
ComputationResult result = actorSystem.tell(master, request)
無處阿卡的文檔中我會看到發送equests到演員系統(來自外部),然後檢索的一個明顯的例子結果。我可以在這裏使用Futures
嗎?在Akka(代碼示例)中處理這種模式的標準方式是什麼?