How to know if Snapshot is created?

Hello!

I am not sure how to check if the snapshot has been created and where to find snapshots. Axon Server folder has a file called “00000000000000000000.snapshots” located in Axon Server → data → default folder. But it seems like this file never changes. No new files are created either.

Where does Axon Server store snapshots by default?

Here is how I configure Snapshotting:

  1. Add the following annotation above the Aggregate class:
    @Aggregate(snapshotTriggerDefinition = "myTriggerDefinition")

  2. In the main application file, I create a Bean:

    @Bean(name = “myTriggerDefinition”)
    public SnapshotTriggerDefinition myTriggerDefinition(Snapshotter snapshotter) {
    return new EventCountSnapshotTriggerDefinition(snapshotter, 2);
    }

After I generate a few events, the 00000000000000000000.snapshots file does not get updated at all.

Only after adding the following dependency, I can see a log entry “Snapshot created”. But the 00000000000000000000.snapshots is still not updated and no new files are created in the Axon Server → data → default folder.

<dependency>

<groupId>org.axonframework</groupId>

<artifactId>axon-spring-boot-autoconfigure</artifactId>

<version>4.4.5</version>

<type>jar</type>

</dependency>

Do I need the axon-spring-boot-autoconfigure dependency for Snapshotting to work?

When debugging the state of the Aggregate object it looks like the snapshot is created only after adding the axon-spring-boot-autoconfigure dependency…

Where does the Axon Server store snapshots?

Hey Serj,

I can answer one of your questions:

Do I need the axon-spring-boot-autoconfigure dependency for Snapshotting to work?

You do need it for your application to work (not just snapshotting) if you are using Spring Boot AutoConfiguration.

You can of course use the Axon’s configuration API instead to do the same. Here is an example from Event Snapshots - Axon Reference Guide

AggregateConfigurer<GiftCard> giftCardConfigurer =
        AggregateConfigurer.defaultConfiguration(GiftCard.class)
                           .configureSnapshotTrigger(config -> new EventCountSnapshotTriggerDefinition(
                                   config.snapshotter(), 500
                           ));
Configurer configurer = DefaultConfigurer.defaultConfiguration()
                                         .configureAggregate(giftCardConfigurer);

I hope this helps.

Milen, thank you very much for your response.

Until I started creating Snapshots, my application worked fine without the axon-spring-boot-autoconfigure dependency. I do have axon-spring-boot-starter in the pom.xml file. My application is able to handle commands and events, use Saga annotations, and command intercepters work fine. Using axon-spring-boot-starter was enough to make it all work.
Looking into the axon-spring-boot-starter dependency, it looks like it depends on the axon-spring-boot-autoconfigure. Why do I need to add it explicitly if I already have axon-spring-boot-starter?

UPDATE:
Apparently, adding the axon-spring-boot-autoconfigure dependency, additionally to axon-spring-boot-starter is not necessary for Snapshotting to work.

The snapshot seems to be created with only axon-spring-boot-starter dependency in pom.xml. It is just with axon-spring-boot-starter version 4.4.5 when a Snapshot is created, there will be a log message “o.a.a.c.event.axon.AxonServerEventStore : Snapshot created”. When using Axon version 4.4.7, there will be no longer a log message confirming that the snapshot is created…

Using version 4.4.7, unless debugging the state of the aggregate, it is hard to know that the Snapshop did get created… I wish Axon Server dashboard could show a list of created Snapshots…

Hi @interested-dev, good news =)

Since Axon Server 4.5, you can now use the Search tab of it to also search for snapshots!

Hope that helps.

1 Like

Oh, is it so? Great! I am using Axon 4.4. Downloading a newer version now :+1:.

UPDATE

Thank you, Lucas! The 4.5 version of Axon Server does indeed have a search option for Snapshot and it is very convenient! Great!

2 Likes