File tree Expand file tree Collapse file tree
src/main/java/com/dddheroes/heroesofddd Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -162,4 +162,5 @@ Please reach me out on LinkedIn [linkedin.com/in/mateusznakodach/](https://www.l
162162
163163### Helpful:
164164CHECK snapshot content!
165- ``` TO read snapshot data: SELECT lo_get(18333) AS payload; ```
165+ ``` TO read snapshot data: SELECT lo_get(18333) AS payload; ```
166+ ``` Error reading snapshot for aggregate [{}]. Reconstructing from entire event stream. ```
Original file line number Diff line number Diff line change 33import com .dddheroes .heroesofddd .astrologers .automation .whenweekstartedthenproclaimweeksymbol .WeekSymbolCalculator ;
44import com .dddheroes .heroesofddd .astrologers .write .WeekSymbol ;
55import com .dddheroes .heroesofddd .shared .domain .identifiers .CreatureId ;
6+ import org .axonframework .eventsourcing .EventCountSnapshotTriggerDefinition ;
7+ import org .axonframework .eventsourcing .SnapshotTriggerDefinition ;
8+ import org .axonframework .eventsourcing .Snapshotter ;
9+ import org .axonframework .eventsourcing .snapshotting .SnapshotFilter ;
610import org .springframework .context .annotation .Bean ;
711import org .springframework .context .annotation .Configuration ;
812
@@ -18,4 +22,17 @@ WeekSymbolCalculator inMemoryWeekSymbolCalculator() {
1822 private static int random (int min , int max ) {
1923 return (int ) (Math .random () * (max - min + 1 ) + min );
2024 }
25+
26+ @ Bean
27+ public SnapshotFilter astrologersSnapshotFilter () {
28+ return snapshotData -> {
29+ // Allow all snapshots for dwellings, as they are always in the correct format
30+ return true ;
31+ };
32+ }
33+
34+ @ Bean
35+ SnapshotTriggerDefinition astrologersSnapshotTrigger (Snapshotter snapshotter ) {
36+ return new EventCountSnapshotTriggerDefinition (snapshotter , 5 );
37+ }
2138}
Original file line number Diff line number Diff line change 1212
1313import static org .axonframework .modelling .command .AggregateLifecycle .apply ;
1414
15- @ Aggregate
15+ @ Aggregate ( snapshotFilter = "astrologersSnapshotFilter" , snapshotTriggerDefinition = "astrologersSnapshotTrigger" )
1616class Astrologers {
1717
1818 @ AggregateIdentifier
Original file line number Diff line number Diff line change 66import org .axonframework .eventsourcing .EventCountSnapshotTriggerDefinition ;
77import org .axonframework .eventsourcing .SnapshotTriggerDefinition ;
88import org .axonframework .eventsourcing .Snapshotter ;
9+ import org .axonframework .eventsourcing .snapshotting .SnapshotFilter ;
910import org .springframework .context .annotation .Bean ;
1011import org .springframework .context .annotation .Configuration ;
1112
@@ -31,4 +32,12 @@ public Class<? extends RecruitCreature> supportedCommandType() {
3132 SnapshotTriggerDefinition dwellingSnapshotTrigger (Snapshotter snapshotter ) {
3233 return new EventCountSnapshotTriggerDefinition (snapshotter , 5 );
3334 }
35+
36+ @ Bean
37+ public SnapshotFilter dwellingSnapshotFilter () {
38+ return snapshotData -> {
39+ // Allow all snapshots for dwellings, as they are always in the correct format
40+ return true ;
41+ };
42+ }
3443}
Original file line number Diff line number Diff line change 2424
2525import static org .axonframework .modelling .command .AggregateLifecycle .*;
2626
27- @ Aggregate (snapshotTriggerDefinition = "dwellingSnapshotTrigger" )
27+ @ Aggregate (snapshotTriggerDefinition = "dwellingSnapshotTrigger" , snapshotFilter = "dwellingSnapshotFilter" )
2828public class Dwelling {
2929
3030 private static final Logger logger = LoggerFactory .getLogger (Dwelling .class );
You can’t perform that action at this time.
0 commit comments