Actor look up vs passing actor

Hi,

Suppose, actor A makes use of actor B to get somethings done.
I can access actor B making use of Akka’s look up facilities OR I can pass actor B(actorRef, to be precise) when I create actor A.
Which is better approach?

Prefer passing the ActorRef, like in dependency injection. That can also be done by passing refs messages.

There are some cases when lookup is needed, such as when bootstrapping interaction with an actor located on another node.

1 Like