I'm a rails developer that recently found ES + CQRS via some high level talks on youtube. I'm sold on the potential benefits, but stuck on details.
The event itself, for example, looks like it needs an aggregate ID. So events always happen to aggregates. But what is producing this aggregate creation event? How do I know if the aggregate exists or not?
Let's say I have a cron job that is periodically importing orders from a 3rd party system like eBay. I don't want to duplicate orders, I want to upsert them.
In event sourcing I probably want a domain event like OrderCreated or OrderShipped. If the order isn't in the system I want OrderCreated, but if the order exists, I want to generate some other change like OrderCanceled or OrderShipped etc.
Greg mentioned in one talk that the only thing we would ever query the event store by is the aggregate ID. But if I don't have the aggregate ID, how do I look it up? Would I look at projections from the command handler?