How do you properly configure snapshots for Aggregates to occur after 3 events in Axon 4.2, using the most basic out-of-the-box setup?
We’ve read countless posts and the Axon documentation over and over. The tables are created and nothing is being written. Most of the time, we get Spring issues when starting the app. Here’s the gist of what’s been done.
-
Followed a simple https://www.baeldung.com/axon-cqrs-event-sourcing example of Axon. Great tutorial to get started for those familiar with the ES concepts, and looking for a quick start.
-
Enabled JDBC persistence by exclude a dependency in the pom, added sqlserver driver, and properly configured application.properties. Regular events are persisted as expected.
-
We added annotation to the Aggregate to define the trigger
@Aggregate(snapshotTriggerDefinition = "mySnapshotTriggerDefinition") public class OrderAggregate {
and created a config class with what we believe to be the basics according to the documentation.
`
import org.axonframework.eventsourcing.EventCountSnapshotTriggerDefinition;
import org.axonframework.eventsourcing.SnapshotTriggerDefinition;
import org.axonframework.eventsourcing.Snapshotter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class AxonConfig {
@Bean
public SnapshotTriggerDefinition mySnapshotTriggerDefinition(Snapshotter snapshotter) {
return new EventCountSnapshotTriggerDefinition(snapshotter, 3);
}
}
`
and we see the message of:
`