Hello guys,
Once in a year, when a new ring appears inside of a tree, I create a treeChangedEvent, from inside a polling Thread (inside the Tree class).
public class Tree extends AbstractAnnotatedAggregateRoot {
@AggregateIdentifier
private int id;
private int years;
public Tree(int years) {
myApplyMethod(years);
}
private void myApplyMethod(int years) {
apply(new TreeYearsChangedEvent(this.id, years));
}
@EventSourcingHandler
private void on(TreeYearsChangedEvent event) {
this.years = event.getYears();
}
// Here I have some polling, that throws a TreeYearsChangedEvent, whenever a new year has passed, by calling the myApplyMethod from a new Thread
}
So after reading the documentation I am still not sure, what the easiest way is to “register” the new Thread properly is.
Is there a command that does that, or do I have to change my architecture?