Skip to content

Document best practices for Eventual Consistency #189

Description

@niko5

I am wondering if there are any best practices for implementing the UI where there is eventual consistency with Neos.EventSourcing and Neos.Flow.

At the moment with immediate consistency I post a Command, from a Fluid form, which is handled by the Command Action Controller this either loads the aggregate directly (or using a CommandHandler) completes the request then I am redirect to the query side which loads the page with the updated view. This all works fine when everything is synchronous.

However when moving to asynchronous listeners and projections what should one do? Here are some ideas of mine at the moment.

  1. You could do the same as above but put a delay time with the redirect (defaults to 0) which may give the read model a chance to update - but this is effectively blocking.
  2. A slightly more sophisticated way is to perhaps get the aggregate id and version number prior to making the call on the aggregate. This gets stored in the read model (somehow) and then the wait on the redirect until the aggregate version has increased or we time out .
  3. Don't have a redirect and return a Response object from the Action Controller with either OK response (200) with the Aggregate id and version prior to the update (the command is executed synchronously) or an error say 406 if Aggregate constraints are violated. This will then leave it for the UI to decide what to do eg it decides what view to call again perhaps using the the Aggregate version and id to make sure it is unto date.
    ...

These are just some ideas that I am kicking around

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions