我有一个 Java 客户端,它获取一个自动生成的端口。启动actor系统后,我想访问端口。
Config clientConfig = ConfigFactory.parseString("akka.remote.netty.tcp.port = 0")
.withFallback(ConfigFactory.parseString("akka.remote.netty.tcp.hostname = " + serverHostName))
.withFallback(ConfigFactory.load("common"));
actorSystem = ActorSystem.create("clientActorSystem", clientConfig);
// how to access the generated port here..!?
端口必须已经设置,因为之后的日志输出ActorSystem.create(...)
是这样的:
[INFO] [03/31/2016 14:11:32.042] [main] [akka.remote.Remoting] Starting remoting
[INFO] [03/31/2016 14:11:32.233] [main] [akka.remote.Remoting] Remoting started; listening on addresses :[akka.tcp://actorSystem@localhost:58735]
[INFO] [03/31/2016 14:11:32.234] [main] [akka.remote.Remoting] Remoting now listens on addresses: [akka.tcp://actorSystem@localhost:58735]
如果我尝试通过配置来获取它actorSystem.settings().config().getValue("akka.remote.netty.tcp.port")
,我仍然会得到之前定义的 0。
有谁知道如何访问此端口(示例中为 58735)?