Retrieve Aggregates from Event Store

Hi all,

I am a newbie on CQRS and Axon. I am going to implement a request approval system via Axon Framework.
There is a use case scenario to approve a request with only request ID and user ID. Before triggering an approve request command, I need to check up the user’s role and the request status.
The user should have admin right to approve the request while the status of the request should be new.

However, should I retrieve the user and request aggregates from event store in command controller?
Or I should issues 2 queries in query side to get user’s role and request status from command controller?

Have you tried considering a saga ( with the following flow ?

UserAggregate: (command)RequestApproval -> (event)ApprovalRequested / ApprovalFailed(“user not an admin”)
Saga: (event)ApprovalRequested -> (command)ApproveRequest
RequestAggregate: (command)ApproveRequest -> (event) RequestApproved / ApprovalFailed(“request not in new”)

Kind regards,
David Stibbe

It works. Thanks for suggestion.

Hi Polly, David,

there are several ways to implement this, depending on your consistency and performance requirements.

While a Saga may work, it is a more cumbersome process, than simply executing a query. The advantage of this approach is that it is explicit and gives you more control on concurrency/consistency. At the expense of complexity.

However, if you just want to make sure a certain condition is met, you can simply execute a query to verify that. You can either execute that query from within the aggregate, or from an external command handler, before loading the aggregate.

Hope this helps.