重启后,Akka演员不会重新连接到远程Actor

时间:2017-08-21 08:43:24

标签: java docker akka

所以我有两个运行2个akka系统的码头工人。

容器A运行系统A

容器B运行系统B

当系统A加载时,它用:

连接到系统B.
Await.result(system.actorSelection(actorPath).resolveOne(new Timeout(RESOLVE_DURATION)), RESOLVE_DURATION)

这里很好,连接成功,系统交换消息。

然后我重启容器B

docker restart container-b

在系统A上,如果系统B终止,我会在系统B上添加一个监视。 当我重新启动系统B时,我在系统A中收到akka Terminated消息 - 一切都很好。 然后我每隔5秒启动一次重新连接循环并尝试再次使用以下命令重新连接到系统B:

Await.result(system.actorSelection(actorPath).resolveOne(new Timeout(RESOLVE_DURATION)), RESOLVE_DURATION)

但现在,我得到了ActorNotFound的例外情况。

    [ERROR] [21/08/2017 08:11:49.851] [exchange-akka.actor.default-dispatcher-14] [akka.remote.EndpointWriter] AssociationError [akka.tcp://system@systemA:2555] -> [akka.tcp://system@systemB:2550]: Error [Shut down address: akka.tcp://system@systemB:2550] [
    akka.remote.ShutDownAssociation: Shut down address: akka.tcp://system@systemB:2550
    Caused by: akka.remote.transport.Transport$InvalidAssociationException: The remote system terminated the association because it is shutting down.
    ]

    [ERROR] [21/08/2017 08:11:54.850] [exchange-akka.actor.default-dispatcher-14] [c.m.e.c.actors.watchdog.WatchDog] Failed to reconnect to path [akka.tcp://system@systemB:2550/user/MyActor]
    akka.actor.ActorNotFound: Actor not found for: ActorSelection[Anchor(akka.tcp://system@systemB:2550/), Path(/user/MyActor)]
        at akka.actor.ActorSelection$$anonfun$resolveOne$1.apply(ActorSelection.scala:65) ~[akka-actor_2.11-2.4.0.jar:na]
        at akka.actor.ActorSelection$$anonfun$resolveOne$1.apply(ActorSelection.scala:63) ~[akka-actor_2.11-2.4.0.jar:na]
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) ~[scala-library-2.11.7.jar:na]
        at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55) ~[akka-actor_2.11-2.4.0.jar:na]
        at akka.dispatch.BatchingExecutor$Batch.run(BatchingExecutor.scala:73) ~[akka-actor_2.11-2.4.0.jar:na]
        at akka.dispatch.ExecutionContexts$sameThreadExecutionContext$.unbatchedExecute(Future.scala:74) ~[akka-actor_2.11-2.4.0.jar:na]
        at akka.dispatch.BatchingExecutor$class.execute(BatchingExecutor.scala:120) ~[akka-actor_2.11-2.4.0.jar:na]
        at akka.dispatch.ExecutionContexts$sameThreadExecutionContext$.execute(Future.scala:73) ~[akka-actor_2.11-2.4.0.jar:na]
        at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:40) ~[scala-library-2.11.7.jar:na]
        at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:248) ~[scala-library-2.11.7.jar:na]
        at akka.pattern.PromiseActorRef.$bang(AskSupport.scala:345) ~[akka-actor_2.11-2.4.0.jar:na]
        at akka.actor.EmptyLocalActorRef.specialHandle(ActorRef.scala:553) ~[akka-actor_2.11-2.4.0.jar:na]
        at akka.actor.DeadLetterA

ctorRef.specialHandle(ActorRef.scala:589) ~[akka-actor_2.11-2.4.0.jar:na]
        at akka.actor.DeadLetterActorRef.$bang(ActorRef.scala:579) ~[akka-actor_2.11-2.4.0.jar:na]
        at akka.remote.RemoteActorRefProvider$RemoteDeadLetterActorRef.$bang(RemoteActorRefProvider.scala:85) ~[akka-remote_2.11-2.4.0.jar:na]
        at akka.remote.EndpointManager$$anonfun$2.applyOrElse(Remoting.scala:614) ~[akka-remote_2.11-2.4.0.jar:na]
        at akka.actor.Actor$class.aroundReceive(Actor.scala:480) ~[akka-actor_2.11-2.4.0.jar:na]
        at akka.remote.EndpointManager.aroundReceive(Remoting.scala:400) ~[akka-remote_2.11-2.4.0.jar:na]
        at akka.actor.ActorCell.receiveMessage(ActorCell.scala:525) [akka-actor_2.11-2.4.0.jar:na]
        at akka.actor.ActorCell.invoke(ActorCell.scala:494) [akka-actor_2.11-2.4.0.jar:na]
        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257) [akka-actor_2.11-2.4.0.jar:na]
        at akka.dispatch.Mailbox.run(Mailbox.scala:224) [akka-actor_2.11-2.4.0.jar:na]
        at akka.dispatch.Mailbox.exec(Mailbox.scala:234) [akka-actor_2.11-2.4.0.jar:na]
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [scala-library-2.11.7.jar:na]
        at 
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [scala-library-2.11.7.jar:na]
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [scala-library-2.11.7.jar:na]
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [scala-library-2.11.7.jar:na]

当我尝试重新连接时,第一个连接中的actorPath是相同的路径。

只有当我重新启动系统A(通过重新启动容器A)时,连接才会像开始一样成功。

版本:

java 8

akka版本:2.4.0

docker version

Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 17:07:28 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 17:07:28 2017
 OS/Arch:      linux/amd64
 Experimental: false

修改 我正在运行简单的远程,而不是akka集群 + 这是我的承诺:

akka {        
  provider = "akka.remote.RemoteActorRefProvider"
  remote {
    transport = "akka.remote.netty.NettyRemoteTransport"
    netty.tcp {
      hostname = ${?AKKA_HOST}
      port = ${?AKKA_PORT}

      bind-hostname = 0.0.0.0
    }
  }
}

此配置有效,消息已在容器之间传输

0 个答案:

没有答案