Reputation: 2874
In java
I have simple web application. In ServletContextListener
I create actor
ActorSystem system = ActorSystem.create("MySystem");
actor = system.actorOf(new Props(MyServerActor.class), "MyServer");
actor.tell(new StartMessage());
this actor has path akka://MySystem/user/MyServer
. Then I try to send message to this actor from business method
ActorSystem system = ActorSystem.create("MySystem");
client = system.actorSelection("/user/MyServer"); // same effect when use actorFor
client.tell("OK");
onReceive
method:
@Override
public void onReceive(Object message) throws Exception {
System.out.println(message + " : " + message);
}
but my actor doesn’t receive message. It look like i send it to /dev/null.
Where is mistake?
//edit:
I try to use fullpath too.
Upvotes: 1
Views: 4117
Reputation: 431
you can try with remote actors:
String path = "akka://MySystem@some-ip:some-port/some/sub/path"
ActorRef xxx = actorSystem.actorFor(path);
Also, it would be better if you have subscribe the deadLetters() actor to record the unhandled messages.
final ActorRef actor = actorSystem.actorOf(new Props(DefaultDeadLetterHandlerActor.class));
actorSystem.eventStream().subscribe(actor, DeadLetter.class);
by maybe just simply log them.
Upvotes: 3
Reputation: 2874
Ok I'm so stupid...
I create two System
so the cannot access one to another, cannot find actor so message were send to /dev/null
Upvotes: 3