#2612 - Clarifying ReceiveTimeout semantics in the documentation.

This commit is contained in:
Viktor Klang 2012-10-14 03:35:09 +02:00
parent b193a45235
commit 0ab417b2c1
4 changed files with 39 additions and 14 deletions

View file

@ -11,13 +11,17 @@ import scala.concurrent.util.Duration;
public class MyReceivedTimeoutUntypedActor extends UntypedActor {
public MyReceivedTimeoutUntypedActor() {
// To set an initial delay
getContext().setReceiveTimeout(Duration.parse("30 seconds"));
}
public void onReceive(Object message) {
if (message.equals("Hello")) {
// To set in a response to a message
getContext().setReceiveTimeout(Duration.parse("30 seconds"));
getSender().tell("Hello world", getSelf());
} else if (message == ReceiveTimeout.getInstance()) {
// To turn it off
throw new RuntimeException("received timeout");
} else {
unhandled(message);