diff --git a/akka-docs/java/code/docs/remoting/RemoteActorExample.java b/akka-docs/java/code/docs/remoting/RemoteActorExample.java deleted file mode 100644 index 3ca25bd153..0000000000 --- a/akka-docs/java/code/docs/remoting/RemoteActorExample.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (C) 2009-2012 Typesafe Inc. - */ -package docs.remoting; - -import akka.actor.ActorRef; -import akka.actor.UntypedActor; - -public class RemoteActorExample extends UntypedActor { - //#localNodeActor - ActorRef a1 = getContext().actorFor("/serviceA/retrieval"); - //#localNodeActor - - //#remoteNodeActor - ActorRef a2 = getContext().actorFor("akka://app@10.0.0.1:2552/user/serviceA/retrieval"); - //#remoteNodeActor - - public void onReceive(Object message) throws Exception { - // Do something - } -} diff --git a/akka-docs/java/code/docs/remoting/RemoteDeploymentDocTestBase.java b/akka-docs/java/code/docs/remoting/RemoteDeploymentDocTestBase.java index cfb12ac7c4..403193ac3c 100644 --- a/akka-docs/java/code/docs/remoting/RemoteDeploymentDocTestBase.java +++ b/akka-docs/java/code/docs/remoting/RemoteDeploymentDocTestBase.java @@ -17,7 +17,17 @@ import akka.actor.ActorSystem; import akka.remote.RemoteScope; //#import +import akka.actor.UntypedActor; + public class RemoteDeploymentDocTestBase { + + //#sample-actor + public static class Echo extends UntypedActor { + public void onReceive(Object message) { + getSender().tell(getSelf(), getSelf()); + } + } + //#sample-actor static ActorSystem system; @@ -38,9 +48,19 @@ public class RemoteDeploymentDocTestBase { addr = AddressFromURIString.parse("akka://sys@host:1234"); // the same //#make-address //#deploy - ActorRef ref = system.actorOf(new Props(RemoteDeploymentDocSpec.Echo.class).withDeploy(new Deploy(new RemoteScope(addr)))); + ActorRef ref = system.actorOf(new Props(Echo.class).withDeploy(new Deploy(new RemoteScope(addr)))); //#deploy assert ref.path().address().equals(addr); } + + @Test + public void demonstrateSampleActor() { + //#sample-actor + + ActorRef actor = system.actorOf(new Props(Echo.class), "sampleActor"); + actor.tell("Pretty slick", null); + //#sample-actor + } + } \ No newline at end of file diff --git a/akka-docs/java/remoting.rst b/akka-docs/java/remoting.rst index 3da0116ab7..faa568a428 100644 --- a/akka-docs/java/remoting.rst +++ b/akka-docs/java/remoting.rst @@ -82,31 +82,30 @@ Once you obtained a reference to the actor you can interact with it they same wa Creating Actors Remotely ^^^^^^^^^^^^^^^^^^^^^^^^ -The configuration below instructs the system to deploy the actor "retrieval” on the specific host "app@10.0.0.1". -The "app" in this case refers to the name of the ``ActorSystem`` (only showing deployment section):: +If you want to use the creation functionality in Akka remoting you have to further amend the +``application.conf`` file in the following way (only showing deployment section):: akka { actor { deployment { - /serviceA/retrieval { - remote = "akka://app@10.0.0.1:2552" + /sampleActor { + remote = "akka://sampleActorSystem@127.0.0.1:2553" } } } } -Logical path lookup is supported on the node you are on, i.e. to use the -actor created above you would do the following: +The configuration above instructs Akka to react when an actor with path ``/sampleActor`` is created, i.e. +using ``system.actorOf(new Props(...), "sampleActor")``. This specific actor will not be directly instantiated, +but instead the remote daemon of the remote system will be asked to create the actor, +which in this sample corresponds to ``sampleActorSystem@127.0.0.1:2553``. -.. includecode:: code/docs/remoting/RemoteActorExample.java#localNodeActor +Once you have configured the properties above you would do the following in code: -This will obtain an ``ActorRef`` on a remote node: +.. includecode:: code/docs/remoting/RemoteDeploymentDocTestBase.java#sample-actor -.. includecode:: code/docs/remoting/RemoteActorExample.java#remoteNodeActor - -As you can see from the example above the following pattern is used to find an ``ActorRef`` on a remote node:: - - akka://@:/ +The actor class ``Echo`` has to be available to the runtimes using it, i.e. the classloader of the +actor systems has to have a JAR containing the class. .. note:: diff --git a/akka-docs/scala/code/docs/remoting/RemoteDeploymentDocSpec.scala b/akka-docs/scala/code/docs/remoting/RemoteDeploymentDocSpec.scala index b391494a3b..593bcf1906 100644 --- a/akka-docs/scala/code/docs/remoting/RemoteDeploymentDocSpec.scala +++ b/akka-docs/scala/code/docs/remoting/RemoteDeploymentDocSpec.scala @@ -12,11 +12,11 @@ import akka.remote.RemoteScope object RemoteDeploymentDocSpec { + //#sample-actor class Echo extends Actor { - def receive = { - case x ⇒ sender ! self - } + def receive = { case _ ⇒ sender ! self } } + //#sample-actor } @@ -49,4 +49,12 @@ class RemoteDeploymentDocSpec extends AkkaSpec(""" one must be === two } + "demonstrate sampleActor" in { + //#sample-actor + + val actor = system.actorOf(Props[Echo], "sampleActor") + actor ! "Pretty slick" + //#sample-actor + } + } \ No newline at end of file diff --git a/akka-docs/scala/remoting.rst b/akka-docs/scala/remoting.rst index 9e11412ef1..d482b21b04 100644 --- a/akka-docs/scala/remoting.rst +++ b/akka-docs/scala/remoting.rst @@ -103,18 +103,15 @@ If you want to use the creation functionality in Akka remoting you have to furth } The configuration above instructs Akka to react when an actor with path ``/sampleActor`` is created, i.e. -using ``system.actorOf(Props(...)`, sampleActor)``. This specific actor will not be directly instantiated, +using ``system.actorOf(Props(...), "sampleActor")``. This specific actor will not be directly instantiated, but instead the remote daemon of the remote system will be asked to create the actor, which in this sample corresponds to ``sampleActorSystem@127.0.0.1:2553``. -Once you have configured the properties above you would do the following in code:: +Once you have configured the properties above you would do the following in code: - class SampleActor extends Actor { def receive = { case _ => println("Got something") } } +.. includecode:: code/docs/remoting/RemoteDeploymentDocSpec.scala#sample-actor - val actor = context.actorOf(Props[SampleActor], "sampleActor") - actor ! "Pretty slick" - -``SampleActor`` has to be available to the runtimes using it, i.e. the classloader of the +The actor class ``Echo`` has to be available to the runtimes using it, i.e. the classloader of the actor systems has to have a JAR containing the class. .. note::