I’m not sure why this would fail. Do you use a batch size for the event processor, can you set it to 1? Does that ‘fix’ the problem? Transactions in Mongo work less straightforward then with SQL, being added later on. Which database do you use, and do you use the spring boot starter from the Mongo extension?
I used spring boot, axon server and mongodb as database, and yes i use axon-mongo-spring-boot-starter
The two events CatalogAdded and NoteAdded are not in the same processing group (i updated my post), does this cause a problem ?
Can SequentialPolicy fix the problem?
How can i set the batch size and how can it fix the problem ?
event processor config:
final TrackingEventProcessorConfiguration tepConfig = TrackingEventProcessorConfiguration
.forSingleThreadedProcessing().andInitialTrackingToken(StreamableMessageSource::createHeadToken);
configurer.registerTrackingEventProcessor(CATALOG_INIT_EVENT, it -> MultiStreamableMessageSource.builder()
.addMessageSource(myContext, (axonservereventstore).createStreamableMessageSourceForContext(dsContext)).build())
.registerTrackingEventProcessorConfiguration(CATALOG_INIT_EVENT, config -> tepConfig);
If they are not in the same processing group, it makes a lot more sense. I’m that case both changes happen about the same time. I would prefer to keep any handlers updating/creating the same entities/documents in the same processing group. This way you should also be able to properly reset the handler, by throwing all the documents away, en read all the events again.
i have a two different processing groups, one for catalog and the other for sku, so when i duplicate the event handler of NoteAdded in the two processing groups, when the NoteAdded event is dispatched it is treated 2 times, one time in the processing group of catalog and the other time in the processing group of sku, for this i put it in a separated processing group to be treated only once