Hi, I don't completely understand how you have designed your system or why you have/think you have a problem.
If there is one actor representing the Amount in your table, and all requests to change the amount go through that actor, then the requests will happen one after each other. This means that if you split up your requests by user and have one actor per user that handle all requests for that user, then that users requests will happen sequentially, but requests for multiple users will happen concurrently. There are a number of books explaining Akka and actor programming in this list: http://doc.akka.io/docs/akka/snapshot/additional/books.html B/ On 23 September 2014 at 16:24:59, [email protected] ([email protected]) wrote: Again thanks for previous help. Only because of previous help we can moved on for our AKKA Project. Now need to know in deep. Problem Statement :- I am having 1 Table with 1 column in my Database ok. |---------| |Amount | |---------| |0 | |---------| package com.ivasyncapp.worker; import akka.actor.UntypedActor; import com.logsapp.logs.LogWriter; public class Worker extends UntypedActor { private static final String TRACE_ID = "Worker"; LoggingAdapter log = Logging.getLogger(getContext().system(), this); public void onReceive(Object object) throws Exception { if(object instanceof Double) { Double amt = (Double) object; log.info("Amount : {}", amt); //Assume that is Database Update Query. It will update my column } else { unhandled(object); } } } Above mentioned Actor will run on each our user request. Now suppose on my application we have 3 request parallely. 1st request : For updating Amount by 100. 2st request : For updating Amount by 200. 3st request : For updating Amount by 300. So after complition of my 3 request processing there should be 600 in our table. |---------| |Amount | |---------| |600 | |---------| But What happing is ????? As we know AKKA is asynchronous in nature so it will run actors asynchronously. So It will give output diffrent, sometime it will provides |---------| |Amount | |---------| |100 | |---------| OR |---------| |Amount | |---------| |200 | |---------| OR |---------| |Amount | |---------| |300 | |---------| But i want to synchronise my actor logic of Database update so only 1 actor can use that at a time : package com.ivasyncapp.worker; import akka.actor.UntypedActor; import com.logsapp.logs.LogWriter; public class Worker extends UntypedActor { private static final String TRACE_ID = "Worker"; LoggingAdapter log = Logging.getLogger(getContext().system(), this); //Synchronised Logic so only 1 Actor can use at a time public void onReceive(Object object) throws Exception { if(object instanceof Double) { Double amt = (Double) object; log.info("Amount : {}", amt); //Assume that is Database Update Query. It will update my column } else { unhandled(object); } } //Synchronised Logic } So please suggest me how to do this & also suggest for this which AKKA concept we have to read & from where ??? On Monday, June 11, 2012 5:58:27 AM UTC+5:30, dimgel wrote: Hi all, Since actors are stateful, I have to create an actor tree for each HTTP request I handle, right? Have I to create ActorSystem for each request too, or I can create the only one in Servlet.init(), reuse it for all (possibly concurrent) requests, and shut it down in Servlet.destroy()? Is there any recommended way of generating unique ActorSystem names if each request needs its own ActorSystem, or unique Actor names otherwise? (AFAIK names are optional and that's OK for standalone server, but anyway maybe someone came upon some guidelines about naming in distributed environment.) Thanks. =) -- >>>>>>>>>> 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 http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout. -- Björn Antonsson Typesafe – Reactive Apps on the JVM twitter: @bantonsson -- >>>>>>>>>> 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 http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
