diff --git a/akka-docs/cluster/durable-mailbox.rst b/akka-docs/cluster/durable-mailbox.rst index 4965eeff8a..774008c6da 100644 --- a/akka-docs/cluster/durable-mailbox.rst +++ b/akka-docs/cluster/durable-mailbox.rst @@ -18,10 +18,9 @@ in its mailbox. .. sidebar:: **IMPORTANT** None of these mailboxes work with blocking message send, e.g. the message - send operations that are relying on futures; ``!!``, ``?``, - ``sendRequestReply`` and ``ask``. If the node has crashed - and then restarted, the thread that was blocked waiting for the reply is gone - and there is no way we can deliver the message. + send operations that are relying on futures; ``?`` or ``ask``. If the node + has crashed and then restarted, the thread that was blocked waiting for the + reply is gone and there is no way we can deliver the message. The durable mailboxes currently supported are: diff --git a/akka-docs/java/remote-actors.rst b/akka-docs/java/remote-actors.rst index 98ad91e8b5..8abedb1c3c 100644 --- a/akka-docs/java/remote-actors.rst +++ b/akka-docs/java/remote-actors.rst @@ -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: diff --git a/akka-docs/java/serialization.rst b/akka-docs/java/serialization.rst index 51ccd278ec..2a10a813bb 100644 --- a/akka-docs/java/serialization.rst +++ b/akka-docs/java/serialization.rst @@ -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"); diff --git a/akka-docs/java/untyped-actors.rst b/akka-docs/java/untyped-actors.rst index 2a7af7faad..9defdf4607 100644 --- a/akka-docs/java/untyped-actors.rst +++ b/akka-docs/java/untyped-actors.rst @@ -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 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'. 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()); } } } diff --git a/akka-docs/modules/camel.rst b/akka-docs/modules/camel.rst index 39b289a88e..b3c07e56dd 100644 --- a/akka-docs/modules/camel.rst +++ b/akka-docs/modules/camel.rst @@ -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 ``http://localhost:8080/news``. Response messages (if supported by 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 used. @@ -1029,7 +1029,7 @@ used. import akka.actor.ActorRef val producer = actorOf[Producer1] - val response = producer !! "akka rocks" + val response = (producer ? "akka rocks").get val body = response.bodyAs[String] **Java** @@ -1283,14 +1283,14 @@ Matching responses ^^^^^^^^^^^^^^^^^^ 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). **Scala** .. code-block:: scala - val response = producer !! message + val response = (producer ? message).get response match { case Some(Message(body, headers)) => ...