I have a set of events that have been refactored to another package. This works as is until I execute the event replay. Digging deeper I noticed a payloadtype in the domainevententry table and figure changing this would be sufficient but alas it seems the xml root element of the event needs to be changed as well. I am hoping there is a simple way to do this.
I cannot find any examples on upcasting to different packages or using XStream aliasing so any help would be greatly appreciated.
Thanks
As you noticed, the default payload type stored in events is the fully qualified class name. This ensures that out of the box serialization and deserialization work as intended. However, moving classes around thus means the payload type can no longer be found, requiring some adjustment to be made.
You could have used the
EventTypeUpcaster, as referred to in the Reference Guide. TheEventTypeUpcasteris dedicated to adjusting the payload type, and thus can also be used to deal with changing package names.When using (the default)
XStreamSerializer, aliasing the tags would indeed also work. How to set aliases can be seen here for example. AS noticed in that sample, the alias is added to theXStreaminstance. TheXStreamSerializeruses anXStreaminstance to support de-/serialization from/to XML. To adjust theXStreaminstance, you can simply use the builder paradigm on theXStreamSerializer. The JavaDoc of the builder should be specific enough to help you out how to use it.