Renaming sendOneWay to tell, closing ticket #1072

This commit is contained in:
Viktor Klang 2011-08-01 17:07:12 +02:00
parent 29ca6a867b
commit 04729bcbc3
32 changed files with 94 additions and 94 deletions

View file

@ -36,7 +36,7 @@ class DispatcherActorSpec extends JUnitSuite {
private val unit = TimeUnit.MILLISECONDS private val unit = TimeUnit.MILLISECONDS
@Test @Test
def shouldSendOneWay = { def shouldTell = {
val actor = actorOf[OneWayTestActor].start() val actor = actorOf[OneWayTestActor].start()
val result = actor ! "OneWay" val result = actor ! "OneWay"
assert(OneWayTestActor.oneWay.await(1, TimeUnit.SECONDS)) assert(OneWayTestActor.oneWay.await(1, TimeUnit.SECONDS))

View file

@ -41,7 +41,7 @@ class PinnedActorSpec extends JUnitSuite {
} }
@Test @Test
def shouldSendOneWay { def shouldTell {
var oneWay = new CountDownLatch(1) var oneWay = new CountDownLatch(1)
val actor = actorOf(new Actor { val actor = actorOf(new Actor {
self.dispatcher = Dispatchers.newPinnedDispatcher(self) self.dispatcher = Dispatchers.newPinnedDispatcher(self)

View file

@ -46,7 +46,7 @@ public class Actors {
* } * }
* }, "my-actor-address"); * }, "my-actor-address");
* actor.start(); * actor.start();
* actor.sendOneWay(message, context); * actor.tell(message, context);
* actor.stop(); * actor.stop();
* </pre> * </pre>
*/ */
@ -70,7 +70,7 @@ public class Actors {
* } * }
* }); * });
* actor.start(); * actor.start();
* actor.sendOneWay(message, context); * actor.tell(message, context);
* actor.stop(); * actor.stop();
* </pre> * </pre>
*/ */
@ -84,7 +84,7 @@ public class Actors {
* <pre> * <pre>
* ActorRef actor = Actors.actorOf(MyUntypedActor.class, "my-actor-address"); * ActorRef actor = Actors.actorOf(MyUntypedActor.class, "my-actor-address");
* actor.start(); * actor.start();
* actor.sendOneWay(message, context); * actor.tell(message, context);
* actor.stop(); * actor.stop();
* </pre> * </pre>
* You can create and start the actor in one statement like this: * You can create and start the actor in one statement like this:
@ -102,7 +102,7 @@ public class Actors {
* <pre> * <pre>
* ActorRef actor = Actors.actorOf(MyUntypedActor.class, "my-actor-address"); * ActorRef actor = Actors.actorOf(MyUntypedActor.class, "my-actor-address");
* actor.start(); * actor.start();
* actor.sendOneWay(message, context); * actor.tell(message, context);
* actor.stop(); * actor.stop();
* </pre> * </pre>
* You can create and start the actor in one statement like this: * 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. * The message that when sent to an Actor kills it by throwing an exception.
* <pre> * <pre>
* actor.sendOneWay(kill()); * actor.tell(kill());
* </pre> * </pre>
* @return the single instance of 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'. * The message that when sent to an Actor shuts it down by calling 'stop'.
* <pre> * <pre>
* actor.sendOneWay(poisonPill()); * actor.tell(poisonPill());
* </pre> * </pre>
* @return the single instance of PoisonPill * @return the single instance of PoisonPill
*/ */

View file

@ -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. * Sends a message asynchronously returns a future holding the eventual reply message.
* <p/> * <p/>
* <b>NOTE:</b> * <b>NOTE:</b>
* 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. * implement request/response message exchanges.
* <p/> * <p/>
* If you are sending messages using <code>ask</code> then you <b>have to</b> use <code>getContext().reply(..)</code> * If you are sending messages using <code>ask</code> then you <b>have to</b> use <code>getContext().reply(..)</code>

View file

@ -59,10 +59,10 @@ trait Channel[-T] {
* Java API.<p/> * Java API.<p/>
* Sends the specified message to the channel, i.e. fire-and-forget semantics.<p/> * Sends the specified message to the channel, i.e. fire-and-forget semantics.<p/>
* <pre> * <pre>
* actor.sendOneWay(message); * actor.tell(message);
* </pre> * </pre>
*/ */
def sendOneWay(msg: T): Unit = this.!(msg) def tell(msg: T): Unit = this.!(msg)
/** /**
* Java API. <p/> * Java API. <p/>
@ -70,19 +70,19 @@ trait Channel[-T] {
* semantics, including the sender reference if possible (not supported on * semantics, including the sender reference if possible (not supported on
* all channels).<p/> * all channels).<p/>
* <pre> * <pre>
* actor.sendOneWay(message, context); * actor.tell(message, context);
* </pre> * </pre>
*/ */
def sendOneWay(msg: T, sender: UntypedChannel): Unit = this.!(msg)(sender) def tell(msg: T, sender: UntypedChannel): Unit = this.!(msg)(sender)
/** /**
* Java API.<p/> * Java API.<p/>
* Try to send the specified message to the channel, i.e. fire-and-forget semantics.<p/> * Try to send the specified message to the channel, i.e. fire-and-forget semantics.<p/>
* <pre> * <pre>
* actor.sendOneWay(message); * actor.tell(message);
* </pre> * </pre>
*/ */
def sendOneWaySafe(msg: T): Boolean = this.safe_!(msg) def tellSafe(msg: T): Boolean = this.safe_!(msg)
/** /**
* Java API. <p/> * Java API. <p/>
@ -90,10 +90,10 @@ trait Channel[-T] {
* semantics, including the sender reference if possible (not supported on * semantics, including the sender reference if possible (not supported on
* all channels).<p/> * all channels).<p/>
* <pre> * <pre>
* actor.sendOneWay(message, context); * actor.tell(message, context);
* </pre> * </pre>
*/ */
def sendOneWaySafe(msg: T, sender: UntypedChannel): Boolean = this.safe_!(msg)(sender) def tellSafe(msg: T, sender: UntypedChannel): Boolean = this.safe_!(msg)(sender)
} }

View file

@ -25,7 +25,7 @@ import akka.japi.{ Creator, Procedure }
* } else if (msg.equals("UseSender") && getContext().getSender().isDefined()) { * } else if (msg.equals("UseSender") && getContext().getSender().isDefined()) {
* // Reply to original sender of message using the sender reference * // Reply to original sender of message using the sender reference
* // also passing along my own reference (the context) * // 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()) { * } else if (msg.equals("UseSenderFuture") && getContext().getSenderFuture().isDefined()) {
* // Reply to original sender of message using the sender future reference * // 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")) { * } else if (msg.equals("SendToSelf")) {
* // Send message to the actor itself recursively * // Send message to the actor itself recursively
* getContext().sendOneWay(msg) * getContext().tell(msg)
* *
* } else if (msg.equals("ForwardMessage")) { * } else if (msg.equals("ForwardMessage")) {
* // Retreive an actor from the ActorRegistry by ID and get an ActorRef back * // 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) { * public static void main(String[] args) {
* ActorRef actor = Actors.actorOf(SampleUntypedActor.class); * ActorRef actor = Actors.actorOf(SampleUntypedActor.class);
* actor.start(); * actor.start();
* actor.sendOneWay("SendToSelf"); * actor.tell("SendToSelf");
* actor.stop(); * actor.stop();
* } * }
* } * }

View file

@ -69,7 +69,7 @@ class UntypedProducerFeatureTest extends FeatureSpec with BeforeAndAfterAll with
when("a test message is sent to the producer with !") when("a test message is sent to the producer with !")
mockEndpoint.expectedBodiesReceived("received test") 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") then("a normal response should have been sent")
mockEndpoint.assertIsSatisfied mockEndpoint.assertIsSatisfied

View file

@ -283,7 +283,7 @@ abstract class RemoteClient private[akka] (
while (pendingRequest ne null) { while (pendingRequest ne null) {
val (isOneWay, futureUuid, message) = pendingRequest val (isOneWay, futureUuid, message) = pendingRequest
if (isOneWay) { if (isOneWay) {
// sendOneWay // tell
val future = currentChannel.write(RemoteEncoder.encode(message)) val future = currentChannel.write(RemoteEncoder.encode(message))
future.awaitUninterruptibly() future.awaitUninterruptibly()
if (!future.isCancelled && !future.isSuccess) { if (!future.isCancelled && !future.isSuccess) {

View file

@ -456,14 +456,14 @@ Let's capture this in code::
if (message instanceof Calculate) { if (message instanceof Calculate) {
// schedule work // schedule work
for (int start = 0; start < nrOfMessages; start++) { 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 // 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 // send a PoisonPill to the router, telling him to shut himself down
router.sendOneWay(poisonPill()); router.tell(poisonPill());
} else if (message instanceof Result) { } 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();
// start the calculation // start the calculation
master.sendOneWay(new Calculate()); master.tell(new Calculate());
// wait for master to shut down // wait for master to shut down
latch.await(); 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) { if (message instanceof Calculate) {
// schedule work // schedule work
for (int start = 0; start < nrOfMessages; start++) { 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 // 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 // send a PoisonPill to the router, telling him to shut himself down
router.sendOneWay(poisonPill()); router.tell(poisonPill());
} else if (message instanceof Result) { } 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();
// start the calculation // start the calculation
master.sendOneWay(new Calculate()); master.tell(new Calculate());
// wait for master to shut down // wait for master to shut down
latch.await(); latch.await();

View file

@ -81,7 +81,7 @@ You can also set the thread to a reference to be able to control its life-cycle:
... // time passes ... // time passes
t.sendOneWay(new Exit()); // shut down the thread t.tell(new Exit()); // shut down the thread
Examples Examples
-------- --------
@ -190,6 +190,6 @@ Example in Akka:
}); });
// shut down the threads // shut down the threads
main.sendOneWay(new Exit()); main.tell(new Exit());
setY.sendOneWay(new Exit()); setY.tell(new Exit());
setV.sendOneWay(new Exit()); setV.tell(new Exit());

View file

@ -176,13 +176,13 @@ Creating a PriorityDispatcher using PriorityGenerator:
ref.start(); // Start the actor 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.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.tell("lowpriority");
ref.sendOneWay("lowpriority"); ref.tell("lowpriority");
ref.sendOneWay("highpriority"); ref.tell("highpriority");
ref.sendOneWay("pigdog"); ref.tell("pigdog");
ref.sendOneWay("pigdog2"); ref.tell("pigdog2");
ref.sendOneWay("pigdog3"); ref.tell("pigdog3");
ref.sendOneWay("highpriority"); ref.tell("highpriority");
ref.getDispatcher().resume(ref); // Resuming the actor so it will start treating its messages ref.getDispatcher().resume(ref); // Resuming the actor so it will start treating its messages
} }
} }

View file

@ -250,7 +250,7 @@ A child actor can tell the supervising actor to unlink him by sending him the 'U
.. code-block:: java .. code-block:: java
ActorRef supervisor = getContext().getSupervisor(); 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 The supervising actor's side of things
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -15,7 +15,7 @@ In Akka, a `Future <http://en.wikipedia.org/wiki/Futures_and_promises>`_ is a da
Use with Actors 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: 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:

View file

@ -625,7 +625,7 @@ Using the generated message builder to send the message to a remote actor:
.. code-block:: java .. code-block:: java
actor.sendOneWay(ProtobufPOJO.newBuilder() actor.tell(ProtobufPOJO.newBuilder()
.setId(11) .setId(11)
.setStatus(true) .setStatus(true)
.setName("Coltrane") .setName("Coltrane")

View file

@ -39,8 +39,8 @@ An UntypedDispatcher is an actor that routes incoming messages to outbound actor
} }
ActorRef router = actorOf(MyRouter.class).start(); ActorRef router = actorOf(MyRouter.class).start();
router.sendOneWay("Ping"); //Prints "Pinger: Ping" router.tell("Ping"); //Prints "Pinger: Ping"
router.sendOneWay("Pong"); //Prints "Ponger: Pong" router.tell("Pong"); //Prints "Ponger: Pong"
UntypedLoadBalancer UntypedLoadBalancer
------------------- -------------------
@ -81,14 +81,14 @@ An UntypedLoadBalancer is an actor that forwards messages it receives to a bound
} }
ActorRef balancer = actorOf(MyLoadBalancer.class).start(); ActorRef balancer = actorOf(MyLoadBalancer.class).start();
balancer.sendOneWay("Pong"); //Prints "Pinger: Pong" balancer.tell("Pong"); //Prints "Pinger: Pong"
balancer.sendOneWay("Ping"); //Prints "Ponger: Ping" balancer.tell("Ping"); //Prints "Ponger: Ping"
balancer.sendOneWay("Ping"); //Prints "Pinger: Ping" balancer.tell("Ping"); //Prints "Pinger: Ping"
balancer.sendOneWay("Pong"); //Prints "Ponger: Pong 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. 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 .. code-block:: java
balancer.sendOneWay(new Routing.Broadcast(new PoisonPill())); balancer.tell(new Routing.Broadcast(new PoisonPill()));

View file

@ -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(); 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 // Transferer: not enough money - retrying
new Atomic() { 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(); 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 left - retrying
// not enough on right - retrying // not enough on right - retrying

View file

@ -86,7 +86,7 @@ Here is an example of coordinating two simple counter UntypedActors so that they
if (message instanceof Increment) { if (message instanceof Increment) {
Increment increment = (Increment) message; Increment increment = (Increment) message;
if (increment.hasFriend()) { if (increment.hasFriend()) {
increment.getFriend().sendOneWay(coordinated.coordinate(new Increment())); increment.getFriend().tell(coordinated.coordinate(new Increment()));
} }
coordinated.atomic(new Atomically() { coordinated.atomic(new Atomically() {
public void 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 counter1 = actorOf(Counter.class).start();
ActorRef counter2 = 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: 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 .. 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. 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 .. 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). 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).

View file

@ -107,7 +107,7 @@ Send messages
------------- -------------
Messages are sent to an Actor through one of the 'send' methods. 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 actors default timeout (set by the 'getContext().setTimeout(..)' method in the 'ActorRef') is used. This method throws an 'ActorTimeoutException' if the call timed out. * '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 actors 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'. * '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 .. code-block:: java
actor.sendOneWay("Hello"); actor.tell("Hello");
Or with the sender reference passed along: Or with the sender reference passed along:
.. code-block:: java .. 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. 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. 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, 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 .. code-block:: java
@ -240,7 +240,7 @@ which you do by Channel.sendOneWay(msg)
String msg = (String)message; String msg = (String)message;
if (msg.equals("Hello")) { if (msg.equals("Hello")) {
// Reply to original sender of message using the channel // 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.*; import static akka.actor.Actors.*;
actor.sendOneWay(poisonPill()); actor.tell(poisonPill());
Killing an Actor Killing an Actor
---------------- ----------------
@ -387,7 +387,7 @@ Use it like this:
import static akka.actor.Actors.*; import static akka.actor.Actors.*;
// kill the actor called 'victim' // kill the actor called 'victim'
victim.sendOneWay(kill()); victim.tell(kill());
Actor life-cycle Actor life-cycle
---------------- ----------------

View file

@ -1047,7 +1047,7 @@ used.
Message response = (Message)producer.sendRequestReply("akka rocks"); Message response = (Message)producer.sendRequestReply("akka rocks");
String body = response.getBodyAs(String.class) 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 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 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 actor using the ! operator and asynchronously receives a response (of type

View file

@ -111,7 +111,7 @@ class DispatcherSpringFeatureTest extends FeatureSpec with ShouldMatchers {
val actorRef = context.getBean("untyped-actor-with-thread-based-dispatcher").asInstanceOf[ActorRef] val actorRef = context.getBean("untyped-actor-with-thread-based-dispatcher").asInstanceOf[ActorRef]
assert(actorRef.getActorClassName() === "akka.spring.foo.PingActor") assert(actorRef.getActorClassName() === "akka.spring.foo.PingActor")
actorRef.start() actorRef.start()
actorRef.sendOneWay("Hello") actorRef.tell("Hello")
assert(actorRef.getDispatcher.isInstanceOf[ThreadBasedDispatcher]) assert(actorRef.getDispatcher.isInstanceOf[ThreadBasedDispatcher])
} }
} }

View file

@ -49,7 +49,7 @@ class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with
scenario("get a untyped actor") { scenario("get a untyped actor") {
val myactor = getPingActorFromContext("/untyped-actor-config.xml", "simple-untyped-actor") val myactor = getPingActorFromContext("/untyped-actor-config.xml", "simple-untyped-actor")
myactor.sendOneWay("Hello") myactor.tell("Hello")
PingActor.latch.await PingActor.latch.await
assert(PingActor.lastMessage === "Hello") assert(PingActor.lastMessage === "Hello")
assert(myactor.isDefinedAt("some string message")) assert(myactor.isDefinedAt("some string message"))
@ -57,7 +57,7 @@ class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with
scenario("untyped-actor of provided bean") { scenario("untyped-actor of provided bean") {
val myactor = getPingActorFromContext("/untyped-actor-config.xml", "simple-untyped-actor-of-bean") val myactor = getPingActorFromContext("/untyped-actor-config.xml", "simple-untyped-actor-of-bean")
myactor.sendOneWay("Hello") myactor.tell("Hello")
PingActor.latch.await PingActor.latch.await
assert(PingActor.lastMessage === "Hello") assert(PingActor.lastMessage === "Hello")
assert(myactor.isDefinedAt("some string message")) assert(myactor.isDefinedAt("some string message"))
@ -66,14 +66,14 @@ class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with
scenario("untyped-actor with timeout") { scenario("untyped-actor with timeout") {
val myactor = getPingActorFromContext("/untyped-actor-config.xml", "simple-untyped-actor-long-timeout") val myactor = getPingActorFromContext("/untyped-actor-config.xml", "simple-untyped-actor-long-timeout")
assert(myactor.getTimeout() === 10000) assert(myactor.getTimeout() === 10000)
myactor.sendOneWay("Hello 2") myactor.tell("Hello 2")
PingActor.latch.await PingActor.latch.await
assert(PingActor.lastMessage === "Hello 2") assert(PingActor.lastMessage === "Hello 2")
} }
scenario("get a remote typed-actor") { scenario("get a remote typed-actor") {
val myactor = getPingActorFromContext("/untyped-actor-config.xml", "remote-untyped-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.isDefined)
assert(myactor.homeAddress.get.getHostName() === "localhost") assert(myactor.homeAddress.get.getHostName() === "localhost")
assert(myactor.homeAddress.get.getPort() === 9990) 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.id === "untyped-actor-with-dispatcher")
assert(myactor.getTimeout() === 1000) assert(myactor.getTimeout() === 1000)
assert(myactor.getDispatcher.isInstanceOf[ExecutorBasedEventDrivenWorkStealingDispatcher]) assert(myactor.getDispatcher.isInstanceOf[ExecutorBasedEventDrivenWorkStealingDispatcher])
myactor.sendOneWay("Hello 5") myactor.tell("Hello 5")
PingActor.latch.await PingActor.latch.await
assert(PingActor.lastMessage === "Hello 5") assert(PingActor.lastMessage === "Hello 5")
} }
scenario("create client managed remote untyped-actor") { scenario("create client managed remote untyped-actor") {
val myactor = getPingActorFromContext("/server-managed-config.xml", "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 PingActor.latch.await
assert(PingActor.lastMessage === "Hello client managed remote untyped-actor") assert(PingActor.lastMessage === "Hello client managed remote untyped-actor")
assert(myactor.homeAddress.isDefined) 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 myactor = getPingActorFromContext("/server-managed-config.xml", "server-managed-remote-untyped-actor")
val nrOfActors = Actor.registry.actors.length val nrOfActors = Actor.registry.actors.length
val actorRef = remote.actorFor("server-managed-remote-untyped-actor", "localhost", 9990) 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 PingActor.latch.await
assert(PingActor.lastMessage === "Hello server managed remote untyped-actor") assert(PingActor.lastMessage === "Hello server managed remote untyped-actor")
assert(Actor.registry.actors.length === nrOfActors) 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 myactor = getPingActorFromContext("/server-managed-config.xml", "server-managed-remote-untyped-actor-custom-id")
val nrOfActors = Actor.registry.actors.length val nrOfActors = Actor.registry.actors.length
val actorRef = remote.actorFor("ping-service", "localhost", 9990) 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 PingActor.latch.await
assert(PingActor.lastMessage === "Hello server managed remote untyped-actor") assert(PingActor.lastMessage === "Hello server managed remote untyped-actor")
assert(Actor.registry.actors.length === nrOfActors) assert(Actor.registry.actors.length === nrOfActors)
@ -138,7 +138,7 @@ class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with
// get client actor ref from spring context // get client actor ref from spring context
val actorRef = context.getBean("client-1").asInstanceOf[ActorRef] val actorRef = context.getBean("client-1").asInstanceOf[ActorRef]
assert(actorRef.isInstanceOf[RemoteActorRef]) assert(actorRef.isInstanceOf[RemoteActorRef])
actorRef.sendOneWay("Hello") actorRef.tell("Hello")
PingActor.latch.await PingActor.latch.await
assert(Actor.registry.actors.length === nrOfActors) assert(Actor.registry.actors.length === nrOfActors)
} }

View file

@ -31,7 +31,7 @@ abstract class UntypedTransactor extends UntypedActor {
case coordinated @ Coordinated(message) { case coordinated @ Coordinated(message) {
val others = coordinate(message) val others = coordinate(message)
for (sendTo others) { for (sendTo others) {
sendTo.actor.sendOneWay(coordinated(sendTo.message.getOrElse(message))) sendTo.actor.tell(coordinated(sendTo.message.getOrElse(message)))
} }
before(message) before(message)
coordinated.atomic(txFactory) { atomically(message) } coordinated.atomic(txFactory) { atomically(message) }

View file

@ -14,7 +14,7 @@ public class EitherOrElseExample {
ActorRef brancher = Actors.actorOf(Brancher.class).start(); ActorRef brancher = Actors.actorOf(Brancher.class).start();
brancher.sendOneWay(new Branch(left, right, 500)); brancher.tell(new Branch(left, right, 500));
new Atomic() { new Atomic() {
public Object atomically() { public Object atomically() {

View file

@ -14,7 +14,7 @@ public class RetryExample {
ActorRef transferer = Actors.actorOf(Transferer.class).start(); 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 // Transferer: not enough money - retrying
new Atomic() { new Atomic() {

View file

@ -21,7 +21,7 @@ public class UntypedCoordinatedCounter extends UntypedActor {
if (message instanceof Increment) { if (message instanceof Increment) {
Increment increment = (Increment) message; Increment increment = (Increment) message;
if (increment.hasFriend()) { if (increment.hasFriend()) {
increment.getFriend().sendOneWay(coordinated.coordinate(new Increment())); increment.getFriend().tell(coordinated.coordinate(new Increment()));
} }
coordinated.atomic(new Atomically() { coordinated.atomic(new Atomically() {
public void atomically() { public void atomically() {

View file

@ -15,7 +15,7 @@ public class UntypedCoordinatedExample {
ActorRef counter1 = Actors.actorOf(UntypedCoordinatedCounter.class).start(); ActorRef counter1 = Actors.actorOf(UntypedCoordinatedCounter.class).start();
ActorRef counter2 = 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); Thread.sleep(3000);

View file

@ -14,7 +14,7 @@ public class UntypedTransactorExample {
ActorRef counter1 = Actors.actorOf(UntypedCounter.class).start(); ActorRef counter1 = Actors.actorOf(UntypedCounter.class).start();
ActorRef counter2 = 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); Thread.sleep(3000);

View file

@ -40,7 +40,7 @@ public class UntypedCoordinatedCounter extends UntypedActor {
final CountDownLatch latch = increment.getLatch(); final CountDownLatch latch = increment.getLatch();
if (!friends.isEmpty()) { if (!friends.isEmpty()) {
Increment coordMessage = new Increment(friends.subList(1, friends.size()), latch); 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) { coordinated.atomic(new Atomically(txFactory) {
public void atomically() { public void atomically() {

View file

@ -44,7 +44,7 @@ public class UntypedCoordinatedIncrementTest {
@Test public void incrementAllCountersWithSuccessfulTransaction() { @Test public void incrementAllCountersWithSuccessfulTransaction() {
CountDownLatch incrementLatch = new CountDownLatch(numCounters); CountDownLatch incrementLatch = new CountDownLatch(numCounters);
Increment message = new Increment(counters.subList(1, counters.size()), incrementLatch); 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 { try {
incrementLatch.await(timeout, TimeUnit.SECONDS); incrementLatch.await(timeout, TimeUnit.SECONDS);
} catch (InterruptedException exception) {} } catch (InterruptedException exception) {}
@ -67,7 +67,7 @@ public class UntypedCoordinatedIncrementTest {
List<ActorRef> actors = new ArrayList<ActorRef>(counters); List<ActorRef> actors = new ArrayList<ActorRef>(counters);
actors.add(failer); actors.add(failer);
Increment message = new Increment(actors.subList(1, actors.size()), incrementLatch); 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 { try {
incrementLatch.await(timeout, TimeUnit.SECONDS); incrementLatch.await(timeout, TimeUnit.SECONDS);
} catch (InterruptedException exception) {} } catch (InterruptedException exception) {}

View file

@ -43,7 +43,7 @@ public class UntypedTransactorTest {
@Test public void incrementAllCountersWithSuccessfulTransaction() { @Test public void incrementAllCountersWithSuccessfulTransaction() {
CountDownLatch incrementLatch = new CountDownLatch(numCounters); CountDownLatch incrementLatch = new CountDownLatch(numCounters);
Increment message = new Increment(counters.subList(1, counters.size()), incrementLatch); Increment message = new Increment(counters.subList(1, counters.size()), incrementLatch);
counters.get(0).sendOneWay(message); counters.get(0).tell(message);
try { try {
incrementLatch.await(timeout, TimeUnit.SECONDS); incrementLatch.await(timeout, TimeUnit.SECONDS);
} catch (InterruptedException exception) {} } catch (InterruptedException exception) {}
@ -66,7 +66,7 @@ public class UntypedTransactorTest {
List<ActorRef> actors = new ArrayList<ActorRef>(counters); List<ActorRef> actors = new ArrayList<ActorRef>(counters);
actors.add(failer); actors.add(failer);
Increment message = new Increment(actors.subList(1, actors.size()), incrementLatch); Increment message = new Increment(actors.subList(1, actors.size()), incrementLatch);
actors.get(0).sendOneWay(message); actors.get(0).tell(message);
try { try {
incrementLatch.await(timeout, TimeUnit.SECONDS); incrementLatch.await(timeout, TimeUnit.SECONDS);
} catch (InterruptedException exception) {} } catch (InterruptedException exception) {}

View file

@ -117,14 +117,14 @@ public class Pi {
if (message instanceof Calculate) { if (message instanceof Calculate) {
// schedule work // schedule work
for (int start = 0; start < nrOfMessages; start++) { 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 // 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 // send a PoisonPill to the router, telling him to shut himself down
router.sendOneWay(poisonPill()); router.tell(poisonPill());
} else if (message instanceof Result) { } else if (message instanceof Result) {
@ -169,7 +169,7 @@ public class Pi {
}, "master").start(); }, "master").start();
// start the calculation // start the calculation
master.sendOneWay(new Calculate()); master.tell(new Calculate());
// wait for master to shut down // wait for master to shut down
latch.await(); latch.await();

View file

@ -119,7 +119,7 @@ public class Pi {
public void apply(Object msg) { public void apply(Object msg) {
// schedule work // schedule work
for (int arg = 0; arg < nrOfMessages; arg++) { 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 // Assume the gathering behavior
become(gather(getContext().getChannel())); become(gather(getContext().getChannel()));
@ -135,7 +135,7 @@ public class Pi {
nrOfResults += 1; nrOfResults += 1;
if (nrOfResults == nrOfMessages) { if (nrOfResults == nrOfMessages) {
// send the pi result back to the guy who started the calculation // send the pi result back to the guy who started the calculation
recipient.sendOneWay(pi); recipient.tell(pi);
// shut ourselves down, we're done // shut ourselves down, we're done
getContext().stop(); getContext().stop();
} }
@ -146,9 +146,9 @@ public class Pi {
@Override @Override
public void postStop() { public void postStop() {
// send a PoisonPill to all workers telling them to shut down themselves // 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 // send a PoisonPill to the router, telling him to shut himself down
router.sendOneWay(poisonPill()); router.tell(poisonPill());
} }
} }