[INFO] [06/20/2017 21:24:37.955] [main] [akka.remote.Remoting] Starting remoting
[INFO] [06/20/2017 21:24:38.091] [main] [akka.remote.Remoting] Remoting started; listening on addresses :[akka.tcp://remoteSystem@127.0.0.1:2552]
[INFO] [06/20/2017 21:24:38.092] [main] [akka.remote.Remoting] Remoting now listens on addresses: [akka.tcp://remoteSystem@127.0.0.1:2552]
[WARN] [06/20/2017 21:27:06.330] [remoteSystem-akka.actor.default-dispatcher-4] [akka://remoteSystem/user/supervisorActor/calculator] / by zero
[ERROR] [06/20/2017 21:27:34.176] [remoteSystem-akka.remote.default-remote-dispatcher-5] [akka.tcp://remoteSystem@127.0.0.1:2552/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FlocalSystem%40127.0.0.1%3A60601-0/endpointWriter] AssociationError [akka.tcp://remoteSystem@127.0.0.1:2552] <- [akka.tcp://localSystem@127.0.0.1:60601]: Error [Shut down address: akka.tcp://localSystem@127.0.0.1:60601] [
akka.remote.ShutDownAssociation: Shut down address: akka.tcp://localSystem@127.0.0.1:60601
Caused by: akka.remote.transport.Transport$InvalidAssociationException: The remote system terminated the association because it is shutting down.
]
/** * A message all Actors will understand, that when processed will reply with * [[akka.actor.ActorIdentity]] containing the `ActorRef`. The `messageId` * is returned in the `ActorIdentity` message as `correlationId`. */ @SerialVersionUID(1L) final case class Identify(messageId: Any) extends AutoReceivedMessage with NotInfluenceReceiveTimeout /** * Reply to [[akka.actor.Identify]]. Contains * `Some(ref)` with the `ActorRef` of the actor replying to the request or * `None` if no actor matched the request. * The `correlationId` is taken from the `messageId` in * the `Identify` message. */ @SerialVersionUID(1L) final case class ActorIdentity(correlationId: Any, ref: Option[ActorRef]) { if (ref.isDefined && ref.get == null) { throw new IllegalArgumentException("ActorIdentity created with ref = Some(null) is not allowed, " +
"this could happen when serializing with Scala 2.12 and deserializing with Scala 2.11 which is not supported.") } /** * Java API: `ActorRef` of the actor replying to the request or * null if no actor matched the request. */ @deprecated("Use getActorRef instead", "2.5.0") def getRef: ActorRef = ref.orNull /** * Java API: `ActorRef` of the actor replying to the request or * not defined if no actor matched the request. */ def getActorRef: Optional[ActorRef] = { import scala.compat.java8.OptionConverters._ ref.asJava } }
object LocalIdentifyDemo extends App { class RemoteCalc extends Actor with ActorLogging { val path = "akka.tcp://remoteSystem@127.0.0.1:2552/user/supervisorActor/calculator" context.actorSelection(path) ! Identify(path) //send req for ActorRef
import context.dispatcher implicit val timeout = Timeout(5 seconds) override def receive: Receive = { case ActorIdentity(p,someRef) if p.equals(path) => someRef foreach