I attach the log of what happens.
I wrapped the AggregateSnapshotter ad put System.out.println("-----------------> CREATE SNAPSHOT") in the createSnapshot() method before a call to super. createSnapshot().
As I understand createSnapshot is called after the Unit Of Work is stopped.
What does it means?
Maybe the snapshot is created after the transaction is committed?
[2013-11-27 16:40:09,786 - DEBUG] (SimpleCommandBus.java:120) -> [Dispatching command [xxx.MyCommand]]
[2013-11-27 16:40:09,787 - DEBUG] (NestableUnitOfWork.java:126) -> [Starting Unit Of Work.]
[2013-11-27 16:40:09,787 - DEBUG] (NestableUnitOfWork.java:141) -> [Registering Unit Of Work as CurrentUnitOfWork]
[2013-11-27 16:40:09,804 - DEBUG] (UnitOfWorkListenerCollection.java:161) -> [Registering listener: org.axonframework.eventsourcing.EventSourcingRepository$ConflictResolvingListener]
[2013-11-27 16:40:09,805 - DEBUG] (UnitOfWorkListenerCollection.java:161) -> [Registering listener: org.axonframework.repository.LockingRepository$LockCleaningListener]
[2013-11-27 16:40:09,805 - DEBUG] (NestableUnitOfWork.java:46) -> [Committing Unit Of Work]
[2013-11-27 16:40:09,806 - DEBUG] (UnitOfWorkListenerCollection.java:108) -> [Notifying listeners of commit request]
[2013-11-27 16:40:09,806 - DEBUG] (UnitOfWorkListenerCollection.java:111) -> [Notifying listener [org.axonframework.eventsourcing.EventSourcingRepository$ConflictResolvingListener] of upcoming commit]
[2013-11-27 16:40:09,807 - DEBUG] (UnitOfWorkListenerCollection.java:111) -> [Notifying listener [org.axonframework.repository.LockingRepository$LockCleaningListener] of upcoming commit]
[2013-11-27 16:40:09,807 - DEBUG] (UnitOfWorkListenerCollection.java:115) -> [Listeners successfully notified]
[2013-11-27 16:40:09,807 - DEBUG] (DefaultUnitOfWork.java:266) -> [Persisting changes to aggregates]
[2013-11-27 16:40:09,808 - DEBUG] (DefaultUnitOfWork.java:269) -> [Persisting changes to [xxxxxx.MyAggregate], identifier: [a9b5effd-2cb3-41fc-9e32-798bb418433c]]
[2013-11-27 16:40:09,809 - DEBUG] (UnitOfWorkListenerCollection.java:161) -> [Registering listener: org.axonframework.eventsourcing.EventCountSnapshotterTrigger$SnapshotTriggeringListener]
[2013-11-27 16:40:09,811 - DEBUG] (DefaultUnitOfWork.java:275) -> [Aggregates successfully persisted]
[2013-11-27 16:40:09,811 - DEBUG] (NestableUnitOfWork.java:52) -> [This Unit Of Work is not nested. Finalizing commit…]
[2013-11-27 16:40:09,812 - DEBUG] (DefaultUnitOfWork.java:233) -> [Publishing events to the event bus]
[2013-11-27 16:40:09,812 - DEBUG] (DefaultUnitOfWork.java:249) -> [Publishing event [xxx.MyEvent] to event bus [org.axonframework.eventhandling.SimpleEventBus@1666eba]]
[2013-11-27 16:40:09,812 - DEBUG] (SimpleEventBus.java:98) -> [Dispatching Event [EventoTestoLavagnaModificato] to EventListener [Class]]
[2013-11-27 16:40:09,815 - DEBUG] (SimpleEventBus.java:98) -> [Dispatching Event [EventoTestoLavagnaModificato] to EventListener [Class]]
[2013-11-27 16:40:09,817 - DEBUG] (SimpleEventBus.java:98) -> [Dispatching Event [EventoTestoLavagnaModificato] to EventListener [Class]]
[2013-11-27 16:40:09,818 - DEBUG] (DefaultUnitOfWork.java:260) -> [All events successfully published.]
[2013-11-27 16:40:09,818 - DEBUG] (UnitOfWorkListenerCollection.java:120) -> [Notifying listeners of transaction commit request]
[2013-11-27 16:40:09,818 - DEBUG] (UnitOfWorkListenerCollection.java:123) -> [Notifying listener [org.axonframework.eventsourcing.EventSourcingRepository$ConflictResolvingListener] of upcoming transaction commit]
[2013-11-27 16:40:09,818 - DEBUG] (UnitOfWorkListenerCollection.java:123) -> [Notifying listener [org.axonframework.repository.LockingRepository$LockCleaningListener] of upcoming transaction commit]
[2013-11-27 16:40:09,819 - DEBUG] (UnitOfWorkListenerCollection.java:123) -> [Notifying listener [org.axonframework.eventsourcing.EventCountSnapshotterTrigger$SnapshotTriggeringListener] of upcoming transaction commit]
[2013-11-27 16:40:09,819 - DEBUG] (UnitOfWorkListenerCollection.java:127) -> [Listeners successfully notified]
[2013-11-27 16:40:09,824 - DEBUG] (UnitOfWorkListenerCollection.java:58) -> [Notifying listeners after commit]
[2013-11-27 16:40:09,824 - DEBUG] (UnitOfWorkListenerCollection.java:63) -> [Notifying listener [org.axonframework.eventsourcing.EventCountSnapshotterTrigger$SnapshotTriggeringListener] after commit]
[2013-11-27 16:40:09,824 - DEBUG] (UnitOfWorkListenerCollection.java:63) -> [Notifying listener [org.axonframework.repository.LockingRepository$LockCleaningListener] after commit]
[2013-11-27 16:40:09,825 - DEBUG] (UnitOfWorkListenerCollection.java:63) -> [Notifying listener [org.axonframework.eventsourcing.EventSourcingRepository$ConflictResolvingListener] after commit]
[2013-11-27 16:40:09,825 - DEBUG] (NestableUnitOfWork.java:171) -> [Stopping Unit Of Work]
[2013-11-27 16:40:09,825 - DEBUG] (UnitOfWorkListenerCollection.java:137) -> [Notifying listeners of cleanup]
[2013-11-27 16:40:09,825 - DEBUG] (UnitOfWorkListenerCollection.java:143) -> [Notifying listener [org.axonframework.eventsourcing.EventCountSnapshotterTrigger$SnapshotTriggeringListener] of cleanup]
-----------------> CREATE SNAPSHOT
[2013-11-27 16:40:09,846 - DEBUG] (UnitOfWorkListenerCollection.java:143) -> [Notifying listener [org.axonframework.repository.LockingRepository$LockCleaningListener] of cleanup]
[2013-11-27 16:40:09,847 - DEBUG] (UnitOfWorkListenerCollection.java:143) -> [Notifying listener [org.axonframework.eventsourcing.EventSourcingRepository$ConflictResolvingListener] of cleanup]
[2013-11-27 16:40:09,847 - DEBUG] (UnitOfWorkListenerCollection.java:150) -> [Listeners successfully notified]
[2013-11-27 16:40:09,847 - DEBUG] (NestableUnitOfWork.java:68) -> [Clearing resources of this Unit Of Work.]