I have a parent Actor class called MainActor and a child actor called 
HelloLocalActor
----------------------------------------------------------------------------------------------------
public class MainActor extends UntypedActor{
ActorRef actorRef ;
@Override
    public void onReceive( Object message ) throws Exception
    {
         if( message instanceof MyMessage )
         {
          actorRef = getSender();
          System.out.println("In Main Actor");
          
getContext().actorOf(Props.create(HelloLocalActor.class),"HelloLocalActor").tell(message,
 
self());

         }
         else if(message instanceof MyLocalMessage){
          System.out.println("Inside Main Actor");
          actorRef.tell(message, self());
         }
         else
         {
              unhandled( message );
         }
    }
}

----------------------------------------------------------------------------------------------------------------------

public class HelloLocalActor extends UntypedActor
{
    @Override
    public void onReceive( Object message ) throws Exception
    {
         if( message instanceof MyMessage )
         {
           System.out.println("Inside Hello Local Actor..");
              MyMessage myMessage = ( MyMessage )message;
              MyLocalMessage myLocalMessage = new MyLocalMessage();
              myLocalMessage.setMessage( "Local Hello, " + 
myMessage.getMessage() );
              getSender().tell( myLocalMessage, getSelf() );
              getContext().stop(getSelf());
         }
         else
         {
              unhandled( message );
         }
    }
}
--------------------------------------------------------------------------------------------------------

In the HelloLocalActor's onReceive() method, I am calling the 
"getContext().stop(getSelf());" method.
If I don't do so, I sometimes get the "InvalidActorNameException: actor 
name [HelloLocalActor] is not unique!" error.

My questions are ?
1) Is it okay to call "getContext().stop(getSelf());" method ?
2) Will it have any adverse effect on the application?
3) It really necessary to call the stop() after the child worker has 
stopped execution?

-- 
>>>>>>>>>>      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 [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/d/optout.

Reply via email to