0

我正在尝试向尚未提出的演员发送消息。当我这样做时,我在控制台上看到以下消息,但是如何以编程方式/通过配置捕获此错误。

[WARN] [09/25/2017 14:15:01.127] [JavaEngineSystem-akka.remote.default-remote-dispatcher-6] [akka.tcp://JavaEngineSystem@018x02h2:1727/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FScalaEngineSystem%40018x02h2%3A4090-0] Association with remote system [akka.tcp://ScalaEngineSystem@018x02h2:4090] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://ScalaEngineSystem@018x02h2:4090]] Caused by: [Connection refused]
[INFO] [09/25/2017 14:15:01.141] [JavaEngineSystem-akka.actor.default-dispatcher-3] [akka://JavaEngineSystem/deadLetters] Message [com.impl.ActorMessage] from Actor[akka://JavaEngineSystem/temp/$a] to Actor[akka://JavaEngineSystem/deadLetters] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.

这是我的系统初始化部分代码:

system = ActorSystem.create("JavaEngineSystem", ConfigFactory.load(ScalaAkkaAccessor.class.getClassLoader()));
        thisActor = system.actorOf(Props.create(AvroActor.class), "javaEngine");
        List<String> paths = new ArrayList<String>();
        StringTokenizer tokenizer = new StringTokenizer(akkaUrl, ",");
        while(tokenizer.hasMoreTokens()) {
            paths.add(tokenizer.nextToken());
        }
        scalaEngineRouterRemote = system.actorOf(new RoundRobinGroup(paths).props(), "router4");

消息发送代码:

Timeout timeout = new Timeout(Duration.create(timeoutDuration, "minute"));
        ActorMessage msg = new ActorMessage();
        msg.setStr(OPER);
        Future<Object> future = Patterns.ask(scalaEngineRouterRemote, msg, timeout);
        Object retn = Await.result(future, timeout.duration());

基本上,在我知道远程参与者不可用(或未运行)而不是等待超时后,我会立即尝试恢复。

4

0 回答 0