Inside actors it is more elegant to send Identify message and act on
the ActorIdentity reply. You can handle timeout and retries by scheduling a
timeout message.

Inspiration:
http://doc.akka.io/docs/akka/2.2.3/scala/actors.html#Identifying_Actors_via_Actor_Selection
http://typesafe.com/blog/staying-in-contact-with-an-actors-acquaintances


On Thu, Dec 19, 2013 at 4:53 PM, Shing <[email protected]> wrote:

> Hi,
>
>    I am using Akka 2.2.1 .
> I am looking up a remote actor using actorSelection using the code below.
>
>   def getActorRef(path: String, context: ActorContext,
> log:LoggingAdapter): ActorRef = {
>
>     implicit val timeout = Timeout(30, TimeUnit.SECONDS);
>     val future = context.actorSelection(path).resolveOne().mapTo[ActorRef]
>
>     val futureTimeout = Duration(30, TimeUnit.SECONDS);
>     val actorRef =
>       try {
>         Await.result(future, futureTimeout)
>       } catch {
>         case ex: Exception => {
>           log.info("+++++ Not available :" + path)
>           context.actorOf(Props.empty)
>
>         }
>       }
>
>     actorRef
>   }
>
>
> Is there a more elegant way (without catching an exception)  of
> determining if a remote actor is running ?
>
>
> Thanks in advance for your assistance !
>
> Shing
>
>
>  --
> >>>>>>>>>> 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 [email protected].
> To post to this group, send email to [email protected].
> 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 <http://typesafe.com/> -  Reactive apps on the JVM
Twitter: @patriknw

-- 
>>>>>>>>>>      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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to