Force the entity creator of an aggregate created if missing
ProprietaryAxon Framework 4 created a missing aggregate through its no-argument constructor for a command handler annotated @CreationPolicy(AggregateCreationPolicy.CREATE_IF_MISSING). AxonIQ's recipes remove the policy and annotate that constructor with @EntityCreator, which Axon Framework 5 does not invoke while the entity has no events, so the command fails with EntityMissingForInstanceCommandHandlerException. The no-argument @EntityCreator of such an aggregate becomes @ForcedEntityCreator, which Axon Framework 5 provides for create-if-missing handlers. With it, every instance command handler of the aggregate runs on a newly constructed entity when it has no events, where Axon Framework 4 rejected the commands of the handlers without the policy.
io. moderne. axon. ForceEntityCreatorForCreateIfMissingmod run . --recipe= io. moderne. axon. ForceEntityCreatorForCreateIfMissingInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.