EventUpcaster for EventStore using Axon Server

Hi Folks,

what is the prefered way of registering event upcasters in the event store provided by the Axon Connector? I couldn’t find anything about it in the docs.

Another question, just to make sure I get it right - if my aggregates and event listeners live in different deployments, I will need event upcasters on both sides, right?

Cheers,

Simon

Hey Simon,

I am also interested in your question specially in the second part that I am thinking lately.

On my case I am registering upcasters along with @Bean EventStorageEngine in a config class, since I am using mongoDB it looks like this:

@Bean
public EventUpcasterChain upCasterChain() {
return new EventUpcasterChain(
new Event001Upcaster(),
new Event002UpCaster());
}

@Bean
public EventStorageEngine storageEngine(EventUpcasterChain upcasterChain) {
return MongoEventStorageEngine
.builder()

.upcasterChain(upCasterChain)
(…)
.build();
}

Now I am curious about the case when one have split deployments. My guess is that the read model doesn’t need to be aware about upcasters

Hi,

if you’re on Spring Boot, you can just define your upcasters in your application context. Use Spring’s @Order to make sure they are put into a chain in the right order.
You can also use the AxonConfiguration API to register your upcasters. The Configurer exposes a method to register an upcaster. The chain is formed using these upcaster in the order in which they were registered.
Lastly, you can also configure the upcasters on the AxonServerEventStore instance itself, using the appropriate builder method: AxonServerEventStore.Builder#upcasterChain

Regarding your second question: yes, if you have an upcaster, it may be necessary to include that upcaster in your projection project as well. Upcasters transform data on the fly, while it’s being loaded. That means nothing in the Event Store is actually altered. If you don’t, and your processor is being reset or is still catching up with events, your projections will just see the originally stored data. Whether it is required to upcast that depends on the information the projection needs.

Hope this helps.
Cheers,