Reputation: 29477
I was under the impression that the only way to communicate with an Akka Actor from outside the ActorSystem
was via Inbox
. However I just found this snippet from Akka's own documentation which shows:
greeter.tell(new WhoToGreet("akka"), ActorRef.noSender());
inbox.send(greeter, new Greet());
So which is it? Is it in fact possible to directly tell
an Actor from the outside world, or did Typesafe have a careless intern writing their documentation for them?!?
If it is possible, then when should you do this, and when should you use Inbox
? For instance, is one method "fire-and-forget" asynchronous/non-blocking and the other synchronous/blocking?
Upvotes: 3
Views: 1010
Reputation: 24040
Inbox
is part of the relatively recent Actor DSL API that is "some nice sugar on top of the usual ways to create actors". You can either use the standard way to create / communicate with actors or use the Actor DSL. They are both async. The Actor DSL is nice for creating one-off actors whose lifetime is one method. The advantage of the DSL syntax is a bit more evident in Scala.
Upvotes: 1
Reputation: 7247
You can safely send messages from outside an actor. Akka will fill in a dummy sender. You just won't be able to receive any replies (though you can use an ask
for that).
Upvotes: 1