I have a simple scenario regarding CQRS and DDD in mind and I can't figure out the right way to implement it:
Order and Buyer are two aggregate roots inside Ordering service. When a user checks out the basket:
An integration event is raised in (basket) service.
It's handler inside Ordering service gets called.
Inside this handler, a CreateOrderCommand is created and dispatched.
The command handler instantiates an "Order".
As the result, a domain event is raised "OrderStartedDomainEvent".
Inside it's handler, the side effects regarding other aggregates (e.g. Buyer) must be applied: A Buyer is instantiated (if not exists already).
So, after this scenario, I want to change the order state. Changing order state requires a command. Where am I supposed to dispatch this command? From what I read so far, it's not appropriate to create and dispatch the command inside domain event handler.
Also, if I need to raise a domain event here, how can I do that? Since the Buyer constructor may not get called (if it already exists). So is it correct to raise a domain event inside a domain event handler?
I searched a lot but the previous answers were so complicated for me . I'd appreciate if someone clarifies. Thanks in advance.