public interface DomainEventConverter<SOURCE extends DomainEvent,
TARGET extends DomainEvent> {
public TARGET convert(SOURCE sourceEvent);
}
The EventStore can use it to transform old events into their new
counterparts when loading events.
The same may be a good idea for Commands. A command conversion could
be done before the command handler is called. This way the conversion
(old 2 new command) is separated cleanly from the handling itself.
Upcasters are certainly helpful and I've created a few of my own. I
did get caught with the new "metaData" element and I did find the
LegacyAxonEventUpcaster class. However I have never found any
reference to the Axon codebase where a "revision" attribute was
attached to the root node.
Should the line which reads:
if (rootNode.attribute("revision") == null) {
be changed to this:
if (rootNode.element("metaData") == null) {
I made the change locally to convert v0.6 event sources to 0.7-current
without causing problems to existing 0.7-current events. Otherwise I
was receiving an error that 0.7-current messages had a duplicate
"metaData" element.
You're right, the check is wrong. I am still figuring out what the best way to get the revision number of an event is, abstract method, protected field, etc. In the end, a check on an explicit revision number is safest.
If anyone has an idea, don't hesitate to let me know.