I use prooph(https://github.com/prooph) so I have my write model, where I store events like below(aggregate table):
when I run projection in background using command:
php bin/console event-store:projection:run card_projection
I have read model like below:
In front of my background application I have rest API, where I create event:
CardWasAdded
through url:
POST /cards
and I receive code 201.
After that I refresh my list through url:
GET /cards
The issue is that sometimes this new event is not processed by projection. So the question is:
How to manage that issue?
My answer is not prooph specific, but here are some strategies you may use in any CQRS system:
With strategy 3 and 4 you may use some kind of server signaling - sockets or something like this. Your read model might be able to confirm it was updated.
Thank you Roman for your answer.
Finally I accepted fact that read model has delay.
In my rest api when I POST new resource I return 201 and json with new created Id and so on. My front application, based on response from POST new resource(POST /card), add new record to data table as new row, with "NEW" badge.
When user refresh the list, read model is ready(because building new record takes under 1 sec).
At the end there is no difference for user whether record is from
POST /cards
or
GET /cards
so user experience is fine.