Hi
I'm getting the following error when trying to call repository.load()
method to load the aggregate:
java.lang.IllegalStateException: Aggregate is already initialized
This is my configuration:
<aop:aspectj-autoproxy/>
<axon:annotation-config/>
<context:component-scan base-package="org.axon.sample" />
<axon:command-bus id="commandBus"></axon:command-bus>
<axon:event-bus id="eventBus"/>
<axon:filesystem-event-store id="eventStore" base-dir="D:\Java
\Workspace\axon-sample\resources\eventstore"/>
<axon:event-sourcing-repository id="workShiftRepository"
aggregate-type="org.axon.sample.domain.aggregates.WorkShift"
event-bus="eventBus"
event-store="eventStore">
<axon:snapshotter-trigger event-count-threshold="50"
snapshotter-ref="snapshotter"/>
</axon:event-sourcing-repository>
<bean id="snapshotter"
class="org.axonframework.eventsourcing.SpringAggregateSnapshotter">
<property name="eventStore" ref="eventStore"/>
<property name="executor" ref="taskExecutor"/>
</bean>
<bean id="taskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="2"/>
<property name="maxPoolSize" value="5"/>
<property name="waitForTasksToCompleteOnShutdown" value="true"/
</bean>
Code to add and load the aggregate:
ApplicationContext ctx = new
ClassPathXmlApplicationContext("applicationContext.xml");
CommandBus commandBus = ctx.getBean(CommandBus.class);
CreateWorkShiftCommand createWorkShift = new
CreateWorkShiftCommand(new StringAggregateIdentifier("3"),
"N/A", new Date(), new Date());
//commandBus.dispatch(createWorkShift, NoOpCallback.INSTANCE);
UpdateWorkShiftCommand updateWorkShift = new
UpdateWorkShiftCommand(new StringAggregateIdentifier("3"), "New
name");
commandBus.dispatch(updateWorkShift);
Thanks