How to customize Event Payload Type for Event Sourcing?


at the moment I can see, that Axon uses the fully qualified class name as Event Payload Type. For example “”.

This means that it’s impossible to refactor the event code, rename class names oder move classes to a different package.

Is there any simple way to define the Event Payload Type?

For Aggregates we can simply use “@Aggregate(type=“MyAggregate”)”. Is there anything similar for events?

Kind regards,

Hi Benjamin,

There are a couple of things you can do in this situation, all depending on the state/set up of your application.

If you are using XStream to de-/serialize your events, you can simply create aliases for the payload types.

I’d like to refer to the XStream GitHub page on how to approach this.

If you are using Jackson for the de-/serialization of your event messages, you could go the route of providing your own dedicated implementation of the JacksonSerializer and overriding the JacksonSerializer#resolveClassName(SerializedType) function. There you can specify how you’d want your payload types to be adjusted in certain scenarios.

See this section in the reference guide as well for some insights in influencing the serialization process.

If both of those aren’t an option at this point, you can also implement very simple upcasters which only upcast the payload-type of a given Event Message.

I hope this clarifies some of your concern Benjamin!


Hi Steven.

Thank you. Of course it’s possible to write a custom de/serializer. But I think it would be much better if Axon provides this out of the box.

Or is there any reason, why Axon doesn’t provide some kind of @EventType annotation? This would be much easier to use. And it would feel convenient in combination with the @Aggregate(type=...) annotation.

Hi Benjamin,

As your question arose, me and a colleague of mine were thinking the exact same thing as you are - why isn’t this easier?

To that end my colleague has introduced an issue which we’ll be discussing soon.

You can find the issue here if you’re interested.

A part from that, I am sorry I cant give you an easier solution than what I’ve provided earlier.


Thank you!

Then let’s “close” this issue here and use the github issue you created.