Understanding 'markDeleted' when using Axon Server

The documentation for the markDeleted method states:

Marks this aggregate as deleted, instructing a repository to remove that aggregate at an appropriate time.
Note that different repository implementations may react differently to aggregates marked for deletion.
Typically, Event Sourced Repositories will ignore the marking and expect deletion to be provided as 
part of Event information.

I have two questions:

Q1: What exactly is the effect of calling markDeleted() on an aggregate using event sourcing and Axon server?

Is it just that future commands and events routed to that aggregate will be rejected? No actual deletion of events will ever take place right? But Axon Server will somehow store that the aggregate is deleted? How does it do that? In the metadata of the last event or something?

Q2: Is it possible to see if an aggregate has been ‘marked deleted’ in the Axon Server UI?

Perhaps a setting which changes the background colour for the row containing the event which triggered the deletion to red or something to that effect?

1 Like

Hi,

as far as I understood and also experienced during debugging, the deletion of the aggregate is not persistent in any way for an event-sourced aggregate. The markDeleted() is only executed when re-hydrating the Aggregate from it’s events and marks the Aggregate instance as deleted in memory - thus rejecting future commands which then would also not allow to add additional events to it.

Regarding your second question I would assume that in that case you would not be able to actually see if an aggregate has been deleted directly (also because there are only events represented) - but i think you could easily query for the respective *DeletedEvent(s) for the aggregate to see if one is present.

Best Regards,
Jakob

1 Like

Thanks Jakob, you confirmed what I thought was true. :slight_smile: