From 04729bcbc33cbbc0566899a9e6bade5d13d3cba3 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 1 Aug 2011 17:07:12 +0200 Subject: [PATCH] Renaming sendOneWay to tell, closing ticket #1072 --- .../akka/dispatch/DispatcherActorSpec.scala | 2 +- .../scala/akka/dispatch/PinnedActorSpec.scala | 2 +- .../src/main/java/akka/actor/Actors.java | 12 ++++++------ .../src/main/scala/akka/actor/ActorRef.scala | 2 +- .../src/main/scala/akka/actor/Channel.scala | 16 ++++++++-------- .../main/scala/akka/actor/UntypedActor.scala | 6 +++--- .../camel/UntypedProducerFeatureTest.scala | 2 +- .../akka/remote/netty/NettyRemoteSupport.scala | 2 +- akka-docs/intro/getting-started-first-java.rst | 16 ++++++++-------- akka-docs/java/dataflow.rst | 8 ++++---- akka-docs/java/dispatchers.rst | 14 +++++++------- akka-docs/java/fault-tolerance.rst | 2 +- akka-docs/java/futures.rst | 2 +- akka-docs/java/remote-actors.rst | 2 +- akka-docs/java/routing.rst | 14 +++++++------- akka-docs/java/stm.rst | 4 ++-- akka-docs/java/transactors.rst | 8 ++++---- akka-docs/java/untyped-actors.rst | 14 +++++++------- akka-docs/modules/camel.rst | 2 +- .../scala/DispatcherSpringFeatureTest.scala | 2 +- .../scala/UntypedActorSpringFeatureTest.scala | 18 +++++++++--------- .../akka/transactor/UntypedTransactor.scala | 2 +- .../akka/stm/example/EitherOrElseExample.java | 2 +- .../java/akka/stm/example/RetryExample.java | 2 +- .../example/UntypedCoordinatedCounter.java | 2 +- .../example/UntypedCoordinatedExample.java | 2 +- .../example/UntypedTransactorExample.java | 2 +- .../test/UntypedCoordinatedCounter.java | 2 +- .../test/UntypedCoordinatedIncrementTest.java | 4 ++-- .../transactor/test/UntypedTransactorTest.java | 4 ++-- .../main/java/akka/tutorial/first/java/Pi.java | 8 ++++---- .../java/akka/tutorial/java/second/Pi.java | 8 ++++---- 32 files changed, 94 insertions(+), 94 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/DispatcherActorSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/DispatcherActorSpec.scala index dc55ad3270..2d5b3ecb16 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/DispatcherActorSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/DispatcherActorSpec.scala @@ -36,7 +36,7 @@ class DispatcherActorSpec extends JUnitSuite { private val unit = TimeUnit.MILLISECONDS @Test - def shouldSendOneWay = { + def shouldTell = { val actor = actorOf[OneWayTestActor].start() val result = actor ! "OneWay" assert(OneWayTestActor.oneWay.await(1, TimeUnit.SECONDS)) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/PinnedActorSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/PinnedActorSpec.scala index c2b6f93ec2..48918d994d 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/PinnedActorSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/PinnedActorSpec.scala @@ -41,7 +41,7 @@ class PinnedActorSpec extends JUnitSuite { } @Test - def shouldSendOneWay { + def shouldTell { var oneWay = new CountDownLatch(1) val actor = actorOf(new Actor { self.dispatcher = Dispatchers.newPinnedDispatcher(self) diff --git a/akka-actor/src/main/java/akka/actor/Actors.java b/akka-actor/src/main/java/akka/actor/Actors.java index 3ef7bc254b..147585cd79 100644 --- a/akka-actor/src/main/java/akka/actor/Actors.java +++ b/akka-actor/src/main/java/akka/actor/Actors.java @@ -46,7 +46,7 @@ public class Actors { * } * }, "my-actor-address"); * actor.start(); - * actor.sendOneWay(message, context); + * actor.tell(message, context); * actor.stop(); * */ @@ -70,7 +70,7 @@ public class Actors { * } * }); * actor.start(); - * actor.sendOneWay(message, context); + * actor.tell(message, context); * actor.stop(); * */ @@ -84,7 +84,7 @@ public class Actors { *
    *   ActorRef actor = Actors.actorOf(MyUntypedActor.class, "my-actor-address");
    *   actor.start();
-   *   actor.sendOneWay(message, context);
+   *   actor.tell(message, context);
    *   actor.stop();
    * 
* You can create and start the actor in one statement like this: @@ -102,7 +102,7 @@ public class Actors { *
    *   ActorRef actor = Actors.actorOf(MyUntypedActor.class, "my-actor-address");
    *   actor.start();
-   *   actor.sendOneWay(message, context);
+   *   actor.tell(message, context);
    *   actor.stop();
    * 
* You can create and start the actor in one statement like this: @@ -130,7 +130,7 @@ public class Actors { /** * The message that when sent to an Actor kills it by throwing an exception. *
-     *  actor.sendOneWay(kill());
+     *  actor.tell(kill());
      * 
* @return the single instance of Kill */ @@ -142,7 +142,7 @@ public class Actors { /** * The message that when sent to an Actor shuts it down by calling 'stop'. *
-     *  actor.sendOneWay(poisonPill());
+     *  actor.tell(poisonPill());
      * 
* @return the single instance of PoisonPill */ diff --git a/akka-actor/src/main/scala/akka/actor/ActorRef.scala b/akka-actor/src/main/scala/akka/actor/ActorRef.scala index 3d8531cd8b..6f0d1ad2cf 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorRef.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorRef.scala @@ -262,7 +262,7 @@ abstract class ActorRef extends ActorRefShared with ForwardableChannel with java * Sends a message asynchronously returns a future holding the eventual reply message. *

* NOTE: - * Use this method with care. In most cases it is better to use 'sendOneWay' together with the 'getContext().getSender()' to + * Use this method with care. In most cases it is better to use 'tell' together with the 'getContext().getSender()' to * implement request/response message exchanges. *

* If you are sending messages using ask then you have to use getContext().reply(..) diff --git a/akka-actor/src/main/scala/akka/actor/Channel.scala b/akka-actor/src/main/scala/akka/actor/Channel.scala index d5e3ce7159..df35725bfc 100644 --- a/akka-actor/src/main/scala/akka/actor/Channel.scala +++ b/akka-actor/src/main/scala/akka/actor/Channel.scala @@ -59,10 +59,10 @@ trait Channel[-T] { * Java API.

* Sends the specified message to the channel, i.e. fire-and-forget semantics.

*

-   * actor.sendOneWay(message);
+   * actor.tell(message);
    * 
*/ - def sendOneWay(msg: T): Unit = this.!(msg) + def tell(msg: T): Unit = this.!(msg) /** * Java API.

@@ -70,19 +70,19 @@ trait Channel[-T] { * semantics, including the sender reference if possible (not supported on * all channels).

*

-   * actor.sendOneWay(message, context);
+   * actor.tell(message, context);
    * 
*/ - def sendOneWay(msg: T, sender: UntypedChannel): Unit = this.!(msg)(sender) + def tell(msg: T, sender: UntypedChannel): Unit = this.!(msg)(sender) /** * Java API.

* Try to send the specified message to the channel, i.e. fire-and-forget semantics.

*

-   * actor.sendOneWay(message);
+   * actor.tell(message);
    * 
*/ - def sendOneWaySafe(msg: T): Boolean = this.safe_!(msg) + def tellSafe(msg: T): Boolean = this.safe_!(msg) /** * Java API.

@@ -90,10 +90,10 @@ trait Channel[-T] { * semantics, including the sender reference if possible (not supported on * all channels).

*

-   * actor.sendOneWay(message, context);
+   * actor.tell(message, context);
    * 
*/ - def sendOneWaySafe(msg: T, sender: UntypedChannel): Boolean = this.safe_!(msg)(sender) + def tellSafe(msg: T, sender: UntypedChannel): Boolean = this.safe_!(msg)(sender) } diff --git a/akka-actor/src/main/scala/akka/actor/UntypedActor.scala b/akka-actor/src/main/scala/akka/actor/UntypedActor.scala index a89a9bccc0..fa93cc0e57 100644 --- a/akka-actor/src/main/scala/akka/actor/UntypedActor.scala +++ b/akka-actor/src/main/scala/akka/actor/UntypedActor.scala @@ -25,7 +25,7 @@ import akka.japi.{ Creator, Procedure } * } else if (msg.equals("UseSender") && getContext().getSender().isDefined()) { * // Reply to original sender of message using the sender reference * // also passing along my own reference (the context) - * getContext().getSender().get().sendOneWay(msg, context); + * getContext().getSender().get().tell(msg, context); * * } else if (msg.equals("UseSenderFuture") && getContext().getSenderFuture().isDefined()) { * // Reply to original sender of message using the sender future reference @@ -33,7 +33,7 @@ import akka.japi.{ Creator, Procedure } * * } else if (msg.equals("SendToSelf")) { * // Send message to the actor itself recursively - * getContext().sendOneWay(msg) + * getContext().tell(msg) * * } else if (msg.equals("ForwardMessage")) { * // Retreive an actor from the ActorRegistry by ID and get an ActorRef back @@ -46,7 +46,7 @@ import akka.japi.{ Creator, Procedure } * public static void main(String[] args) { * ActorRef actor = Actors.actorOf(SampleUntypedActor.class); * actor.start(); - * actor.sendOneWay("SendToSelf"); + * actor.tell("SendToSelf"); * actor.stop(); * } * } diff --git a/akka-camel/src/test/scala/akka/camel/UntypedProducerFeatureTest.scala b/akka-camel/src/test/scala/akka/camel/UntypedProducerFeatureTest.scala index 96510ad415..4a5dfdca0c 100644 --- a/akka-camel/src/test/scala/akka/camel/UntypedProducerFeatureTest.scala +++ b/akka-camel/src/test/scala/akka/camel/UntypedProducerFeatureTest.scala @@ -69,7 +69,7 @@ class UntypedProducerFeatureTest extends FeatureSpec with BeforeAndAfterAll with when("a test message is sent to the producer with !") mockEndpoint.expectedBodiesReceived("received test") - val result = producer.sendOneWay(Message("test"), producer) + val result = producer.tell(Message("test"), producer) then("a normal response should have been sent") mockEndpoint.assertIsSatisfied diff --git a/akka-cluster/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala b/akka-cluster/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala index 015ccde474..b5ebf69062 100644 --- a/akka-cluster/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala +++ b/akka-cluster/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala @@ -283,7 +283,7 @@ abstract class RemoteClient private[akka] ( while (pendingRequest ne null) { val (isOneWay, futureUuid, message) = pendingRequest if (isOneWay) { - // sendOneWay + // tell val future = currentChannel.write(RemoteEncoder.encode(message)) future.awaitUninterruptibly() if (!future.isCancelled && !future.isSuccess) { diff --git a/akka-docs/intro/getting-started-first-java.rst b/akka-docs/intro/getting-started-first-java.rst index 17cab7cf41..43bb638bfa 100644 --- a/akka-docs/intro/getting-started-first-java.rst +++ b/akka-docs/intro/getting-started-first-java.rst @@ -456,14 +456,14 @@ Let's capture this in code:: if (message instanceof Calculate) { // schedule work for (int start = 0; start < nrOfMessages; start++) { - router.sendOneWay(new Work(start, nrOfElements), getContext()); + router.tell(new Work(start, nrOfElements), getContext()); } // send a PoisonPill to all workers telling them to shut down themselves - router.sendOneWay(new Broadcast(poisonPill())); + router.tell(new Broadcast(poisonPill())); // send a PoisonPill to the router, telling him to shut himself down - router.sendOneWay(poisonPill()); + router.tell(poisonPill()); } else if (message instanceof Result) { @@ -502,7 +502,7 @@ Now the only thing that is left to implement is the runner that should bootstrap }).start(); // start the calculation - master.sendOneWay(new Calculate()); + master.tell(new Calculate()); // wait for master to shut down latch.await(); @@ -646,14 +646,14 @@ Before we package it up and run it, let's take a look at the full code now, with if (message instanceof Calculate) { // schedule work for (int start = 0; start < nrOfMessages; start++) { - router.sendOneWay(new Work(start, nrOfElements), getContext()); + router.tell(new Work(start, nrOfElements), getContext()); } // send a PoisonPill to all workers telling them to shut down themselves - router.sendOneWay(new Broadcast(poisonPill())); + router.tell(new Broadcast(poisonPill())); // send a PoisonPill to the router, telling him to shut himself down - router.sendOneWay(poisonPill()); + router.tell(poisonPill()); } else if (message instanceof Result) { @@ -698,7 +698,7 @@ Before we package it up and run it, let's take a look at the full code now, with }).start(); // start the calculation - master.sendOneWay(new Calculate()); + master.tell(new Calculate()); // wait for master to shut down latch.await(); diff --git a/akka-docs/java/dataflow.rst b/akka-docs/java/dataflow.rst index 901fdb2e38..fc2121792a 100644 --- a/akka-docs/java/dataflow.rst +++ b/akka-docs/java/dataflow.rst @@ -81,7 +81,7 @@ You can also set the thread to a reference to be able to control its life-cycle: ... // time passes - t.sendOneWay(new Exit()); // shut down the thread + t.tell(new Exit()); // shut down the thread Examples -------- @@ -190,6 +190,6 @@ Example in Akka: }); // shut down the threads - main.sendOneWay(new Exit()); - setY.sendOneWay(new Exit()); - setV.sendOneWay(new Exit()); + main.tell(new Exit()); + setY.tell(new Exit()); + setV.tell(new Exit()); diff --git a/akka-docs/java/dispatchers.rst b/akka-docs/java/dispatchers.rst index e8b1e9ee04..3af53cfa6b 100644 --- a/akka-docs/java/dispatchers.rst +++ b/akka-docs/java/dispatchers.rst @@ -176,13 +176,13 @@ Creating a PriorityDispatcher using PriorityGenerator: ref.start(); // Start the actor ref.getDispatcher().suspend(ref); // Suspending the actor so it doesn't start to treat the messages before we have enqueued all of them :-) - ref.sendOneWay("lowpriority"); - ref.sendOneWay("lowpriority"); - ref.sendOneWay("highpriority"); - ref.sendOneWay("pigdog"); - ref.sendOneWay("pigdog2"); - ref.sendOneWay("pigdog3"); - ref.sendOneWay("highpriority"); + ref.tell("lowpriority"); + ref.tell("lowpriority"); + ref.tell("highpriority"); + ref.tell("pigdog"); + ref.tell("pigdog2"); + ref.tell("pigdog3"); + ref.tell("highpriority"); ref.getDispatcher().resume(ref); // Resuming the actor so it will start treating its messages } } diff --git a/akka-docs/java/fault-tolerance.rst b/akka-docs/java/fault-tolerance.rst index 087f6cb0be..2b11a2425b 100644 --- a/akka-docs/java/fault-tolerance.rst +++ b/akka-docs/java/fault-tolerance.rst @@ -250,7 +250,7 @@ A child actor can tell the supervising actor to unlink him by sending him the 'U .. code-block:: java ActorRef supervisor = getContext().getSupervisor(); - if (supervisor != null) supervisor.sendOneWay(new Unlink(getContext())) + if (supervisor != null) supervisor.tell(new Unlink(getContext())) The supervising actor's side of things ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/akka-docs/java/futures.rst b/akka-docs/java/futures.rst index 91fc62cd4d..8eb3d37758 100644 --- a/akka-docs/java/futures.rst +++ b/akka-docs/java/futures.rst @@ -15,7 +15,7 @@ In Akka, a `Future `_ is a da Use with Actors --------------- -There are generally two ways of getting a reply from an ``UntypedActor``: the first is by a sent message (``actorRef.sendOneWay(msg);``), which only works if the original sender was an ``UntypedActor``) and the second is through a ``Future``. +There are generally two ways of getting a reply from an ``UntypedActor``: the first is by a sent message (``actorRef.tell(msg);``), which only works if the original sender was an ``UntypedActor``) and the second is through a ``Future``. Using the ``ActorRef``\'s ``ask`` method to send a message will return a Future. To wait for and retrieve the actual result the simplest method is: diff --git a/akka-docs/java/remote-actors.rst b/akka-docs/java/remote-actors.rst index 8eb5573e16..d08e72b0b9 100644 --- a/akka-docs/java/remote-actors.rst +++ b/akka-docs/java/remote-actors.rst @@ -625,7 +625,7 @@ Using the generated message builder to send the message to a remote actor: .. code-block:: java - actor.sendOneWay(ProtobufPOJO.newBuilder() + actor.tell(ProtobufPOJO.newBuilder() .setId(11) .setStatus(true) .setName("Coltrane") diff --git a/akka-docs/java/routing.rst b/akka-docs/java/routing.rst index bf4af356a3..56b549a24a 100644 --- a/akka-docs/java/routing.rst +++ b/akka-docs/java/routing.rst @@ -39,8 +39,8 @@ An UntypedDispatcher is an actor that routes incoming messages to outbound actor } ActorRef router = actorOf(MyRouter.class).start(); - router.sendOneWay("Ping"); //Prints "Pinger: Ping" - router.sendOneWay("Pong"); //Prints "Ponger: Pong" + router.tell("Ping"); //Prints "Pinger: Ping" + router.tell("Pong"); //Prints "Ponger: Pong" UntypedLoadBalancer ------------------- @@ -81,14 +81,14 @@ An UntypedLoadBalancer is an actor that forwards messages it receives to a bound } ActorRef balancer = actorOf(MyLoadBalancer.class).start(); - balancer.sendOneWay("Pong"); //Prints "Pinger: Pong" - balancer.sendOneWay("Ping"); //Prints "Ponger: Ping" - balancer.sendOneWay("Ping"); //Prints "Pinger: Ping" - balancer.sendOneWay("Pong"); //Prints "Ponger: Pong + balancer.tell("Pong"); //Prints "Pinger: Pong" + balancer.tell("Ping"); //Prints "Ponger: Ping" + balancer.tell("Ping"); //Prints "Pinger: Ping" + balancer.tell("Pong"); //Prints "Ponger: Pong You can also send a 'new Routing.Broadcast(msg)' message to the router to have it be broadcasted out to all the actors it represents. .. code-block:: java - balancer.sendOneWay(new Routing.Broadcast(new PoisonPill())); + balancer.tell(new Routing.Broadcast(new PoisonPill())); diff --git a/akka-docs/java/stm.rst b/akka-docs/java/stm.rst index ebdd553465..eef1aae61a 100644 --- a/akka-docs/java/stm.rst +++ b/akka-docs/java/stm.rst @@ -305,7 +305,7 @@ Here is an example of using ``retry`` to block until an account has enough money ActorRef transferer = Actors.actorOf(Transferer.class).start(); - transferer.sendOneWay(new Transfer(account1, account2, 500.0)); + transferer.tell(new Transfer(account1, account2, 500.0)); // Transferer: not enough money - retrying new Atomic() { @@ -428,7 +428,7 @@ You can also have two alternative blocking transactions, one of which can succee ActorRef brancher = Actors.actorOf(Brancher.class).start(); - brancher.sendOneWay(new Branch(left, right, 500)); + brancher.tell(new Branch(left, right, 500)); // not enough on left - retrying // not enough on right - retrying diff --git a/akka-docs/java/transactors.rst b/akka-docs/java/transactors.rst index 3655bd290f..32e1890231 100644 --- a/akka-docs/java/transactors.rst +++ b/akka-docs/java/transactors.rst @@ -86,7 +86,7 @@ Here is an example of coordinating two simple counter UntypedActors so that they if (message instanceof Increment) { Increment increment = (Increment) message; if (increment.hasFriend()) { - increment.getFriend().sendOneWay(coordinated.coordinate(new Increment())); + increment.getFriend().tell(coordinated.coordinate(new Increment())); } coordinated.atomic(new Atomically() { public void atomically() { @@ -105,7 +105,7 @@ Here is an example of coordinating two simple counter UntypedActors so that they ActorRef counter1 = actorOf(Counter.class).start(); ActorRef counter2 = actorOf(Counter.class).start(); - counter1.sendOneWay(new Coordinated(new Increment(counter2))); + counter1.tell(new Coordinated(new Increment(counter2))); To start a new coordinated transaction that you will also participate in, just create a ``Coordinated`` object: @@ -117,13 +117,13 @@ To start a coordinated transaction that you won't participate in yourself you ca .. code-block:: java - actor.sendOneWay(new Coordinated(new Message())); + actor.tell(new Coordinated(new Message())); To include another actor in the same coordinated transaction that you've created or received, use the ``coordinate`` method on that object. This will increment the number of parties involved by one and create a new ``Coordinated`` object to be sent. .. code-block:: java - actor.sendOneWay(coordinated.coordinate(new Message())); + actor.tell(coordinated.coordinate(new Message())); To enter the coordinated transaction use the atomic method of the coordinated object. This accepts either an ``akka.transactor.Atomically`` object, or an ``Atomic`` object the same as used normally in the STM (just don't execute it - the coordination will do that). diff --git a/akka-docs/java/untyped-actors.rst b/akka-docs/java/untyped-actors.rst index fd6912be11..5fbe3c7a81 100644 --- a/akka-docs/java/untyped-actors.rst +++ b/akka-docs/java/untyped-actors.rst @@ -107,7 +107,7 @@ Send messages ------------- Messages are sent to an Actor through one of the 'send' methods. -* 'sendOneWay' means “fire-and-forget”, e.g. send a message asynchronously and return immediately. +* 'tell' means “fire-and-forget”, e.g. send a message asynchronously and return immediately. * 'sendRequestReply' means “send-and-reply-eventually”, e.g. send a message asynchronously and wait for a reply through a Future. Here you can specify a timeout. Using timeouts is very important. If no timeout is specified then the actor’s default timeout (set by the 'getContext().setTimeout(..)' method in the 'ActorRef') is used. This method throws an 'ActorTimeoutException' if the call timed out. * 'ask' sends a message asynchronously and returns a 'Future'. @@ -120,13 +120,13 @@ This is the preferred way of sending messages. No blocking waiting for a message .. code-block:: java - actor.sendOneWay("Hello"); + actor.tell("Hello"); Or with the sender reference passed along: .. code-block:: java - actor.sendOneWay("Hello", getContext()); + actor.tell("Hello", getContext()); If invoked from within an Actor, then the sending actor reference will be implicitly passed along with the message and available to the receiving Actor in its 'getContext().getSender();' method. He can use this to reply to the original sender or use the 'getContext().reply(message);' method. @@ -231,7 +231,7 @@ Reply using the channel If you want to have a handle to an object to whom you can reply to the message, you can use the Channel abstraction. Simply call getContext().channel() and then you can forward that to others, store it away or otherwise until you want to reply, -which you do by Channel.sendOneWay(msg) +which you do by Channel.tell(msg) .. code-block:: java @@ -240,7 +240,7 @@ which you do by Channel.sendOneWay(msg) String msg = (String)message; if (msg.equals("Hello")) { // Reply to original sender of message using the channel - getContext().channel().sendOneWaySafe(msg + " from " + getContext().getUuid()); + getContext().channel().tellSafe(msg + " from " + getContext().getUuid()); } } } @@ -373,7 +373,7 @@ Use it like this: import static akka.actor.Actors.*; - actor.sendOneWay(poisonPill()); + actor.tell(poisonPill()); Killing an Actor ---------------- @@ -387,7 +387,7 @@ Use it like this: import static akka.actor.Actors.*; // kill the actor called 'victim' - victim.sendOneWay(kill()); + victim.tell(kill()); Actor life-cycle ---------------- diff --git a/akka-docs/modules/camel.rst b/akka-docs/modules/camel.rst index b1bf200e91..63f5ea437e 100644 --- a/akka-docs/modules/camel.rst +++ b/akka-docs/modules/camel.rst @@ -1047,7 +1047,7 @@ used. Message response = (Message)producer.sendRequestReply("akka rocks"); String body = response.getBodyAs(String.class) -If the message is sent using the ! operator (or the sendOneWay method in Java) +If the message is sent using the ! operator (or the tell method in Java) then the response message is sent back asynchronously to the original sender. In the following example, a Sender actor sends a message (a String) to a producer actor using the ! operator and asynchronously receives a response (of type diff --git a/akka-spring/src/test/scala/DispatcherSpringFeatureTest.scala b/akka-spring/src/test/scala/DispatcherSpringFeatureTest.scala index ad33910e1d..002ebbe123 100644 --- a/akka-spring/src/test/scala/DispatcherSpringFeatureTest.scala +++ b/akka-spring/src/test/scala/DispatcherSpringFeatureTest.scala @@ -111,7 +111,7 @@ class DispatcherSpringFeatureTest extends FeatureSpec with ShouldMatchers { val actorRef = context.getBean("untyped-actor-with-thread-based-dispatcher").asInstanceOf[ActorRef] assert(actorRef.getActorClassName() === "akka.spring.foo.PingActor") actorRef.start() - actorRef.sendOneWay("Hello") + actorRef.tell("Hello") assert(actorRef.getDispatcher.isInstanceOf[ThreadBasedDispatcher]) } } diff --git a/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala b/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala index fa5b2c3572..8e32da1925 100644 --- a/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala +++ b/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala @@ -49,7 +49,7 @@ class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with scenario("get a untyped actor") { val myactor = getPingActorFromContext("/untyped-actor-config.xml", "simple-untyped-actor") - myactor.sendOneWay("Hello") + myactor.tell("Hello") PingActor.latch.await assert(PingActor.lastMessage === "Hello") assert(myactor.isDefinedAt("some string message")) @@ -57,7 +57,7 @@ class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with scenario("untyped-actor of provided bean") { val myactor = getPingActorFromContext("/untyped-actor-config.xml", "simple-untyped-actor-of-bean") - myactor.sendOneWay("Hello") + myactor.tell("Hello") PingActor.latch.await assert(PingActor.lastMessage === "Hello") assert(myactor.isDefinedAt("some string message")) @@ -66,14 +66,14 @@ class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with scenario("untyped-actor with timeout") { val myactor = getPingActorFromContext("/untyped-actor-config.xml", "simple-untyped-actor-long-timeout") assert(myactor.getTimeout() === 10000) - myactor.sendOneWay("Hello 2") + myactor.tell("Hello 2") PingActor.latch.await assert(PingActor.lastMessage === "Hello 2") } scenario("get a remote typed-actor") { val myactor = getPingActorFromContext("/untyped-actor-config.xml", "remote-untyped-actor") - myactor.sendOneWay("Hello 4") + myactor.tell("Hello 4") assert(myactor.homeAddress.isDefined) assert(myactor.homeAddress.get.getHostName() === "localhost") assert(myactor.homeAddress.get.getPort() === 9990) @@ -86,14 +86,14 @@ class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with assert(myactor.id === "untyped-actor-with-dispatcher") assert(myactor.getTimeout() === 1000) assert(myactor.getDispatcher.isInstanceOf[ExecutorBasedEventDrivenWorkStealingDispatcher]) - myactor.sendOneWay("Hello 5") + myactor.tell("Hello 5") PingActor.latch.await assert(PingActor.lastMessage === "Hello 5") } scenario("create client managed remote untyped-actor") { val myactor = getPingActorFromContext("/server-managed-config.xml", "client-managed-remote-untyped-actor") - myactor.sendOneWay("Hello client managed remote untyped-actor") + myactor.tell("Hello client managed remote untyped-actor") PingActor.latch.await assert(PingActor.lastMessage === "Hello client managed remote untyped-actor") assert(myactor.homeAddress.isDefined) @@ -112,7 +112,7 @@ class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with val myactor = getPingActorFromContext("/server-managed-config.xml", "server-managed-remote-untyped-actor") val nrOfActors = Actor.registry.actors.length val actorRef = remote.actorFor("server-managed-remote-untyped-actor", "localhost", 9990) - actorRef.sendOneWay("Hello server managed remote untyped-actor") + actorRef.tell("Hello server managed remote untyped-actor") PingActor.latch.await assert(PingActor.lastMessage === "Hello server managed remote untyped-actor") assert(Actor.registry.actors.length === nrOfActors) @@ -122,7 +122,7 @@ class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with val myactor = getPingActorFromContext("/server-managed-config.xml", "server-managed-remote-untyped-actor-custom-id") val nrOfActors = Actor.registry.actors.length val actorRef = remote.actorFor("ping-service", "localhost", 9990) - actorRef.sendOneWay("Hello server managed remote untyped-actor") + actorRef.tell("Hello server managed remote untyped-actor") PingActor.latch.await assert(PingActor.lastMessage === "Hello server managed remote untyped-actor") assert(Actor.registry.actors.length === nrOfActors) @@ -138,7 +138,7 @@ class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with // get client actor ref from spring context val actorRef = context.getBean("client-1").asInstanceOf[ActorRef] assert(actorRef.isInstanceOf[RemoteActorRef]) - actorRef.sendOneWay("Hello") + actorRef.tell("Hello") PingActor.latch.await assert(Actor.registry.actors.length === nrOfActors) } diff --git a/akka-stm/src/main/scala/akka/transactor/UntypedTransactor.scala b/akka-stm/src/main/scala/akka/transactor/UntypedTransactor.scala index aac2e55908..39a29c24b8 100644 --- a/akka-stm/src/main/scala/akka/transactor/UntypedTransactor.scala +++ b/akka-stm/src/main/scala/akka/transactor/UntypedTransactor.scala @@ -31,7 +31,7 @@ abstract class UntypedTransactor extends UntypedActor { case coordinated @ Coordinated(message) ⇒ { val others = coordinate(message) for (sendTo ← others) { - sendTo.actor.sendOneWay(coordinated(sendTo.message.getOrElse(message))) + sendTo.actor.tell(coordinated(sendTo.message.getOrElse(message))) } before(message) coordinated.atomic(txFactory) { atomically(message) } diff --git a/akka-stm/src/test/java/akka/stm/example/EitherOrElseExample.java b/akka-stm/src/test/java/akka/stm/example/EitherOrElseExample.java index 0e0345b6af..75ce56c4fe 100644 --- a/akka-stm/src/test/java/akka/stm/example/EitherOrElseExample.java +++ b/akka-stm/src/test/java/akka/stm/example/EitherOrElseExample.java @@ -14,7 +14,7 @@ public class EitherOrElseExample { ActorRef brancher = Actors.actorOf(Brancher.class).start(); - brancher.sendOneWay(new Branch(left, right, 500)); + brancher.tell(new Branch(left, right, 500)); new Atomic() { public Object atomically() { diff --git a/akka-stm/src/test/java/akka/stm/example/RetryExample.java b/akka-stm/src/test/java/akka/stm/example/RetryExample.java index 6fe3e3f535..3d32ecf727 100644 --- a/akka-stm/src/test/java/akka/stm/example/RetryExample.java +++ b/akka-stm/src/test/java/akka/stm/example/RetryExample.java @@ -14,7 +14,7 @@ public class RetryExample { ActorRef transferer = Actors.actorOf(Transferer.class).start(); - transferer.sendOneWay(new Transfer(account1, account2, 500.0)); + transferer.tell(new Transfer(account1, account2, 500.0)); // Transferer: not enough money - retrying new Atomic() { diff --git a/akka-stm/src/test/java/akka/transactor/example/UntypedCoordinatedCounter.java b/akka-stm/src/test/java/akka/transactor/example/UntypedCoordinatedCounter.java index 167db3a3c4..6e78e8ea43 100644 --- a/akka-stm/src/test/java/akka/transactor/example/UntypedCoordinatedCounter.java +++ b/akka-stm/src/test/java/akka/transactor/example/UntypedCoordinatedCounter.java @@ -21,7 +21,7 @@ public class UntypedCoordinatedCounter extends UntypedActor { if (message instanceof Increment) { Increment increment = (Increment) message; if (increment.hasFriend()) { - increment.getFriend().sendOneWay(coordinated.coordinate(new Increment())); + increment.getFriend().tell(coordinated.coordinate(new Increment())); } coordinated.atomic(new Atomically() { public void atomically() { diff --git a/akka-stm/src/test/java/akka/transactor/example/UntypedCoordinatedExample.java b/akka-stm/src/test/java/akka/transactor/example/UntypedCoordinatedExample.java index f3ac18fb73..ac659405ce 100644 --- a/akka-stm/src/test/java/akka/transactor/example/UntypedCoordinatedExample.java +++ b/akka-stm/src/test/java/akka/transactor/example/UntypedCoordinatedExample.java @@ -15,7 +15,7 @@ public class UntypedCoordinatedExample { ActorRef counter1 = Actors.actorOf(UntypedCoordinatedCounter.class).start(); ActorRef counter2 = Actors.actorOf(UntypedCoordinatedCounter.class).start(); - counter1.sendOneWay(new Coordinated(new Increment(counter2))); + counter1.tell(new Coordinated(new Increment(counter2))); Thread.sleep(3000); diff --git a/akka-stm/src/test/java/akka/transactor/example/UntypedTransactorExample.java b/akka-stm/src/test/java/akka/transactor/example/UntypedTransactorExample.java index 34e2e2edec..42970b88f0 100644 --- a/akka-stm/src/test/java/akka/transactor/example/UntypedTransactorExample.java +++ b/akka-stm/src/test/java/akka/transactor/example/UntypedTransactorExample.java @@ -14,7 +14,7 @@ public class UntypedTransactorExample { ActorRef counter1 = Actors.actorOf(UntypedCounter.class).start(); ActorRef counter2 = Actors.actorOf(UntypedCounter.class).start(); - counter1.sendOneWay(new Increment(counter2)); + counter1.tell(new Increment(counter2)); Thread.sleep(3000); diff --git a/akka-stm/src/test/java/akka/transactor/test/UntypedCoordinatedCounter.java b/akka-stm/src/test/java/akka/transactor/test/UntypedCoordinatedCounter.java index 24a720dba8..99f0cd19fe 100644 --- a/akka-stm/src/test/java/akka/transactor/test/UntypedCoordinatedCounter.java +++ b/akka-stm/src/test/java/akka/transactor/test/UntypedCoordinatedCounter.java @@ -40,7 +40,7 @@ public class UntypedCoordinatedCounter extends UntypedActor { final CountDownLatch latch = increment.getLatch(); if (!friends.isEmpty()) { Increment coordMessage = new Increment(friends.subList(1, friends.size()), latch); - friends.get(0).sendOneWay(coordinated.coordinate(coordMessage)); + friends.get(0).tell(coordinated.coordinate(coordMessage)); } coordinated.atomic(new Atomically(txFactory) { public void atomically() { diff --git a/akka-stm/src/test/java/akka/transactor/test/UntypedCoordinatedIncrementTest.java b/akka-stm/src/test/java/akka/transactor/test/UntypedCoordinatedIncrementTest.java index 84773d7d5d..df969c2b27 100644 --- a/akka-stm/src/test/java/akka/transactor/test/UntypedCoordinatedIncrementTest.java +++ b/akka-stm/src/test/java/akka/transactor/test/UntypedCoordinatedIncrementTest.java @@ -44,7 +44,7 @@ public class UntypedCoordinatedIncrementTest { @Test public void incrementAllCountersWithSuccessfulTransaction() { CountDownLatch incrementLatch = new CountDownLatch(numCounters); Increment message = new Increment(counters.subList(1, counters.size()), incrementLatch); - counters.get(0).sendOneWay(new Coordinated(message)); + counters.get(0).tell(new Coordinated(message)); try { incrementLatch.await(timeout, TimeUnit.SECONDS); } catch (InterruptedException exception) {} @@ -67,7 +67,7 @@ public class UntypedCoordinatedIncrementTest { List actors = new ArrayList(counters); actors.add(failer); Increment message = new Increment(actors.subList(1, actors.size()), incrementLatch); - actors.get(0).sendOneWay(new Coordinated(message)); + actors.get(0).tell(new Coordinated(message)); try { incrementLatch.await(timeout, TimeUnit.SECONDS); } catch (InterruptedException exception) {} diff --git a/akka-stm/src/test/java/akka/transactor/test/UntypedTransactorTest.java b/akka-stm/src/test/java/akka/transactor/test/UntypedTransactorTest.java index 97446d2cda..fb4cb5c0d5 100644 --- a/akka-stm/src/test/java/akka/transactor/test/UntypedTransactorTest.java +++ b/akka-stm/src/test/java/akka/transactor/test/UntypedTransactorTest.java @@ -43,7 +43,7 @@ public class UntypedTransactorTest { @Test public void incrementAllCountersWithSuccessfulTransaction() { CountDownLatch incrementLatch = new CountDownLatch(numCounters); Increment message = new Increment(counters.subList(1, counters.size()), incrementLatch); - counters.get(0).sendOneWay(message); + counters.get(0).tell(message); try { incrementLatch.await(timeout, TimeUnit.SECONDS); } catch (InterruptedException exception) {} @@ -66,7 +66,7 @@ public class UntypedTransactorTest { List actors = new ArrayList(counters); actors.add(failer); Increment message = new Increment(actors.subList(1, actors.size()), incrementLatch); - actors.get(0).sendOneWay(message); + actors.get(0).tell(message); try { incrementLatch.await(timeout, TimeUnit.SECONDS); } catch (InterruptedException exception) {} diff --git a/akka-tutorials/akka-tutorial-first/src/main/java/akka/tutorial/first/java/Pi.java b/akka-tutorials/akka-tutorial-first/src/main/java/akka/tutorial/first/java/Pi.java index 338133b38b..0442fabc45 100644 --- a/akka-tutorials/akka-tutorial-first/src/main/java/akka/tutorial/first/java/Pi.java +++ b/akka-tutorials/akka-tutorial-first/src/main/java/akka/tutorial/first/java/Pi.java @@ -117,14 +117,14 @@ public class Pi { if (message instanceof Calculate) { // schedule work for (int start = 0; start < nrOfMessages; start++) { - router.sendOneWay(new Work(start, nrOfElements), getContext()); + router.tell(new Work(start, nrOfElements), getContext()); } // send a PoisonPill to all workers telling them to shut down themselves - router.sendOneWay(new Broadcast(poisonPill())); + router.tell(new Broadcast(poisonPill())); // send a PoisonPill to the router, telling him to shut himself down - router.sendOneWay(poisonPill()); + router.tell(poisonPill()); } else if (message instanceof Result) { @@ -169,7 +169,7 @@ public class Pi { }, "master").start(); // start the calculation - master.sendOneWay(new Calculate()); + master.tell(new Calculate()); // wait for master to shut down latch.await(); diff --git a/akka-tutorials/akka-tutorial-second/src/main/java/akka/tutorial/java/second/Pi.java b/akka-tutorials/akka-tutorial-second/src/main/java/akka/tutorial/java/second/Pi.java index 9fb2343b63..2dc7da4399 100644 --- a/akka-tutorials/akka-tutorial-second/src/main/java/akka/tutorial/java/second/Pi.java +++ b/akka-tutorials/akka-tutorial-second/src/main/java/akka/tutorial/java/second/Pi.java @@ -119,7 +119,7 @@ public class Pi { public void apply(Object msg) { // schedule work for (int arg = 0; arg < nrOfMessages; arg++) { - router.sendOneWay(new Work(arg, nrOfElements), getContext()); + router.tell(new Work(arg, nrOfElements), getContext()); } // Assume the gathering behavior become(gather(getContext().getChannel())); @@ -135,7 +135,7 @@ public class Pi { nrOfResults += 1; if (nrOfResults == nrOfMessages) { // send the pi result back to the guy who started the calculation - recipient.sendOneWay(pi); + recipient.tell(pi); // shut ourselves down, we're done getContext().stop(); } @@ -146,9 +146,9 @@ public class Pi { @Override public void postStop() { // send a PoisonPill to all workers telling them to shut down themselves - router.sendOneWay(new Broadcast(poisonPill())); + router.tell(new Broadcast(poisonPill())); // send a PoisonPill to the router, telling him to shut himself down - router.sendOneWay(poisonPill()); + router.tell(poisonPill()); } }