Monday, 30 September 2013

Best practices for actors lookup from actors

Best practices for actors lookup from actors

I am using akka 2.2.x. in cluster mode. My question is related to actors
lookup.
I have two kind of actors:
processor. It accepts text and processes it somehow
result collector. Acceps messages from processor and summarize the results.
Processor actor needs to send message to result collector. So, I need to
have ActorRef inside processor.
The queston is - how to pass/lookup this ActorRef to processor.
I have 3 different solutions for now:
Lookup ActorRef to processor in creation time and pass ActorRef as
contructor parameter. Looks possibly wrong because it does not handle
actor restart process and does not fit into cluster environment.
Lookup in preStart with context.actorSelection("../result-collector").
After this I have the object of ActorSelection and can send messages with
!. In this solution I am aware of performance degradation because of
lookup in cluster before every call. Or am I wrong here?
Lookup in preStart with context.actorSelection("../result-collector") and
call resolveOne to obtain ActorRef. Looks ok, but may not handle akka
cluster changes.
Thanks!

No comments:

Post a Comment