axon kafka serailization error

Hi,

I was exploring axon-kafka component to distribute events.

I have changed my event store and query side data store from mongodb to mysql and i am getting this error.

com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.axonframework.kafka.eventhandling.consumer.KafkaTrackingToken and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS).

Please help!!

Thanks in advance…

Hi Saikat,

it seems that the KafkaTrackingToken isn’t compatible with the JacksonSerializer. We generally recommend using the XStreamSerializer for everything but messages. When using Spring, you annotate your JacksonSerializer with @Qualifier(“messageSerializer”) and when using configuration API, register it as Message Serializer in the Configurer.

That should do it.
Cheers,

Allard

Yes, its works for me below is my configuration with mongo as event store using KafkaTrackingToken

Code Snippet:

@Qualifier("mapper")
@Bean
public ObjectMapper objectMapper() {
    return
            new ObjectMapper()
                    .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
}

@Qualifier("messageSerializer")
@Bean
public Serializer messageSerializer(@Qualifier("mapper") ObjectMapper objectMapper) {
    return new JacksonSerializer(objectMapper);

}

The full code can be found : https://github.com/SanjayaKumarSahoo/axon-spring-cqrs-how-to

Thanks Allard.

axon.serializer.general=XSTREAM

This configuration has solved the problem.

I have one more question.While using mysql there is a table that gets created while bootstrapping - token_entry where the token is kept and updated.

But in mongo there was no such collection that gets created.So in that case how axon manages the Token Store… In memory?

Hi Saikat,

If you’re in a Spring Boot environment, using Mongo, I’d expect that the MongoTokenStore would be created for you.

The MongoTokenStore is in charge of storing the tokens.

I hope this addresses your concern!

Cheers,
Steven