Akka遥控器/工作人员断开连接并被隔离

时间:2014-02-12 01:13:16

标签: scala akka remote-server akka-cluster

遥控器系统:

代码:

private final ActorRef reaper = getContext().actorOf(Props.create(Reaper.class), "reaper");
private final ActorRef router = getContext().actorOf(Props.create(Worker.class).withRouter(new RemoteRouterConfig(new RoundRobinRouter(10), getNodes())), "router");

getnodes()是List<Address>

application.conf:

akka {
  log-dead-letters-during-shutdown = off
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
    remote {
      enabled-transports = ["akka.remote.netty.tcp"]
      transport-failure-detector {
        acceptable-heartbeat-pause = 100s
      }
      watch-failure-detector {
        acceptable-heartbeat-pause = 100s
      }
      netty.tcp {
        hostname = "127.0.0.1"
        port = 2552
      }
    }
  }
}

远程工作者系统: 代码:

 private ActorSystem system;

  public RemoteWorker(String name) {
    Config conf = ConfigFactory.load("remote");
    int port = conf.getInt("akka.remote.netty.tcp.port");
    system = ActorSystem.create(name, conf);
  }

  private void handleShutdown() {
    Runtime.getRuntime().addShutdownHook(new Thread() {
      @Override public void run() {
        System.out.println("Shutting down remote actor system...");
        system.shutdown();
      }
    });
  }

  public static void main(String[] args) {
    String systemName = (args.length == 0) ? "remote" : args[0];
    RemoteWorker remsys = new RemoteWorker(systemName);
    remsys.handleShutdown();
  }

remote.conf

akka {
  log-dead-letters-during-shutdown = off
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }
  remote {
    enabled-transports = ["akka.remote.netty.tcp"]
    netty.tcp {
      hostname = ""
      port = 2553
    }
  }
}

错误: [WARN] [02/11/2014 14:50:26.728] [remote-akka.actor.default-dispatcher-17] [akka://..../system/remote-watcher]检测到无法访问:[akka。 TCP://remote@192.178.1.100:2553] [INFO] [02/11/2014 14:50:26.728] [remote-akka.actor.default-dispatcher-15] [Remoting]地址[akka.tcp://remote@192.178.1.100:2553]现已被隔离,所有发往此地址的邮件都将发送给死信。

1 个答案:

答案 0 :(得分:1)

您的主人希望工作人员在127.0.0.1听,但工作人员会听取计算机的默认地址。