Hi Paweł, Creating new actor is cheap, but you will have to bother with destroying it. Otherwise you will have a kind of memory leak. Anyway you shouldn't block in actor's receive function. This can be easy solved by using pipe pattern: http://doc.akka.io/docs/akka/2.3.8/scala/actors.html#Ask__Send-And-Receive-Future
PS This is my opinion, but I think you should consider using akka futures instead of actors. Actors are usable only when you have well defined hierarchy or you have to manage internal (and mutable) actor state. It seems to me that both of those don't apply to your case. Regards, Paweł On Saturday, January 3, 2015 12:24:57 AM UTC+1, Paweł Sadowski wrote: > > Hi, > > My code looks like > > lazy val userLinksActor: ActorRef = Akka.system.actorOf(Props(new > UserLinksActor(articleReader)),"userLinksActor") > > def receive = { > case GetLinks(usersFuture) => > > usersFuture.onComplete { > case Success(users: List[User]) => { > users.foreach(user => > //here should i use val userLinksActor or create each time new actor? > //each of this actor is calling ws, when i use val userLinksActor these > calls are synchronized, one after another. When i create new actor all > calls to //ws are asnyc > //I thought that i should use one reference to actor(val) and akka will > spawn new when needed and parallel calls > Akka.system.actorOf(Props(new UserLinksActor(articleReader))) ! > GetUserLinks(user, originalSender)) > } > } > } > > I have another question here about akka, maybe someone can help > https://groups.google.com/forum/#!topic/play-framework/DrqNw-rA2Lo > -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.