[axonframework] Re: Clarification as to why aggregates are not meant to be queried.

Hi Robert,

I’d only mark querying Aggregates “a smell” if you are pursuing CQRS in your implementation.
If you are, that means you should segregate the Command Model and Query Model from another, both with their own purpose within the application.

The Aggregate implementation within Axon Framework follows the focus of supporting the Command Model and thus should not be used to query.

However, it is perfectly fine to not segregate the command and query model from another.
Then you can simply use your Aggregate for both handling commands and handling queries.
A state-stored aggregate would be a reasonable approach to take if you want to query the Aggregate’s state for example.

So, whether you would state Aggregate Querying as a code smell highly depends on whether you want to do CQRS.
From an evolutionary microservices approach, thus being able to split the application in smaller components at a later stage, I can tell you it is beneficial to have this command and query model segregation.

All this is however a choice you can make within your own implementation.

That’s my two cents on the situation.

Cheers,
Steven