Merge pull request #799 from akka/wip-2612-improve-receivetimeout-docs-√
#2612 - Clarifying ReceiveTimeout semantics in the documentation.
This commit is contained in:
commit
a1b8abbe6f
4 changed files with 40 additions and 14 deletions
|
|
@ -11,13 +11,18 @@ 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("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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue