Full snapshot of all aggregates

Hello dear friends,

We tried to get a full snapshot of all aggregates but there is discrepancy between the quantity of unique Aggregate IDs in the events table and snapshots table.

  1. We are getting AggregateIDs from

select d.aggregateIdentifier from DomainEventEntry d where d.type=:aggregateName group by d.type,d.aggregateIdentifier order by d.timeStamp

  1. Using AggregateIDs from the first request we create snapshots for each of it: org.axonframework.eventsourcing.Snapshotter.scheduleSnapshot(Aggregat.class, aggregateIdentifierId)

  2. Comparing number of snapshots with unique AggIDs, there is a discrepancy of 31000 to 39000. Number of snapshots are less.

What we are doing wrongly?

Thanks,
Rashid

Hi Rashid,

I am unable to deduce from your current scenario what you might be doing wrongfully.
What stands out is your request to make “full snapshots of all aggregates”.

Why do you need this? What’s the end goal you are trying to achieve with these snapshots?
Note that snapshots are intended to speed up the loading process of an Event Sourced Aggregate.
They are typically only required if loading takes to0 long, which you might notice after 250 distinct events have been published for a given aggregate instance.

This threshold of 250 events is what you would use in the snapshot trigger definition.
This SnapshotTriggerDefinition (i.e. the EventCountSnapshotTriggerDefinition implementation) can be configured on your Aggregate in two ways:

  1. On the AggregateConfigurer, by using the configureSnapshotTrigger method.

  2. When using Spring, by creating a SnapshotTriggerDefinition bean which you reference in the @Aggregate annotation’s snapshotTriggerDefinition field.

Thus calling the Snapshotter directly like you are suggesting in your comment is not a necessity at all.
Hope this piece of background helps you further Rashid!

Cheers,
Steven

Rashid,

also note that the snapshotter does not store a snapshot is only a single event was loaded to create the aggregate state. Could it be that some aggregates’ streams have no more than one event?

Kind regards,