Hi,

I tried to use this earlier (the actorSelection) but didn't know how to 
handle a wrong path. I wanted to use the logic to initialize the actor if 
it doesn't exist.

This is what I tried with


ActorSystem system = ActorSystem.create("Hello");

ActorRef a = system.actorOf(Props.create(HelloWorld.class), "helloWorld");
a.tell("created object", null);
ActorSelection selection1 = system.actorSelection("/user/helloWorld");

System.out.println(selection1);

selection1.tell("selection ", null);
ActorSelection selection = system.actorSelection("/user/helloWorld_wrong");

//this is not null, shouldn't this be null?
System.out.println(selection);

selection.tell("wrong path, should fail", null);  


Thanks
Hari



On Tuesday, November 1, 2016 at 1:00:34 AM UTC-7, Patrik Nordwall wrote:
>
> Use ActorSelection: 
> http://doc.akka.io/docs/akka/2.4/java/untyped-actors.html#Identifying_Actors_via_Actor_Selection
>
> On Mon, Oct 31, 2016 at 7:30 PM, Harinath Mallepally <ha...@harinath.in 
> <javascript:>> wrote:
>
>> Hi,
>>
>> I am using this deprecated method for referencing existing actor, is this 
>> the right approach? given that I have created a actor with a unique name, I 
>> want to reference is so that I can use it.
>>
>>  ActorRef actor = actorSystem.actorFor(actorSystem.child(<actor name>)
>>
>> I always get not null value even if the actor doesn't exist.
>>
>> Thanks
>> Hari
>>
>> -- 
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> 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 <javascript:>.
>> To post to this group, send email to akka...@googlegroups.com 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
>
> Patrik Nordwall
> Akka Tech Lead
> Lightbend <http://www.lightbend.com/> -  Reactive apps on the JVM
> Twitter: @patriknw
>
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      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+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to