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.
- 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.
- 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 .
- 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
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.
...
These are just some ideas that I am kicking around