remove references to !! from docs (apart from camel internals)

This commit is contained in:
Roland 2011-10-30 11:39:10 +01:00
parent bb51bfdc72
commit cccf6b4ed9
5 changed files with 16 additions and 41 deletions

View file

@ -353,7 +353,7 @@ Client side usage
import static akka.actor.Actors.*;
ActorRef actor = remote().actorFor("hello-service", "localhost", 2552);
Object result = actor.sendRequestReply("Hello");
Object result = actor.ask("Hello").get();
There are many variations on the 'remote()#actorFor' method. Here are some of them:

View file

@ -62,7 +62,7 @@ The following JUnit snippet first creates an actor using the default constructor
ActorRef ref = Actors.actorOf(SerializationTestActor.class);
assertNotNull(ref);
try {
Object result = ref.sendRequestReply("Hello");
Object result = ref.ask("Hello").get();
assertEquals("got it!", result);
} catch (ActorTimeoutException ex) {
fail("actor should not time out");
@ -74,7 +74,7 @@ The following JUnit snippet first creates an actor using the default constructor
assertNotNull(r);
try {
Object result = r.sendRequestReply("Hello");
Object result = r.ask("Hello").get();
assertEquals("got it!", result);
} catch (ActorTimeoutException ex) {
fail("actor should not time out");
@ -151,10 +151,10 @@ Step 3: Serialize and de-serialize
ActorRef ref = Actors.actorOf(MyUntypedActor.class);
assertNotNull(ref);
try {
Object result = ref.sendRequestReply("hello");
Object result = ref.ask("hello").get();
assertEquals("world 1", result);
result = ref.sendRequestReply("hello");
assertEquals("world 2", result);
result = ref.ask("hello").get();
assertEquals("world 2", result);
} catch (ActorTimeoutException ex) {
fail("actor should not time out");
}
@ -164,9 +164,9 @@ Step 3: Serialize and de-serialize
ActorRef r = fromBinaryJ(bytes, f);
assertNotNull(r);
try {
Object result = r.sendRequestReply("hello");
Object result = r.ask("hello").get();
assertEquals("world 3", result);
result = r.sendRequestReply("hello");
result = r.ask("hello").get();
assertEquals("world 4", result);
} catch (ActorTimeoutException ex) {
fail("actor should not time out");

View file

@ -107,7 +107,6 @@ Send messages
Messages are sent to an Actor through one of the 'send' methods.
* '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.
* 'ask' sends a message asynchronously and returns a 'Future'.
In all these methods you have the option of passing along your 'ActorRef' context variable. Make it a practice of doing so because it will allow the receiver actors to be able to respond to your message, since the sender reference is sent along with the message.
@ -131,29 +130,6 @@ If invoked from within an Actor, then the sending actor reference will be implic
If invoked from an instance that is **not** an Actor there will be no implicit sender passed along the message and you will get an 'IllegalStateException' if you call 'getContext().reply(..)'.
Send-And-Receive-Eventually
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Using 'sendRequestReply' will send a message to the receiving Actor asynchronously but it will wait for a reply on a 'Future', blocking the sender Actor until either:
* A reply is received, or
* The Future times out and an 'ActorTimeoutException' is thrown.
You can pass an explicit time-out to the 'sendRequestReply' method and if none is specified then the default time-out defined in the sender Actor will be used.
Here are some examples:
.. code-block:: java
UntypedActorRef actorRef = ...
try {
Object result = actorRef.sendRequestReply("Hello", getContext(), 1000);
... // handle reply
} catch(ActorTimeoutException e) {
... // handle timeout
}
Send-And-Receive-Future
^^^^^^^^^^^^^^^^^^^^^^^
@ -239,7 +215,7 @@ which you do by Channel.tell(msg)
String msg = (String)message;
if (msg.equals("Hello")) {
// Reply to original sender of message using the channel
getContext().channel().tryTell(msg + " from " + getContext().getUuid());
getContext().channel().tell(msg + " from " + getContext().getUuid());
}
}
}