[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:
parent
e852724228
commit
c1fe739e37
@ -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);
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ import java.util.Map;
|
||||
|
||||
import static org.axonframework.modelling.command.AggregateLifecycle.apply;
|
||||
|
||||
@Aggregate
|
||||
@Aggregate(snapshotTriggerDefinition = "orderAggregateSnapshotTriggerDefinition")
|
||||
public class OrderAggregate {
|
||||
|
||||
@AggregateIdentifier
|
||||
|
Loading…
x
Reference in New Issue
Block a user