简体   繁体   English

如何在akka中查找来自不同系统的远程actor的引用?

[英]How can I look up a reference to a remote actor from a different system in akka?

I have an ActorSystem running on port 2552 and another running on port 2553. Each of them create an Actor which instantiates a singleton object. 我有一个在端口2552上运行的ActorSystem,另一个在端口2553上运行。每个都创建一个实例化单例对象的Actor。 I now want to create another system that manages both of these systems and can reference these actors in order to make use of the singletons simultaneously. 我现在想要创建另一个管理这两个系统的系统,并且可以引用这些actor以便同时使用单例。

I know the actors are listening on the port because it gives me a log like this for each port 我知道演员正在监听端口,因为它为每个端口提供了这样的日志

 Remoting started; listening on addresses :[akka.tcp://singletonApplication@127.0.0.1:2552]

and it when I look at the object using the debugger the actor shows up like this 当我使用调试器查看对象时,actor就会显示出来

 Actor[akka://singletonApplication/user/singleton]

I create the manager system using 我使用创建管理器系统

 ActorSystem system = ActorSystem.create("managerSystem");

but when I try and reference the remote actors by the following line 但是当我尝试通过以下行引用远程actor时

 system.actorSelection("akka.tcp://singletonApplication@127.0.0.1:2552/user/singleton");

It gives me this in the object 它在对象中给了我这个

 ActorSelection[Actor[akka://managerApplication/deadLetters]/user/singleton]

and when I try and send it a message it gives me a deadletter error log in the console I am not really sure what I doing wrong but it looks like the system I am trying to use to look up the remote actors is messing up my actorSelection call. 当我尝试发送一条消息时,它在控制台中给出了一个死信错误日志我不太确定我做错了但看起来我试图用来查找远程actor的系统搞乱了我的actorSelection呼叫。 Do I need to be within the same system in order to reference a remote actor? 我是否需要在同一系统内才能引用远程演员? I thought this was one of the points to using akka? 我认为这是使用akka的要点之一?

You are saying that you are accessing the remote actor from a different system. 您说您正在从其他系统访问远程actor。 But i see that you are using 127.0.0.1 to address the remote system. 但我发现你使用127.0.0.1来解决远程系统问题。 127.0.0.1 is a special loopback address and refers to the local machine. 127.0.0.1是一个特殊的环回地址,指的是本地机器。 So you need to give addressable IP to access remote machine. 所以你需要提供可寻址的IP来访问远程机器。

For more on Loopback check this http://en.wikipedia.org/wiki/Loopback 有关Loopback的更多信息,请查看http://en.wikipedia.org/wiki/Loopback

This is also clearly stated in the documentation : 文档中也明确说明了这一点:

"Note “注意

Be sure to replace the default IP 127.0.0.1 with the real address the system is reachable by if you deploy onto multiple machines! 如果部署到多台计算机上,请务必将默认IP 127.0.0.1替换为系统可访问的实际地址! "

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM