Hi!
I saw your new “CreationPolicy” Feature in Axon 4.3. Due to your example
`
public class GiftCard {
public GiftCard() {
// Required no-op constructor
}
@CommandHandler
@CreationPolicy(AggregateCreationPolicy.ALWAYS)
public void handle(IssueCardCommand cmd) {
// An IssueCardCommand
-handler which will create a GiftCard
aggregate
}
@CommandHandler
@CreationPolicy(AggregateCreationPolicy.CREATE_IF_MISSING)
public void handle(CreateOrRechargeCardCommand cmd) {
// A ‘CreateOrRechargeCardCommand’-handler which creates a GiftCard
aggregate if it did not exist
// Otherwise, it will update an existing GiftCard
aggregate.
}
// omitted aggregate state, command handling logic and event sourcing handlers
}
`
we could use the CREATE_IF_MISSING policy. In contrast to your example, we have our CommandHandlers outside of the Aggregate class.
Can the annotation “CreationPolicy” be used in such a case, too?
I’m just wondering how Axon finds out what aggregate should be instanciated just by looking at the
TargetAggregateIdentifier
inside the command.