Reputation: 1019
I am using Lagom's persitent entity, and read side Cassandra support to implement, save the sate for read side queries. So trying to understand, are the persistent entities also actors? meaning only one event / command will be handled at a time ? Are events also messages the "persistent entity" handles? I could not find much documentation regarding the following:
If we go by a model in which the actor is removed after some timeout... Will the actor have to read all events again to handle another request ? Wont this increase the latency ?
most of the examples I saw were relating to implementing shopping cart / something similar. If adding items to cart is handled by commands / queries how is it ensured that the same item is not added onto the cart twice ? As read / update rely on different views / sources of truth. (I understand that this can happen in any app with concurrent users, but this scenarios seems quite frequently possible using Actors)
Upvotes: 0
Views: 540
Reputation: 16935
Are the persistent entities also actors? Meaning only one event / command will be handled at a time ?
I would not ask the question this way; actors do perform synchronous message handling, but that something performs synchronous message handling does not imply that it is an actor.
Now that the semantics are out of the way, we can address the question... PersistentEntity
s are technically not actors... However, PersistentEntityRegistry
s will create something that is a PersistentActor
.
- is every entity persisted in memory once created?
Entities are persisted in whichever store you use according to that Akka persistence snapshotting (see here) mechanism.
- If we go by a model in which the actor is removed after some timeout... Will the actor have to read all events again to handle another request?
Again, snapshotting will help considerably.
- If adding items to cart is handled by commands / queries how is it ensured that the same item is not added onto the cart twice?
You can read more about delivery semantics of Akka actors here.
Upvotes: 2
Reputation: 1468
Upvotes: 1