Deleting events that are no longer relevant

Hi Allar,

As the domain model undergoes changes, I find myself with events that are no longer needed. The problem is I cannot remove them or serializing fails when Axon tries to recreate the aggregate via the events.

What’s the best way t deal with this scenario? Upcasting is the maturation of the event but what if the event is not needed at all?


P.S. Almost done with my 2.4.6 -> 3.0.5 migration!

I’d still use an upcaster for this. An upcaster maps each input event to an arbitrary number of output events, and 0 is a valid number of output events. In Axon 3 you’d do it by returning a filtered version of the input stream with a predicate that excludes the events you don’t care about any more. In Axon 2 you’d do it by having your upcaster return an empty list.


Hi Bjorn, Steven,

in such a case, it is recommended not to return zero events from a deleted events, but instead use a placeholder type. The problem is that the sequence number will also not be updated in the aggregate when an event is missing, causing conflicts when new events are added. This is only an issue when the last event is removed from the stream, which happens to be a realistic scenario.

By upcasting to a Void type (java.lang.Void) and changing the contents of the payload to (for XStream), you basically have a type that is usually not used by any handler.