Retrieve another aggregate's data


let’s suppose I have an ordering system with two aggregates Order and Product each implemented as separate microservice.
What is the best approach to retrieve product information from Order?
Should the Order listen to events from Product and build its own data model or should the Order contact the Product microservice via API and request product details?



Hi Pavel,

Aggregates cannot handle events from own another, as Aggregates are the ‘Command Model’ in your system.

As such, they only deal with handling commands. They might additionally deal with their own events if you choose to do Event Sourcing for your Aggregates.

What you’re asking here, is how to Query information from one part of your system.

In a typical CQRS set up, you would have a Query Model dedicated to answering that exact question.
The Query Model in turn is updated by a service which handles events.

Then, to actually retrieve the data, I would personally suggest to leverage Query Messages.
Doing so will allow you to isolate your Product micro service and Order micro service in regards to the domain events they themselves publish.
For both services requesting data from one another, you can then use a query message.

That’s my two cents.