Snake-case and camel-case serialization in our event store. What could be the cause?


Today we have run into an error where an axon event could not be deserialized anymore because it was missing properties. After some investigation we have found that sometimes the event was serialized in camel-case and sometimes in snake case. Where as all the other events are all in snake case.

Our current best guess is that Axon Server sends events to our service before it is fully initialized and then decides to use snake-case instead of camel-case. Could that be the cause of this or is something else at play?

How does axon server determine what casing to use for serialization?


I am working in the same team as Jaco. We ended up looking into Axon Framework source code while investigating this problem. From it we concluded that there is some non-deterministic behavior going on when Axon Framework decides which Jackson ObjectMapper to use, and there are multiple ObjectMappers in the Spring context. In our case that meant that sometimes Axon-using microservice X got an ObjectMapper with snake case property naming, and Axon-using microservice Y got one with camel case property naming. Which meant they did not understand each others’ messages.

In an attempt to make the code in AxonAutoConfiguration.buildSerializer have a stable outcome for us, we adjusted our microservices’ Spring configurations to have yet another ObjectMapper bean, with name “defaultAxonObjectMapper”.

It does feel like a bit of a hack and a dependency on Axon Framework internal implementation details, but seems to have worked for now.