spring-bootaxon

How to upcast events with Axon Server?


I'm relatively new to the Axon Framework and just evaluating if the framework is suitable for a project of me. Versioning of events is described in this post. But in the example the EventStore is changed to Jpa. Is it possible to upcast events with Axon Server as event store? Or did I misunderstand something?


Solution

  • The Upcaster logic provided by Axon Framework is in no way biased to the type of EventStore backing your application. It is thus perfectly doable to provide an UpcasterChain to the AxonServerEventStore, containing the EventUpcaster implementation you have written.


    Upcaster Registration Update

    Nicolas asked the following as a follow-up on my response:

    But the upcaster is only applied for the service that contains it. So is it possible to register an upcaster globally or do I have to implement it in every service connected with the Axon Server?

    Axon Server will not delegate registered Upcaster instances throughout the connected Axon Server Clients (aka, the Axon Framework implementations). It doesn't because you could have a heterogeneous deployment of services, one with old event versions and one with the most recent version including such an Upcaster.

    Think about it from a Blue-Green Deployment strategy, or a Rolling-Upgrade approach; you wouldn't want Axon Server to push the upcasters to the clients directly, as the client should be in charge of the exact version they're interested in.

    Having said this, you would thus have to share the upcasters together with your messages, as part of your API so to say. This would be a requirement for an Axon application regardless of whether you'd use Axon Server. Having said that, this is the case for Axon Server for at least (the upcoming) version 4.3. I do not know (yet) whether such a feature will be added in the future.