The Artima Developer Community
Sponsored Link

Akka Concurrency Forum
actorFor Outside ActorSystem

4 replies on 1 page. Most recent reply: Dec 6, 2012 5:21 AM by Lawrence MacFadyen

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Lawrence MacFadyen

Posts: 7
Nickname: 84427
Registered: Oct, 2012

actorFor Outside ActorSystem Posted: Dec 3, 2012 6:34 PM
Reply to this message Reply
Advertisement
Hi,

From some of the content in chapter 8, I understand that doing actorFor is safer on descendents of a given actor since those descendents would generally be under control/supervision of the higher level actor.

For references to actors above an actor, dependency injection or message passing would be better since you are not dependent on the path and thus are resilient to refactoring etc.

When you have multiple ActorSystems and you want to lookup an actor from another ActorSystem, it would seem to me that the same rule would apply in the latter case above, ie. it would be more risky relying on the path and using actorFor, and therefore optimum to use DI or message passing.

I'd like to hear your thoughts on this topic when multiple ActorSystems are involved.

Thanks,

Larry


Derek Wyatt

Posts: 69
Nickname: dwyatt
Registered: Oct, 2012

Re: actorFor Outside ActorSystem Posted: Dec 4, 2012 2:50 AM
Reply to this message Reply
That's a good question. I'm not sure I really have a huge opinion on this, though. Akka tends to make this stuff pretty transparent and universal, so what works for one ActorSystem works for more than one.

With that said, the patterns can be slightly different when it comes to the real-world usage of things. I use separate ActorSystems rather rarely; the only time I've done it is to segment two distinct parts of a running system that were truly separate components on their own. They were more like entirely separate apps.

In that configuration, I tended to use the two systems as distinct services from one another. Each system loaded up its Actors and did its work independently of the other, so nobody performed an actorOf() on anything but their own system.

In order to get Actor references between systems, I found it easiest to create well known entry points in each system (e.g. /user/ServiceManager) and used those as lookup services / delegators. Stuff like this:

// The remote Actor delegates and possibly proxies the request / response
remoteSystem.actorFor("/user/ServiceManager") ! DoSomeWork(work)

// The remote Actor returns the reference to the internal Actor that I'm interested in
remoteSystem.actorFor("/user/ServiceManager") ! LookupService(identifier)

These were very short-lived calls and I never had any reason to put deathwatch on them or anything like that.

As with most things, it really just depends on how you want to lay your app out.

Lawrence MacFadyen

Posts: 7
Nickname: 84427
Registered: Oct, 2012

Re: actorFor Outside ActorSystem Posted: Dec 5, 2012 5:04 AM
Reply to this message Reply
Thanks for the quick response!

I have one follow-on question.

When you've used the well-known entry point and used that as service lookup or delegator, would you always make that the top level actor, or not necessarily?

Thanks,

Larry

Derek Wyatt

Posts: 69
Nickname: dwyatt
Registered: Oct, 2012

Re: actorFor Outside ActorSystem Posted: Dec 5, 2012 5:15 AM
Reply to this message Reply
In my case, I made it a top-level Actor, but that's not necessary. Specifically, though, I made it a top-level Actor with no significant children. i.e. the "app" was under a different hierarchy, and the accessor Actor was in its own.

Lawrence MacFadyen

Posts: 7
Nickname: 84427
Registered: Oct, 2012

Re: actorFor Outside ActorSystem Posted: Dec 6, 2012 5:21 AM
Reply to this message Reply
That seems like an interesting idea...thanks as usual for your response.

Larry

Flat View: This topic has 4 replies on 1 page
Topic: Code Coverage Previous Topic   Next Topic Topic: On traits vs. Params

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use