[BAEL-4768] Snapshotting the Aggregate in Axon (#11103)

* Add configuration class

Add configuration class

#BAEL-4768

* Add SnapshotTriggerDefinition bean creation method

Add SnapshotTriggerDefinition bean creation method

#BAEL-4768

* Add SnapshotTriggerDefinition bean name

Add SnapshotTriggerDefinition bean name

#BAEL-4768

* Add threshold behind property value

Add threshold behind property value. Default to 250.

#BAEL-4768

* Add link to the readme

Add a link to the article in the readme

#BAEL-4768

* Process review comments

- Drop readme line
- Adjust parameter indentation of config class

#BAEL-4768
This commit is contained in:
Steven van Beelen 2021-09-25 15:13:54 +02:00 committed by GitHub
parent e852724228
commit c1fe739e37
2 changed files with 19 additions and 1 deletions

View File

@ -0,0 +1,18 @@
package com.baeldung.axon;
import org.axonframework.eventsourcing.EventCountSnapshotTriggerDefinition;
import org.axonframework.eventsourcing.SnapshotTriggerDefinition;
import org.axonframework.eventsourcing.Snapshotter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class OrderApplicationConfiguration {
@Bean
public SnapshotTriggerDefinition orderAggregateSnapshotTriggerDefinition(Snapshotter snapshotter,
@Value("${axon.aggregate.order.snapshot-threshold:250}") int threshold) {
return new EventCountSnapshotTriggerDefinition(snapshotter, threshold);
}
}

View File

@ -23,7 +23,7 @@ import java.util.Map;
import static org.axonframework.modelling.command.AggregateLifecycle.apply;
@Aggregate
@Aggregate(snapshotTriggerDefinition = "orderAggregateSnapshotTriggerDefinition")
public class OrderAggregate {
@AggregateIdentifier