Questions on payload revision

I’m working through some upcasting and I would like to understand how the revisioning is tracked and updated.
I’ve been experimenting with adding the different RevisionResolvers to the serializer for my upcaster.

What I’ve noticed is that if I add the FIxedValueRevisionResolver, then new events never have a version in the Domain_entry_table and every new event goes through my upcaster.
If I use the SerialVersionUIDRevisionResolver, the new event added after the old events have been upcast do not get upcast, but I don’t see any version in the Domain_entry_table
But if I use the AnnotationRevisionResolver, the version gets set for new event and new events never go through the upcaster.

Where is the revision being tracked if not in the payload_revision on the domain entry table?

I’m upcasting every event type in this upcaster and I don’t see where I would set the new revisionId. I’m using AbstractSingleEntryUpcaster

This is an example of my doUpcast method

protected Object doUpcast(SerializedObject intermediateRepresentation, UpcastingContext context) {

Document event = (Document)intermediateRepresentation.getData();

if (null != event.getRootElement().element(“seId”)) {

event.getRootElement().element(“seId”).setText(event.getRootElement().element(“seId”).getText().toUpperCase());

}

return event ;

}

Hi Carol,

the RevisionResolver is used to define the value to set as the “payloadRevision” in the EventStore. By default, this field is null.

When using the FixedValueRevisionResolver, it will always return the value you have defined in that Resolver. The AnnotationRevisionResolver (default) looks at the @Revision annotation on the class being serialized.

From your example, I take it that you’re using Axon 2?

Note that SerializedObject has a Generic type. It is the type of Data contained in the serialized object. The UpcasterChain ensures that the data type is converted to whatever is returned from the “expectedRepresentationType()” method. In your case, that should be Document.class.

That Serialized Object also contains a SerializedType, which is a combination of the name (fully qualified class name, by default) and the revision. Based on these values, you can decide whether you want to upcast the representation, or not.

Hope this helps.
Cheers,

Allard

Hi Allard,

Thanks for your patience as I try to work this out. I am using axon 2 and I’m trying to use the FixedValueRevisionResolver.

It’s successfully getting into my upcaster and upcasting the events. The issue is that new events after upcasting are created with null payload_revision, so they are always hitting the upcaster as well. I’m wondering if I’m missing a configuration. I define a new XstreamSerializer with a revision resolver for my upcaster chain. I don’t have the revision resolver defined anywhere else. Do I need to configure it somewhere else as well to get the payload revision added to new events?

Carol

Hi Carol,

did you configure the serializer on your Event Store instance?
You should see the payloadRevision in the Event Store tables being set to the value of your RevisionResolver. Upcasters don’t use the RevisionResolver anymore, because they need to know what the revision was at the time the object was serialized.

In fact, it is recommended to explicitly inject that Serializer instance in all the components that accept one.

If you have the chance to migrate to Axon 3, configuration is a lot simpler there (and the Upcaster API is more powerul).

Cheers,

Allard