I am new to Akka and I read some documentation and I am trying to send 
message to a remote actor (In a different jvm in the same machine).

I have attached the code for my program


*Hero.java*

import akka.actor.UntypedActor;

public class Hero extends UntypedActor {

    @Override
    public void onReceive(Object arg0) throws Exception {
        System.out.println("Received = " + arg0);
    }

}




*TestHero.java*import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;

public class TestHero {
    
    public static void main(String[] args) {
        ActorSystem system = ActorSystem.create("testHero");
        ActorRef master = system.actorOf(Props.create(Hero.class), 
"master");
        System.out.println(master.path());
        master.tell("I am here", ActorRef.noSender());
    }

}

*application.conf for running TestHero.java (through vm argument)*

akka {
    actor {
        provider = "akka.remote.RemoteActorRefProvider"
    }
    remote {
        enabled-transports = ["akka.remote.netty.tcp"]
        netty.tcp {
            hostname = "localhost"
            port = 2009
        }
    }
}



*Messenger.java*

import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActor;

public class Messenger extends UntypedActor {
    
    public Messenger() {
        
        
    }

    @Override
    public void onReceive(Object arg0) throws Exception {
        System.out.println("msg = " + arg0);
        ActorSelection master = 
ActorSystem.create("msngr").actorSelection("akka.tcp://testHero@localhost:2009/user/master");
        System.out.println(master);
        master.tell(arg0, getSelf());
    }
    
    
    public static void main(String[] args) {
        ActorSystem system = ActorSystem.create("test");
        ActorRef actor = system.actorOf(Props.create(Messenger.class), 
"msgnr");
        actor.tell("Hi", null);
    }

}

When I run TestHero.java I get the following output in the console.





*[INFO] [05/16/2015 22:35:11.856] [main] [Remoting] Starting remoting[INFO] 
[05/16/2015 22:35:12.215] [main] [Remoting] Remoting started; listening on 
addresses :[akka.tcp://testHero@localhost:2009][INFO] [05/16/2015 
22:35:12.217] [main] [Remoting] Remoting now listens on addresses: 
[akka.tcp://testHero@localhost:2009]akka://testHero/user/masterReceived = I 
am here*

When I run Messenger.java I get the following output




*msg = HiActorSelection[Anchor(akka://msngr/deadLetters), 
Path(/user/master)][INFO] [05/16/2015 22:37:51.462] 
[msngr-akka.actor.default-dispatcher-7] [akka://msngr/deadLetters] Message 
[java.lang.String] from Actor[akka://test/user/msgnr#149375712] to 
Actor[akka://msngr/deadLetters] was not delivered. [1] dead letters 
encountered. This logging can be turned off or adjusted with configuration 
settings 'akka.log-dead-letters' and 
'akka.log-dead-letters-during-shutdown'.*
I could not understand why it is not delivered to Hero actor.

Can any one please clarify?

-- 
>>>>>>>>>>      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