0

Here is my use case:

case class Organization(id: String = UUID.randomUUID().toString, userId: String)
case class OrganizationState(organization: Option[Organization])
case CreateOrganization extends OrganizationCommand
case OrganizationCreated extends OrganizationEvent
class OrganizationEntity extends PersistentEntity[OrganizationCommand, OrganizationEvent, OrganizationState]

POST /organizations?userId=1 <= creates an organization associated with user 1
GET /organizations?userId=1 <= retrieves all organizations associated with user 1

How can I implement my service in order to insure consistency ?

I try using a CassandraReadSide to maintain a table mapping userId with organizationId but this table is eventually consistent. Do I need to create another Entity with the userId as entityId ?

In fun-cqrs, there is the Projection.onEvent that allows to know when an event was processed by a projection.

See https://groups.google.com/forum/#!topic/lagom-framework/JG71x5W5h7I

Thomas Pocreau
  • 470
  • 5
  • 12

1 Answers1

0

Readside is the answer as you point out. It is of course eventually consistent. Alternatively you can create another entity and have one entity directly invoke the other but it will still be eventually consistent from the perspective of the client.

The question you have to ask yourself is why the POST and GET have to be immediately consistent? There are ways of accomplishing this but the trade offs you make would usually impact performance and may not align with lagom.

dres
  • 1,172
  • 11
  • 15