I'm looking over the Akka Java documentation on untyped actors (http://doc.akka.io/docs/akka/2.3.2/java/untyped-actors.html)
I effectively want to accomplish something such as:
Set a timeout for any particular message I expect to receive in my onReceive() method. For instance:
public void onReceive(Object message) throws Exception {
if (message.equals("start")) {
child.tell("fetch something for me!", getSelf());
}
if (message.equals("child's response")) {
// handle a response from a child here,
// but timeout within some timeframe if I don't get a
// response quick enough.
// use this here? getContext().setReceiveTimeout(Duration.create("1 second"));
}
}
I understand you can use Patterns.ask( actor , message , timeout ), which returns a future. If the response isn't sent back within the specified timeout argument, fail.
I don't want to use futures here. I don't understand the usage of the setReceiveTimeout method. How do I accomplish this by purely using actor.tell ?