javaaxon

How to change payloadData format on axon server?


When Axon server is up, we can open browser and go to http://localhost:8024/#query On that page we can explore all commands and events. When we open event details we can see event fields in xml format. Can it be configured to display these fields in JSON format? How to do this?

enter image description here


Solution

  • The fact your data is in XML, is not a configuration option of Axon Server. This is your connected application, which I assume to be an Axon Framework application who's serializer is the default serializer.

    Axon Framework defaults to the XStreamSerializer, which will serialize to XML. As Axon Server is your event store, it'll show the serialized events as XML as your application dictates it so.

    If you want to change this to JSON, you must set your application's Serializer to a JacksonSerializer instance. I recommend checking out the Reference Guide for more specifics on the Framework's serialization approach and how you can configure this.

    Note that the already stored events cannot be changed from XML to JSON, since you cannot update events (according to the definition of an Event Store). So, if you're referring to a non-production environment, feel free to simply drop your event store.

    If this is production, you will have to deal with the XML events. In that case, you can still switch to JSON, mind you, but the old events cannot be updated. Instead, you will need to define a Serializer that (1) defaults to JSON and if it fails, reverts to XML.