Akka.Net 远程处理:ActorSelection 与 IActorRef
Akka.Net Remoting: ActorSelection vs. IActorRef
将 Akka.net 与远程处理结合使用。 This article 关于使用 ActorSelection 有以下说法:
The other time when I tend to use an ActorSelection is when I am
initially communicating with a remote actor system.
我不太明白的是如何将初始的 ActorSelection 转换为我可以继续使用的 IActorRef。
这里最简单的方法是使用actorSelection.ResolveOne(timeout)
方法,这将return Task<IActorRef>
。如果在提供的路径下没有找到参与者,任务也可能以超时或 ActorNotFoundException
结束。
另一种更符合演员习惯的方式是向演员选择发送 Identify(correlationId)
消息。它应该以 ActorIdentity(correlationId, actorRef)
回复响应。请注意,如果在提供的演员选择下没有人收听,它可能根本不会响应。
将 Akka.net 与远程处理结合使用。 This article 关于使用 ActorSelection 有以下说法:
The other time when I tend to use an ActorSelection is when I am initially communicating with a remote actor system.
我不太明白的是如何将初始的 ActorSelection 转换为我可以继续使用的 IActorRef。
这里最简单的方法是使用actorSelection.ResolveOne(timeout)
方法,这将return Task<IActorRef>
。如果在提供的路径下没有找到参与者,任务也可能以超时或 ActorNotFoundException
结束。
另一种更符合演员习惯的方式是向演员选择发送 Identify(correlationId)
消息。它应该以 ActorIdentity(correlationId, actorRef)
回复响应。请注意,如果在提供的演员选择下没有人收听,它可能根本不会响应。