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.
com.thoughtworks.xstream.converters.ConversionException:
---- 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 : 1.4.11.1
-------------------------------
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:77)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1487)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1467)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1338)
at org.axonframework.serialization.xml.XStreamSerializer.doDeserialize(XStreamSerializer.java:123)
at org.axonframework.serialization.AbstractXStreamSerializer.deserialize(AbstractXStreamSerializer.java:150)
at org.axonframework.serialization.LazyDeserializingObject.getObject(LazyDeserializingObject.java:102)
at org.axonframework.serialization.SerializedMessage.getPayload(SerializedMessage.java:77)
at org.axonframework.messaging.MessageDecorator.getPayload(MessageDecorator.java:56)
at