I've seen this kind of architecture before. It sounds nice but is loaded with consistency problems.
I've seen this kind of architecture before. It sounds nice but is loaded with consistency problems.
https://chrisrichardson.net/post/sagas/2019/08/04/developing...
You receive a message "{entity}Created" and it contains the Id of the full object.
The feedback flow is async from the creation flow.
If you get created through the feedback flow it's created.
There's also many ways to "work around it", so that it doesn't seem inconsistent to the user.
I'm definitely not arguing that it's how most systems should be designed though.
A slightly more sophisticated pattern is to have the initial creation command return an ID of the creation event. Then the client can poll that ID and just check that the event has been processed successfully. This requires the client to trust the server a little, but it means it can just poll a small, temporary, probably in-memory "recent events" table instead of hammering the main API.
A more efficient design is to YOLO, submit the second command while the first is still being processed, and trust the server to handle the commands in the right order. This is fine for backend services, unfortunately human users get annoyed at their frontend when it says "sorry you have to do the purchase finalization again because an earlier 'add to cart' command failed and I only noticed it now".