> 15 feb. 2017 kl. 22:18 skrev Igor Berman <[email protected]>: > > Hello All > Wanted to get a bit of advice regarding following usecase: > I have local ActorSystem that handles messages with some key inside. Every > such message causes mutation of db state by the key: read old value by key, > compute new state given message, write new value to the db. > > To guarantee consistent update per each key I thought of spliting processing > of incoming messages by ConsistentHashingPool, so that all messages with same > key will be handled by the same child actor. Number of children will give me > sort of partitioning of key-set into finite number of actors, it will provide > concurrency of updates across keys from different partitions too. Suppose I > can't use akka-persistence module and need to maintain "state" inside this db. > > Now concerning implementation of update itself: if I wrap processing in some > future (so that actor won't be blocked to read from db and to write to db) > and then pipe the result to the sender I might break the order of processing > within same key(e.g. when update logic running in future for some msg is not > yet finished write to db, the next msg will be taken from mailbox by actor > and will submit another processing that might interleave with the first one), > so I found technique of becoming "unresponsive" and stashing all messages and > then, when future completes unbecoming and unstashing all messages(from here > http://chariotsolutions.com/blog/post/order-chaos-maintaining-ordered-processing-messages-akka-actors/) > > On the other hand, I'll need some thread pool anyway for those futures(since > reads/writes are blocking), so maybe just doing this blocking work inside > actor and configuring it with custom dispatcher will give same effect, while > being more simple solution
Yes, this is the right conclusion: Actors establish order within chaos and manage resources. Regards, Roland > > thanks in advance > Igor > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/> > >>>>>>>>>> Check the FAQ: > >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html> > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > >>>>>>>>>> <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] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at https://groups.google.com/group/akka-user > <https://groups.google.com/group/akka-user>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- >>>>>>>>>> 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.
