Aggregate deleted, now what?

Hi all,

As far as I understand, once I mark an Aggregate as deleted, it won’t accept any other command.
But what about commands whose handler is annotated as @CreationPolicy(ALWAYS) or @CreationPolicy(CREATE_IF_MISSING)?
Are these commands accepted?

If so, can I safely exploit this lifecycle “trick” or should I avoid re-creating deleted aggregates?

Hi,
If you mark an aggregate as deleted, and later need to recreate this deleted aggregate, the two (the original aggregate (marked as deleted) and the newly created instance of that deleted aggregate) will always have different IDs. The newly created instance of the deleted aggregate is now a different entity with a new lifecycle.
The creation of an aggregate in, for example, AS will always fail, because the sequence number already exists in Axon Server.
You may instead want to flag it as “expired” instead of “mark as deleted” and change the end logic somewhere else to show that these events are “moved” elsewhere.
Allard (AxonIQ’s CTO) and I talked about this point during this podcast episode at around minute 45 of the episode.
I hope this helps.

1 Like