Hi, Axon forum!
I have experimented with Snaphooting and the default config for it.
My config is:
@Bean
public Repository<ProductAggregate> productAggregateRepository(EventStore eventStore,
SnapshotTriggerDefinition subscriptionSnapshotDefinition)
{
return EventSourcingRepository.builder(ProductAggregate.class)
.snapshotTriggerDefinition(subscriptionSnapshotDefinition)
.eventStore(eventStore).build();
}
@Bean("productSnapshotDefinition")
public SnapshotTriggerDefinition productSnapshotDefinition(Snapshotter snapshotter)
{
return new EventCountSnapshotTriggerDefinition(snapshotter, 1);
}
@Aggregate
(snapshotTriggerDefinition = "productSnapshotDefinition")
public class ProductAggregate
Shaphot is done.
But after all command/event for update more than 2 times the exception is throwing:
org.axonframework.eventsourcing.IncompatibleAggregateException: Aggregate identifier must be non-null after applying an event. Make sure the aggregate identifier is initialized at the latest when handling the creation event.
After that I noticed that that payload in table snapshot_event_entry is empty:
and probably the issue is related.
domain_event_entry is ok and payload is stored.
My question should I add something else for populating payload as well?
The second question what is the best practice to get the latest snapshot for Aggregate?
eventStore.readEvents(productId).asStream() contains only events.
I didn’t find in the documentation how can I retrieve snapshot by Aggregate Id.
Thanks in advance!