I have been playing around with Akka-Java to learn writing concurrent application using Actors. I have previously worked on Java CompletableFutures extensively.
There are few things which I could not figure out despite searching for them on internet. Suppose there is a sequence of dependant operations say: a. Build X b. Insert X into Database c. Find Y in the Database d. Get Z from some Computation and return it Assuming all the above operations are blocking. Now my first question is, 1. How do I approach in building Actor model for the above scenario? # One way I understood is to create one actor for each operation and one parent actor which will do result passing between children like: *Parent* => *Build X Actor*==returns X==> *Parent* == pass X ==> *InsertX Acto*r ==> .... goes on Although inclusion of Parent Actor might not be necessary in the above scenario but the point is to create One actor for Each blocking operation. The problem with this approach is that I endup *creating* so many actors which makes my code messy and codebase grows like crazy as I create so many actors for one functionality. #Another way is to *wrap all the operations inside one actor*. The better part with this approach is it does not create that many actors as approach one but it certainly ruins the purpose of actors because AFAIK if an actor has severe blocking code, it almost mimics a Java thread itself. # Another approach I have came across is to create Message Protocols for each of the above mentioned operations by realising them as Events and Create a Parent + Child Routes. Parent routes each operation to one of its children based one Message Protocol. For Example: Suppose there are three sequential operations *A*, *B *and *C*. I create a Message Protocol for each operation, say *MessageA*, *MessageB &* *MessageC*. Now, Parent, on completion of *MessageA* will take it's result and give it as an input to one of its children by routing and same goes with *MessageB*. When *MessageC* is completed & returned by one of its children, Parent returns *MessageC* data to the caller of Parent actor indication of completion. This approach looks reasonable but not convincing. I tried all the above approaches but I somehow not convinced about my approaches. Please correct my understanding on this. Next two questions are kind of related to Play framework+Akka, It's okay if you do not have answer for the below ones; I'll post below on Play Framework group too. 2. I use Play framework with Java, Is there any way to use only actors until controller level (after which I am forced to send* CompletionStage<Result>* to avoid blocking API call anyway)? For now I'm using *Patterns.ask(..) *to wait for the data. 3. One final question is, even if followed various approaches of actors I could not hit concurrency level beyond 1000. What is the optimal value for real world scenarios, not hello world ones. Regards, Vishwa -- >>>>>>>>>> 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
