0

I work with CQRS and Event Sourcing to project my entity in multiple steps, so every time I send a command to project an attribute After the last command, I want to display all the details of my entity using an API (getMyEntityById). The problem is that some fields in the response API are NULL and it makes sense because the projections are not complete in background. How can I detect that the update of my Entity is complete so that I can display it without getting null ?

1 Answers1

0

You can check in the query handler if any field is still null. And only send a response once it's not the case anymore?

To do this efficiently you need something like a PendingQueriesMap, with id as key, and completable future as value.

For any event, after updating the projection, you can check if it's in the map, and if the projection is now complete, complete the future, thereby sending it over.

Gerard Klijs
  • 211
  • 2
  • 4