Serialization issue

Hello, I am new to Axon. I have a few events stored in domain_event_entry. I am using SpringBoot to develop a new project, but while reading, I am getting an exception. I have two questions

  1. How can i read payload (store currently in XML format) & deserialize it ?
    i tried EventStore.readEvents(...) method , but i am getting
Could not deserialize the message. The serialized type is unknown registeredCreatedEvent (rev,null)

i have this payload as XML in domain_event_entry

<registrationCreatedEvent>
	<regId>78638e33d3b</regId>
	<registrantReference>CHAR</registrantReference>
	<definitionAndValues>
......etc

My configuration in application.properties

#axon.serializer.general=xstream
#axon.serializer.events=xstream
#axon.serializer.messages=xstream

I tried for java and jackson as well
I have created a DTO class RegistrationCreatedEvent and subclass for all subtags, but I am not sure how to pass this class as an argument for deserialization

  1. How to read payload in domain_event_entry in the fastest way with deserialization?

Hello @satya,

You are describing the correct way to retrieve events manually. Normally they are retrieved for you automatically by Axon Framework when loading an aggregate.

The fact that you’re getting an unknown serialized type is strange. Did you move the class between applications starts? The fully qualified classname (so including package) needs to remain the same so Axon Framework can find the class to deserialize to.

yes @Morlack application starts, i am trying with annotations binding, will let you know if i get into it. Thanks.

Looking at your edited post, I can spot the problem. The registrationCreatedEvent type in your XStream document is not know. You have to create an alias in XSteam pointing registrationCreatedEvent to the actual class.

You can find more about aliases in the XStream documentation. In addition, you can read about how to configure the Serializer in Axon Framework here.

thanks @Morlack , can you suggest , how can you directly deserialize while iterating ?
I am gettting exeception when domainEventMessage.getPayload() method is called.
Note: we are in old framework of axon 2.4.X

DomainEventStream domainEventStream = eventStore.readEvents("EventSourcedRegistration", testDevKey);
            while(domainEventStream.hasNext()){
                DomainEventMessage domainEventMessage = domainEventStream.next();
                System.out.println(domainEventMessage.getIdentifier());
                String payload = (String) domainEventMessage.getPayload();
                System.out.println(payload);

            }

I am getting

Exception occured in getRegQuick:org.axonframework.serializer.UnknownSerializedTypeException: Could not deserialize a message. The serialized type is unknown: registrationCreatedEvent (rev. null)

this is my bean

@Component
public class ExportXStreamSerializer extends XStreamSerializer{

    @Primary
    @Bean
    public Serializer defaultSerializerAxon() {
        XStreamSerializer xStreamSerializer = new XStreamSerializer();
        xStreamSerializer.addAlias("registrationCreatedEvent", RegistrationCreatedEvent.class);
        xStreamSerializer.addAlias("registrationSignedEvent", RegistrationSignedEvent.class);
        xStreamSerializer.addAlias("definitionAndValues", DefinitionAndValues.class);
        xStreamSerializer.addAlias("values", Values.class);
        XStream xStream = xStreamSerializer.getXStream();
        xStream.ignoreUnknownElements();

        xStream.addImplicitCollection(Values.class,"variable", Variable.class);
        //<values> tag attributes
        xStream.useAttributeFor(Values.class,"id");
        //<regDefReference> tag attributes
        xStream.useAttributeFor(RegDefReference.class,"key");
        xStream.useAttributeFor(RegDefReference.class,"version");
        //<variable> tag attribute
        xStream.useAttributeFor(Variable.class,"id");
        xStream.useAttributeFor(Variable.class,"state");
        xStream.useAttributeFor(Variable.class,"type");
        xStream.useAttributeFor(Variable.class,"value");
        //xStreamSerializer.addFieldAlias();
        return xStreamSerializer;
    }

In DB domain_event_entry table inside payloadtype column i have registrationCreatedEvent .
Is there any way we can specify package name where all our dto classes are present to be deserialized ?
How can I prefix some package name infront of value of payloadtype column ?
E.g. com.org.datatest.dto.registerCreatedEvent , not in DB , i want this to be in runtime.