I have two aggregates Account and Convention, when creating a new convention, a creation of an account is launched, so when i get the account by the contextId from the repository (spring data) to do some validation, i get nothing, because the event is not arrived yet to the projection to save in the data base.
So the idea is to get the Account by the contextId from the event store.
The bean EventStore
has a function readEvents
, but the problem it accept only the aggregateIdentifier.
@Aggregate
public class AccountAggregate {
@AggregateIdentifier
private String accountId;
private String contextId;
}
@Aggregate
public class ConventionAggregate {
@AggregateIdentifier
private String conventionId;
public ConventionAggregate() {
}
@CommandHandler
protected ConventionAggregate(CreateConventionCommand cmd) {
// i want to get the Account by contextId from the event store (cmd.contextId)
}
}