I’m trying to migrate from Axon 2.4.5 to Axon 3.4
Old EventStore API uses the aggregate type.
New EventStore doesn’t take aggregate type into account.
So, events for aggregates of different types but with the same aggregate identifier are mixed.
E.g. aggregates Client and Performer with the aggregate identifier “Unknown”.
On loading any of them clientAggregateRepository.load(“Unknown”) tries to reconstruct Client with both event types ClientEvent and PerformerEvent. Because events are read just by id.
And the “IncompatibleAggregateException: Aggregate identifier must be non-null after applying an event. Make sure the aggregate identifier is initialized at the latest when handling the creation event.” is the natural result.
What am I doing wrong?
@Bean fun eventStorageEngine(mongoTemplate: MongoTemplate): EventStorageEngine = MongoEventStorageEngine(JacksonSerializer(createMapper()), null, mongoTemplate, DocumentPerEventStorageStrategy())
@Bean fun eventStore(eventStorageEngine: EventStorageEngine): EventStore = EmbeddedEventStore(eventStorageEngine)
@Bean fun clientAggregateRepository(eventStore: EventStore): AggregateRepo = EventSourcingRepository(Client::class.java, eventStore)
@Bean fun performerAggregateRepository(eventStore: EventStore): AggregateRepo = EventSourcingRepository(Performer::class.java, eventStore)
Should some filter be applied to events somewhere?