I’ve been studying actor model and I’m trying to get some real usage examples. One thing I can think of it is using it to control concurrent access of specific resources.
Let’s imagine a banking system where each checking account is modeled as an actor. The checking account actors can be spread among various machines, forming a cluster (making use of the location transparency and features like akka-cluster). Each transaction (credit or debit) must be handled one by one so we can guarantee that the final balance is consistent. The mailbox of the actor seems to me a good place to achieve this concurrent control, so each transaction can be queued and processed properly. During each transaction processing, the actor insert new records in the database to persist the operation. In this case, the actor works as a facade / queue to the repository.
I know that an actor can handle the concurrent access of its internal state, but this concept can be correctly used to control access of external resources like databases? Is this a common approach when building this kind of application?