Safely remove domain event classes

Hi

Is there any way or workaround to safely remove obsolete domain event classes (or attributes), so XML serializer won’t complain when class or field is not found?

Thanks

Hi Nedo,

in which Axon version? There are different approaches for Axon 1 and 2. They both involve creating an upcaster.

Cheers,

Allard

Hi Allard

It’s for Axon 1.4. Thanks :slight_smile:

Hi Nedo,

unfortunately, in Axon 1.x there is no beautiful solution. A team at Trifork has created a nice workaround for this one, which is pretty simple to implement.
They had created an empty event class (no additional fields). This event is not used anywhere, Then, they use an upcaster to “upcast” all deprecated events to this dummy event. They do so by renaming the root element name to the fully qualified classname of the "dummy"event en remove all child elements, expect for the aggregate identifier and sequence number.

The result is that the serializer will create an instance of the dummy event, for which there are no handlers anyway. The event is then practically ignored.

In Axon 2, the upcaster can simply return an empty list (the result of an upcaster is always a list of events), telling Axon that an event is deprecated.

Cheers,

Allard

You might have figured this out by yourself already, but I have attached a code example (TipEventUpcaster.java) for ignoring old event types.

Then we injected this upcaster into XStreamEventSerializer in the JpaEventStore.

TipEventUpcaster.java (1.98 KB)