Search code examples
axonaxon-framework

Axon Framework: Convert XStream serialized events to Jackson Serializer in existing application


We have an application that was written using the Axon Framework. Based on the issues we are having with XStream, the idea of converting to the Jackson serializer has been proposed.

Is it possible to convert the current events in the event store to a JSON representation using configuration options in Axon or are we going to have to handle this manually?


Solution

  • Axon Framework, nor any of the extensions, provide something out of the box to achieve this. The most straightforward way to rewrite an event store is to write a basic event handling application that reads from store one and writes (with the desired adjustments) to store two.

    From an effort perspective, that's something like this:

    • Construct basic Axon Framework application, reading from current XML store.
    • Configure the second EventStore in your application separately from Axon's Configurer. This second store's EventStorageEngine should receive the JacksonSerializer, whereas the default store should use the XStreamSerializer
    • Write an event handler that handles all events, keeping things like the timestamp (very important) intact. This handler should 'append' events into store two.
    • Start the application. The default Streaming Event Processor will read everything, give it to your Event Handler, that'll provide them to the second store.