Clarifying setReceiveTimeout examples after review

This commit is contained in:
Viktor Klang 2012-10-15 13:49:12 +02:00
parent 0ab417b2c1
commit dbad8c85f6
2 changed files with 4 additions and 3 deletions

View file

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