Snapshots Not Triggered


First of all I want to thank everyone who has helped me over the last couple weeks, I’ve posted a handful of questions and have gotten some great feedback that has really made the difference for me to continue evaluating the Axon framework. I think this product provides a very elegant solution for DDD based products. The integration with Spring Boot also has the ability to greatly simplify configuration–I’m a fan. However, it can be very painful to figure out what is needed when you stray from the defaults, which is inevitable when you go beyond a simple example application. Anyway, thank you Allard for your fine work and thanks to the community at large for sharing your knowledge!

So on to my question. I have the following repository bean definition for one of my aggregate roots:


public Repository pkgRepository(EventStore eventStore, Cache cache, Snapshotter snapshotter) {
CachingEventSourcingRepository repository = new CachingEventSourcingRepository<>(
pkgAggregateFactory(), eventStore, cache, new EventCountSnapshotTriggerDefinition(snapshotter, 50));
return repository;


I also have the following axon configuration:


package com.fedexx;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import org.axonframework.commandhandling.AsynchronousCommandBus;
import org.axonframework.common.caching.Cache;
import org.axonframework.common.caching.WeakReferenceCache;
import org.axonframework.common.transaction.TransactionManager;
import org.axonframework.eventsourcing.eventstore.EventStore;
import org.axonframework.messaging.Message;
import org.axonframework.messaging.annotation.ParameterResolverFactory;
import org.axonframework.messaging.interceptors.BeanValidationInterceptor;
import org.axonframework.messaging.interceptors.TransactionManagingInterceptor;
import org.axonframework.spring.eventsourcing.SpringAggregateSnapshotter;
import org.springframework.amqp.core.AmqpAdmin;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.ExchangeBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

public class AxonConfig {

public static final String EXCHANGE_NAME = “FXEvents”;
public static final String QUEUE_NAME = EXCHANGE_NAME;

public BeanValidationInterceptor<Message<?>> beanValidationInteceptor() {
return new BeanValidationInterceptor<>();

@Bean(destroyMethod = “shutdown”)
public AsynchronousCommandBus commandBus(TransactionManager transactionManager) {
AsynchronousCommandBus cb = new AsynchronousCommandBus();
cb.registerHandlerInterceptor(new TransactionManagingInterceptor<>(transactionManager));
return cb;

public Cache cache() {
return new WeakReferenceCache();

public SpringAggregateSnapshotter snapshotter(ParameterResolverFactory parameterResolverFactory,
EventStore eventStore, TransactionManager transactionManager) {
Executor executor = Executors.newSingleThreadExecutor();
return new SpringAggregateSnapshotter(eventStore, parameterResolverFactory, executor, transactionManager);

public Exchange exchange() {
return ExchangeBuilder.fanoutExchange(EXCHANGE_NAME).build();

public Queue queue() {
return QueueBuilder.durable(QUEUE_NAME).build();

public Binding binding() {
return BindingBuilder.bind(queue()).to(exchange()).with("*").noargs();

public void configure(AmqpAdmin admin) {


When I exceed the threshold (configured as 50) nothing happens.

I’ve debugged through the org.axonframework.commandhandling.model.AggregateLifecycle.apply(Object) method invoked by my aggregate command handler and when I come to this line the snapshotTrigger instance type is org.axonframework.eventsourcing.NoSnapshotTriggerDefinition, not the configured type I was expecting: org.axonframework.eventsourcing.EventCountSnapshotTriggerDefinition

What am I missing?



Hi Troy,

you’re hitting a little “convention-over-configuration” issue here. By default, the name of the repository that Axon will look for (or create if it doesn’t exist), is <lowerCaseFirst(aggregateSimpleClassName)>Repository.

In your case, your aggregate seems to be called PkgAR. The @Bean annotated method (which defines the name, unless explicitly specified) is called pkgRepository.
If you rename that method to pkgARRepository, or use @Bean(“pckARRepository”), it should work.

Alternatively, to prevent these “silent problems”, you can specify the bean name of the repository you want to use in the @Aggregate annotation: @Aggregate(repository=“pkgRepository”)

Hope this helps.


Thanks Allard! That works now.