Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java actorSelection和resolveActorRef之间的Akka差异_Java_Akka_Actor Model - Fatal编程技术网

Java actorSelection和resolveActorRef之间的Akka差异

Java actorSelection和resolveActorRef之间的Akka差异,java,akka,actor-model,Java,Akka,Actor Model,我使用两种不同的方法来获得相同的结果,但在一种方法中我需要指定回拨时间为什么? 他们做了同样的事情吗 ActorRef resolveActorRef = getContext().getSystem() .provider() .resolveActorRef(ActorPath.fromString("akka://RootRemoteActors/user/$a/remote.actors.AA")); 上面的代码在不等待任何时间的情况下检索act

我使用两种不同的方法来获得相同的结果,但在一种方法中我需要指定回拨时间为什么? 他们做了同样的事情吗

    ActorRef resolveActorRef = getContext().getSystem()
                .provider() .resolveActorRef(ActorPath.fromString("akka://RootRemoteActors/user/$a/remote.actors.AA"));
上面的代码在不等待任何时间的情况下检索actor Ref 为什么如果我没有获得proveider,我必须指定一个持续时间

      ActorSelection actorSelection = getContext().getSystem()
            .actorSelection( ActorPath.fromString("akka://RootRemoteActors/user/$a/remote.actors.AA"));



       ActorRef ois = actorSelection.resolveOne( new Timeout(1000, TimeUnit.MILLISECONDS  ))
                .value().get().get();

最明显的区别可能是,如果在参与者路径中使用通配符,
ActorSelection
可以表示多个
ActorRef
s。因此,如果您只需在
actor选择上调用
.tell
,而不是
resolveOne
即可将消息传递给所有匹配的参与者

我从未使用过
resolveActorRef
,但从源代码(和)
ActorRefProvider
中可以看到,我使用
rootGuardian
上的
getChild
查找您正在查找的
Actor
,因此从Actor树的顶部向下遍历,直到他最终找到它(或没有)

ActorSelection
尝试使用ask模式(因此超时)向选择发送
Identify
消息,如果收到响应,它将提供从中获得响应的
ActorRef

resolveActorRef
似乎是在您编写自己的序列化程序时使用的:,因此,如果您只想解析一个参与者,我将使用
ActorSelection
(顺便说一句,您不必解析它,就可以向它发送消息)