--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.
Patrik Nordwall
Typesafe - Reactive apps on the JVM
Twitter: @patriknw
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
You received this message because you are subscribed to a topic in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/qqzKfE3_VSw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+...@googlegroups.com.
public static Result invite( String id ) {
// akka actor
ActorRef ref = null;
// selection path
String actorId = "InviteSupervisor-" + id;
String path = "/user/" + actorId;
ActorSelection sel = Akka.system().actorSelection(path);
// ask to identify
Timeout t = new Timeout(3000);
AskableActorSelection asker = new AskableActorSelection(sel);
Future<Object> fut = asker.ask(new Identify(id), t);
ActorIdentity ident;
try {
// wait results
ident = (ActorIdentity)Await.result(fut, t.duration());
ref = ident.getRef();
} catch (Exception e) {
Logger.error(TAG + e.getMessage(), e);
// TODO handle timeout or other errors
return badRequest("Selection Error");
}
// actor exist or not
if ( ref == null ) {
// start new actor
// kick off process queue
ref = Akka.system().actorOf(InviteSupervisor.props(id), actorId);
// start invite import process
ref.tell(new InviteSupervisor.ImportMessage(id), ActorRef.noSender());
return ok( "Actor not found :( but one was created :) " + ref.path().toString() );
} else {
// already running, get progress
String status = "";
// get progress
Future<Object> futProg = asker.ask(new InviteSupervisor.ProgressMessage(null), t);
try {
// wait results
InviteSupervisor.ProgressMessage msg = (InviteSupervisor.ProgressMessage)Await.result(futProg, t.duration());
status = msg.getProgress().toString();
} catch (Exception e) {
Logger.error(TAG + e.getMessage(), e);
// TODO handle timeout or other errors
}
return ok( "Actor Found! " + ref.path().toString() + " [" + status + "]");
}
}