We are facing the following situation and would love to hear the community’s take on it.
We have a domain event that represented an error scenario
Our business has decided that this error scenario is no longer necessary
Because of this, we would like to remove the Java class for the event
However, if we remove the Java class Axon will throw errors while trying to de-serialize the payload for this event that already exist in our event store.
Upcasting is definitely the approach we were going to follow. What I was going for was upcasting it to an explicit NoOpsEvent. Is there any particular reason to upcast to an empty list?
by upcasting to an empty list, you’re explicitly indicating that the event no longer exists. When upcasting to a NoOpEvent, you implicitly mean the same thing, as no one is interested in a NoOp event.
So you achieve the same thing, but explicit always beats implicit in DDD
for the moment I favour the upcast to a NoOpEvent. My reason for this are event sequence numbers.
What happens if the to be removed event is the last one in the aggregate’s event stream? E.g you have event 1 (sequence no. 1) and event 2 (sequence no. 2) in the event store. We remove event 2 by upcasting to an empty list or null.
Now a new command comes in and event 3 is applied in the aggregate. Would that not cause the event 3 to have sequence number 2 beacause the event 2 was removed in the in memory event stream? This would break inserts to at least some event store implementations. It does not seem that the upcasting utils handle this case specially… or I did not find that code part.