replaying events

Hello,

I’m trying to replay events using tracking processor.The events are loaded correctly from DB, the TokenEntry is updated in DB too, but in my EventSourcingHandler, only the object creation event (MessageCreatedEvent from examples) is passed to event handler.

I only use hibernate without Spring and Axon framework 3.1.1
this is my config and how i start the replay :

public TrackingProcessorService(EntityManagerProvider entityManagerProvider, TransactionManager transactionManager, EventStore eventStore, AggregateAnnotationCommandHandler<MessagesAggregate> messagesAggregateAggregateAnnotationCommandHandler, MessagesEventHandler messagesEventHandler) {
    this.entityManagerProvider = entityManagerProvider;
    this.eventHandlingConfiguration = new EventHandlingConfiguration()
            .registerEventHandler(c -> messagesEventHandler);

    this.eventHandlingConfiguration.usingTrackingProcessors();

    Configuration configuration = DefaultConfigurer.jpaConfiguration(entityManagerProvider, transactionManager)
            .configureAggregate(MessagesAggregate.class)
            .registerModule(this.eventHandlingConfiguration)
            .configureEventStore(e -> eventStore)
            .registerCommandHandler(c -> messagesAggregateAggregateAnnotationCommandHandler)
            .buildConfiguration();
    configuration.start();
}

public void startReplay() {
    String endOfReplay = getEndOfReplay(entityManagerProvider.getEntityManager());

    Optional<EventProcessor> processor = this.eventHandlingConfiguration.getProcessor(processorName);
    processor.get().registerInterceptor(new MessageHandlerInterceptor() {

        @Override
        public Object handle(UnitOfWork unitOfWork, InterceptorChain interceptorChain) throws Exception {

            if(endOfReplay.equals(unitOfWork.getMessage().getIdentifier())){
                processor.get().shutDown();
                return null;
            }else {
                return proceedWithReplay(interceptorChain);
            }
        }

    });
    processor.get().shutDown();
    processor.get().start();
}


annotating the event handler with @ProcessingGroup(processorName) does not seem to make any difference.

Thanks for help, much appreciated.

Am I missing the point of the Configuration? Should i setup the eventStore etc in a way i get it from Configuration first in order to make it play nicely?

Ok after few hours i found the problem… in SimpleEventHandlerInvoker.handle() method i received an exception i didnt know about - org.axonframework.serialization.SerializationException: Error while deserializing object

i don’t like the fact, the app didn’t crash right away with this exception…

Hi Tomas,

The exception should have been logged when the processor stumbled upon it. Wasn’t it?

Allard