Hi all,
We have the following case:
-
Service which accepts the request and asynchronously process it (returns acknowledgment immediately, and after processing issues a command which contains the result: SupplyResultCommand)
-
Command for starting the business transaction: StartBusinessTransactionCommand
-
Command handler for StartBusinessTransactionCommand command which does the following:
-
Applies the event that business transaction is started: BusinessTransactionStartedEvent
-
Reaches out to multiple instances of Service and requests a processing
-
Event sourcing handler on BusinessTransactionStartedEvent which updates the aggregate (sets aggregate id among other updates)
Since command handler is in one UOW (Unit Of Work) meaning that transaction is not committed (not persisted to the database) until event sourcing handler finishes and services are reached out, there is a race condition that one of services issues a SupplyResultCommand before UOW is done (persistence to the database happened) causing exception that aggregate is not found. What is the best way (using Axon building blocks) to solve this issue?
Thank you!