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

@ -18,10 +18,9 @@ in its mailbox.
.. sidebar:: **IMPORTANT** .. sidebar:: **IMPORTANT**
None of these mailboxes work with blocking message send, e.g. the message None of these mailboxes work with blocking message send, e.g. the message
send operations that are relying on futures; ``!!``, ``?``, send operations that are relying on futures; ``?`` or ``ask``. If the node
``sendRequestReply`` and ``ask``. If the node has crashed has crashed and then restarted, the thread that was blocked waiting for the
and then restarted, the thread that was blocked waiting for the reply is gone reply is gone and there is no way we can deliver the message.
and there is no way we can deliver the message.
The durable mailboxes currently supported are: The durable mailboxes currently supported are:

View file

@ -353,7 +353,7 @@ Client side usage
import static akka.actor.Actors.*; import static akka.actor.Actors.*;
ActorRef actor = remote().actorFor("hello-service", "localhost", 2552); 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: 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); ActorRef ref = Actors.actorOf(SerializationTestActor.class);
assertNotNull(ref); assertNotNull(ref);
try { try {
Object result = ref.sendRequestReply("Hello"); Object result = ref.ask("Hello").get();
assertEquals("got it!", result); assertEquals("got it!", result);
} catch (ActorTimeoutException ex) { } catch (ActorTimeoutException ex) {
fail("actor should not time out"); fail("actor should not time out");
@ -74,7 +74,7 @@ The following JUnit snippet first creates an actor using the default constructor
assertNotNull(r); assertNotNull(r);
try { try {
Object result = r.sendRequestReply("Hello"); Object result = r.ask("Hello").get();
assertEquals("got it!", result); assertEquals("got it!", result);
} catch (ActorTimeoutException ex) { } catch (ActorTimeoutException ex) {
fail("actor should not time out"); fail("actor should not time out");
@ -151,10 +151,10 @@ Step 3: Serialize and de-serialize
ActorRef ref = Actors.actorOf(MyUntypedActor.class); ActorRef ref = Actors.actorOf(MyUntypedActor.class);
assertNotNull(ref); assertNotNull(ref);
try { try {
Object result = ref.sendRequestReply("hello"); Object result = ref.ask("hello").get();
assertEquals("world 1", result); assertEquals("world 1", result);
result = ref.sendRequestReply("hello"); result = ref.ask("hello").get();
assertEquals("world 2", result); assertEquals("world 2", result);
} catch (ActorTimeoutException ex) { } catch (ActorTimeoutException ex) {
fail("actor should not time out"); fail("actor should not time out");
} }
@ -164,9 +164,9 @@ Step 3: Serialize and de-serialize
ActorRef r = fromBinaryJ(bytes, f); ActorRef r = fromBinaryJ(bytes, f);
assertNotNull(r); assertNotNull(r);
try { try {
Object result = r.sendRequestReply("hello"); Object result = r.ask("hello").get();
assertEquals("world 3", result); assertEquals("world 3", result);
result = r.sendRequestReply("hello"); result = r.ask("hello").get();
assertEquals("world 4", result); assertEquals("world 4", result);
} catch (ActorTimeoutException ex) { } catch (ActorTimeoutException ex) {
fail("actor should not time out"); 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. 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. * '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'. * '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. 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(..)'. 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 Send-And-Receive-Future
^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
@ -239,7 +215,7 @@ which you do by Channel.tell(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().tryTell(msg + " from " + getContext().getUuid()); getContext().channel().tell(msg + " from " + getContext().getUuid());
} }
} }
} }

View file

@ -1017,7 +1017,7 @@ Any message sent to a Producer actor (or UntypedProducerActor) will be sent to
the associated Camel endpoint, in the above example to the associated Camel endpoint, in the above example to
``http://localhost:8080/news``. Response messages (if supported by the ``http://localhost:8080/news``. Response messages (if supported by the
configured endpoint) will, by default, be returned to the original sender. The configured endpoint) will, by default, be returned to the original sender. The
following example uses the ``!!`` operator (Scala) to send a message to a following example uses the ``?`` operator (Scala) to send a message to a
Producer actor and waits for a response. In Java, the sendRequestReply method is Producer actor and waits for a response. In Java, the sendRequestReply method is
used. used.
@ -1029,7 +1029,7 @@ used.
import akka.actor.ActorRef import akka.actor.ActorRef
val producer = actorOf[Producer1] val producer = actorOf[Producer1]
val response = producer !! "akka rocks" val response = (producer ? "akka rocks").get
val body = response.bodyAs[String] val body = response.bodyAs[String]
**Java** **Java**
@ -1283,14 +1283,14 @@ Matching responses
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
The following code snippet shows how to best match responses when sending The following code snippet shows how to best match responses when sending
messages with the !! operator (Scala) or with the sendRequestReply method messages with the ``?`` operator (Scala) or with the ``ask`` method
(Java). (Java).
**Scala** **Scala**
.. code-block:: scala .. code-block:: scala
val response = producer !! message val response = (producer ? message).get
response match { response match {
case Some(Message(body, headers)) => ... case Some(Message(body, headers)) => ...