Hello guys, I think this may be a bug or something not really supported.
Anyway, after customize my JpaTokenStore and JpaEventStorageEngine to use JacksonSerializer I got this exception:
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of org.axonframework.eventsourcing.eventstore.GapAwareTrackingToken: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: [B@5751442b; line: 1, column: 2]
So, I had to implement a CustomJpaEventStoreEngine to change the use of GapAwareTrackingToken on fetchTrackedEvents method to my own CustomTrackingToken (with a public Constructor) to make everything works fine again.
Makes senses?
public class CustomJpaEventStorageEngine extends JpaEventStorageEngine {
// ...
@Override
protected List<? extends TrackedEventData<?>> fetchTrackedEvents(TrackingToken lastToken, int batchSize) {
Assert.isTrue(lastToken == null || lastToken instanceof CustomTrackingToken, () -> String
.format("Token [%s] is of the wrong type. Expected [%s]", lastToken,
CustomTrackingToken.class.getSimpleName()));
final CustomTrackingToken previousToken = (CustomTrackingToken) lastToken;
// ...
Config:
@Bean
public Serializer serializer() {
return new JacksonSerializer();
}
@Bean
public JpaTokenStore jpaTokenStore(EntityManagerProvider entityManagerProvider) {
return new JpaTokenStore(entityManagerProvider, serializer());
}
@Bean
public JpaEventStorageEngine jpaEventStorageEngine(EntityManagerProvider entityManagerProvider,
TransactionManager transactionManager) {
return new CustomJpaEventStorageEngine(serializer(), null,
null, null,
entityManagerProvider, transactionManager,
null, null, true);
}