Serializing Sagas that contain Avro data


I’m integrating the SagaStore and EventStorageEngine components to our system,
And I’ve encountered a serious (and one that was destined to happen) problem when trying to serialize Sagas.
Currently I’m using the XStream serializer, which fails to serializes Sagas due to them having Avro objects, which have proven
To be not easily serializable (as they are not POJOs).

Has anyone encountered this case (working with Kafka of course), and managed to found a good solution, or at least a workaround?
I’m considering creating an XStreamSerializer that preprocesses the sagas to convert Avro objects to/from strings on serialization/deserializations.

Would love some help with this!

Also adding some info:


org.axonframework axon-core 3.3.6
org.apache.avro avro 1.8.1

We don’t use Avro specifically, but my team has had good luck implementing custom XStream serializers. The first one we wrote had a small learning curve and required a little bit of glue code, but nothing difficult. After the first one, additional ones were very quick and easy to write.

There’s no reason to avoid going that route in my opinion; XStream is easy to extend and adding custom serializers is a fully-documented, fully-supported process.

Some of our custom serializers haven’t even been for purposes of serializing otherwise non-serializable data, but just to shorten the serialized representations of frequently-used classes. While we use default serialization for most things, we don’t view custom serialization as an option of last resort. We have around 10 custom serializers at the moment and they’ve been totally trouble-free.


Actually I ended up writing an XStreamSerializer for Avro and it was quite easy and even fun.

The thing is that I also had to implement a TransactionManager, to work with Jpa, which I tried doing.

Although, looking at stackoverflow posts, it seems quite impossible to make this work without using Spring, which we don’t use…

בתאריך יום שלישי, 12 בפברואר 2019 בשעה 20:27:21 UTC+2, מאת Steven Grimm: