Hi,
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:
`
@Bean
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;
@Configuration
public class AxonConfig {
public static final String EXCHANGE_NAME = “FXEvents”;
public static final String QUEUE_NAME = EXCHANGE_NAME;
@Bean
public BeanValidationInterceptor<Message<?>> beanValidationInteceptor() {
return new BeanValidationInterceptor<>();
}
@Bean(destroyMethod = “shutdown”)
public AsynchronousCommandBus commandBus(TransactionManager transactionManager) {
AsynchronousCommandBus cb = new AsynchronousCommandBus();
cb.registerDispatchInterceptor(beanValidationInteceptor());
cb.registerHandlerInterceptor(new TransactionManagingInterceptor<>(transactionManager));
return cb;
}
@Bean
public Cache cache() {
return new WeakReferenceCache();
}
@Bean
public SpringAggregateSnapshotter snapshotter(ParameterResolverFactory parameterResolverFactory,
EventStore eventStore, TransactionManager transactionManager) {
Executor executor = Executors.newSingleThreadExecutor();
return new SpringAggregateSnapshotter(eventStore, parameterResolverFactory, executor, transactionManager);
}
@Bean
public Exchange exchange() {
return ExchangeBuilder.fanoutExchange(EXCHANGE_NAME).build();
}
@Bean
public Queue queue() {
return QueueBuilder.durable(QUEUE_NAME).build();
}
@Bean
public Binding binding() {
return BindingBuilder.bind(queue()).to(exchange()).with("*").noargs();
}
@Autowired
public void configure(AmqpAdmin admin) {
admin.declareExchange(exchange());
admin.declareQueue(queue());
admin.declareBinding(binding());
}
}
`
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?
Cheers,
Troy