Hello guys, how are you?
So, I’m trying to understand snapshotters better.
So far I’m just using the following annotation:
@Aggregate(snapshotTriggerDefinition = "eventCountSnapshot")
@Revision("1.0")
final class Account constructor() {
with this simple configuration:
@Bean
fun snapshotterFactory(): SpringAggregateSnapshotterFactoryBean {
return SpringAggregateSnapshotterFactoryBean()
}
@Bean
fun eventCountSnapshot(snapshotter: Snapshotter) =
EventCountSnapshotTriggerDefinition(snapshotter, 2)
So far so good. I have this row on my snapshot table.
6946167f-c375-4e45-ac48-d745c8b15128 31 Account 483355b1-68eb-453b-877f-103f536aa7e8 {“traceId”:“891d401a-8262-4102-98bf-825bdacb3771”,“correlationId”:“891d401a-8262-4102-98bf-825bdacb3771”} {“id”:“6946167f-c375-4e45-ac48-d745c8b15128”,“name”:“Account 1”,“balance”:359} 1.0 br.com.zup.axon.saga.aggregate.Account 2018-06-01T20:46:51.868Z
also, I have this handler on my Account Aggregate
@EventHandler
fun on(account: Account) {
this.id = id
this.name = name
this.balance = balance
}
My question is, how I can customize my payload_type to a specific event class model? Let’s say AccountSnapshotEvent.
Is this more or less what the documentation in this part said I could do?
@EventHandler
protected void applySnapshot(MySnapshotEvent event) {
// the snapshot event should contain all relevant state
this.someState = event.someState;
this.otherState = event.otherState;
}
Thanks for any help