#2612 - Clarifying ReceiveTimeout semantics in the documentation.
This commit is contained in:
parent
b193a45235
commit
0ab417b2c1
4 changed files with 39 additions and 14 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue