Axon stores events as XML instead of JSON

I’m new on Axon framework and i want to configure Axon in order to store events as JSON. I’m using Spring-Boot and, as per documentation, i set some key/value in a .properties file

I expected to see events stored as JSON but i keep seeing XML in the serializedPayload of the MongoDB event store. I think I have configured the serilializers correctly but obviously I’m doing something wrong

Please note that debugging the application it seems that JacksonSerializer class is never invocated and instead XStreamSerializer class is called even my key/value configuration. So i need to understand why my jackson configuraton is not calling the right serializer

Hi @matteo.bruni,

I see you also asked this on stackoverflow.

I’ve provided all the info there but I am just going to copy it here for others!


You have to configure the MongoEventStorageEngine to use the Serializer you want.

Looking at it’s Builder (specially the javadoc), you can see it offers a snapshotSerializer and a eventSerializer methods while the javadoc states that both of them defaults to XStreamSerializer.

If you need help configuring it, I can point you to the mongo-axon-example where you can see a project configured and running.
The example is not using Jackson but it should be an easy addition to configure it here.

1 Like