AggregateIdentfier generated by "legacy" system

How can I deal with axon in a scenario where the aggregate identifier exists only after an entity was created by an external system? Seems like I wont be able to send the command from the client since I do not have the id yet.
Can I still use an (external) commandhandler with reference to the aggregate repo? do I have to work with two commands (create external resource triggers create-aggregate command)? Can I work with a custom UnitOfWork? Would Saga be an option?

Background: I want to use axon aggregate to synchronize writes to the underlying system to benefit from locking and projections but cannot refactor the whole application to use aggregates/ES completely.


Hi Jan,

not entirely sure what you’re trying to achieve here. At the latest, the identifier of an aggregate needs to be known when the first event is being applied. So anytime before that, you can still decide on the identifier. In other words, an external handler can do a call to the external party, and with the result store some aggregate instance.

If you want your aggregate to be a reflection of (or gateway to) an external system, then I would not go for the option of making extra commands. Generally, you will regret these types of artificial (technology driven) solutions in the long term.