Configuring a Custom Deserializer for EventMessage Deserialization

I’ve configured a KafkaPublisher bean to use a custom KafkaMessageConverter implementation which uses an a custom Avro Serializer to (des)serialize events. This has been working without error so far, however, when try to add an avro field whose type is “long”, we start seeing XStream conversion errors. It’s as if it can’t convert from bytes to a long. See the stack trace at the bottom of the post. Adding the following Avro field causes the exception.

"name": "seenDate",
"type" :{ "type" : "long", "logicalType" : "timestamp-millis", "default": -1 

As you can see in the stack trace, LazyDeserializingObject is still configured to use an XStream Serializer. How can I configure the underlying implementation of EventMessage.getPayload() to use our Avro Serializer? We are relying on the schema class of the event message payload to determine what topic to send the message to, hence the call to EventMessage.getPayload(). We’re investigating other solutions to determining the topic in the meantime, but any advice is welcomed.

---- Debugging information ----
cause-exception     : java.lang.ClassCastException
cause-message       : [B cannot be cast to java.lang.Byte
class               : <omitted>
required-type       : <omitted>
converter-type      : com.thoughtworks.xstream.converters.reflection.ExternalizableConverter
path                : <omitted>
line number         : 1
version             :
            at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(
            at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(
            at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(
            at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(
            at com.thoughtworks.xstream.core.TreeUnmarshaller.start(
            at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(
            at com.thoughtworks.xstream.XStream.unmarshal(
            at com.thoughtworks.xstream.XStream.unmarshal(
            at com.thoughtworks.xstream.XStream.fromXML(
            at org.axonframework.serialization.xml.XStreamSerializer.doDeserialize(
            at org.axonframework.serialization.AbstractXStreamSerializer.deserialize(

            at org.axonframework.serialization.LazyDeserializingObject.getObject(
            at org.axonframework.serialization.SerializedMessage.getPayload(
            at org.axonframework.messaging.MessageDecorator.getPayload(

Hi @blackcompe,

You can configure your serializers to use any Serializer you want - in your case, configuring it as the should do the trick for you. You can find more info here.

But, we are very much interested on your implementation of the AvroSerializer. Have you based it on our Serializer interface? If that is the case, it would be a valuable addition to the Framework and a PR for that would be awesome!