Issue with Appender.deleteEvent in Transformation API and Re-inserting Events

Hello Axon Community,

I’m experimenting with the Axon Framework Transformation API to clean up my event store by removing specific events. In particular, I want to delete all events related to a specific metadata tag, e.g., all events for employer X.

I’ve been using the Appender.deleteEvent() API within the Transformation API to accomplish this, and that part works as expected—the events are removed from the event store.

However, I run into an issue afterward: when I attempt to receive a new initial load (replaying or re-importing events) that contains events for the same employer X, Axon Server rejects them with an error stating that the aggregateId - sequence number combination already exists.

It seems that deleteEvent() does remove the event from the visible store, but the sequence numbers for aggregates are still considered taken, preventing re-insertion.

My questions:

  1. Is this expected behavior in Axon Server?
  2. Is there a recommended way to completely remove events and free up sequence numbers for an aggregate?
  3. Could this be a limitation of the Transformation API, or am I missing a proper procedure for “re-importing” cleansed events?

Any guidance or suggestions on how to safely delete events for a specific aggregate and allow future events with the same aggregateId to be inserted would be greatly appreciated.

Thanks in advance!

1 Like

Hi Rhino,

This behaviour is by design. When you delete an event from the store, its content is deleted, but information like aggregateId, aggregateType, and aggregateSequenceNumber stays untouched.

You want to reuse the aggregateId and start over. However, there are cases where you want to delete only a particular aggregate event, and then the sequence numbers are valid. It is safer for the implementation to assume the latter.

I’d suggest you use another identifier for that specific employer.

Cheers,
Milan