Hi Sridhar,

You can create actors as needed anywhere within the actor and they will be 
created as children of that actor. 

So MasterPoller creates RegionPollers which can fire off either futures or 
child actors to do the processing. To prevent overloading I would make the 
RegionPoller track and rate limit the number of workers it creates, it would be 
easy to pause the poller if it is getting too far ahead of the workers.  

In answer to your second part, if the file worker is busy processing it would 
not respond to messages. The question comes down to what you want to do if the 
workers are not keeping up with the global polling schedule. Main options would 
be to  be either cancel the work ( the worker would need to release control or 
check periodically to cancel) or wait until the work is done as the regional 
poller is effectively managing a work queue (which could be purged when a new 
poll request comes in. 

Hope that helps. 

Cheers

Rory

> On 20 Dec 2013, at 02:25, Sridhar Sreenivasan 
> <[email protected]> wrote:
> 
> Hi,
>     Iam new to Akka, and have been designing an application in 
> akka(2.2.3)/scala. Gist of the application is to poll for files from external 
> source every minute, process the file (read) and send it for downstream 
> processing.
> I have a master actor, that creates region pollers (the external source can 
> be located in multiple geo regions). The region pollers then polls for files 
> in the specific region and creates child actors that processes the files.
> Current mechanism-
> 1. MasterPoller created and scheduled periodically, by sending a message in a 
> Main
> 2. The MasterPoller actor creates the RegionPoller actor upon receiving the 
> message
> 3. The RegionPoller creates the FileWorker actors upon receiving the message
> 4. FileWorker processes the files.
> 
> First question, is this an acceptable pattern of creating actors within the 
> "receive" method. Or should it be created as part of the "preStart" of each 
> actor. Should I terminate the actors in step 3. and 2. after processing? Or 
> if I don't, will they be reused when the MasterPoller creates the actors 
> again? I fear that with the implementation I currently have, the number of 
> actors are going to be incremented with no explicit "stop". But what's the 
> performance impact of stopping the actors, and recreating them? 
> Secondly if I create the actors as part of "prestart" then they will be 
> reused. But in the case where FileWorker is processing, and then the 
> MasterPoller is scheduled for the next run, and sends a message to 
> RegionPoller. When RegionPoller sends the message to FileWorker, it's going 
> to be blocked, right? 
> Any suggestions on what the best practices are?
> 
> Regards,
> Sridhar.
> -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://akka.io/faq/
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to