I am having the following issue:
I have the following Aggregate:
public class Account {
@AggregateIdentifier
private String accountEventId;
private String firstName;
private String lastName;
private String email;
@CommandHandler
public Account(CreateAccountCommand command) {
AccountCreatedEvent event = new AccountCreatedEvent(command.getAccountEventId(), command.getFirstName(), command.getLastName(),
command.getEmail());
apply(event);
}
@CommandHandler
public void handle(UpdateAccountCommand command) {
AccountUpdatedPasswordTokenEvent event = new AccountUpdatedPasswordTokenEvent(command.getAccountEventId(), command.getPasswordResetToken(), command.getEmail());
apply(event);
}
@EventSourcingHandler
protected void on(AccountEvent event) {
this.accountEventId = event.getAccountEventId();
this.firstName = event.getFirstName();
this.lastName = event.getLastName();
this.email = event.getEmail();
}
@EventSourcingHandler
protected void on(AccountUpdatedPasswordTokenEvent event) {
this.accountEventId = event.getAccountEventId();
this.passwordResetToken = event.getPasswordResetToken();
this.email = event.getEmail();
}
}
I have the following kotlin classes
class CreateAccountCommand(@TargetAggregateIdentifier val accountEventId: String, val firstName: String,
val lastName: String, val email: String)
class UpdateAccountCommand (@TargetAggregateIdentifier val accountEventId: String, val firstName: String, val lastName: String, val email: String)
//Events
abstract class AccountEvent (val accountEventId: String, val firstName: String, val lastName: String, val email: String)
class AccountCreatedEvent(
accountEventId: String, firstName: String, lastName: String, email: String) :
AccountEvent(accountEventId, firstName, lastName, email)
class AccountUpdatedPasswordTokenEvent (val accountEventId: String, val passwordResetToken: String, val email: String)
In one point I am calling the send method of the Gateway like so:
commandGateway.send(updateAccountCommand);
However, it does not reach the above command handler and also it does not trigger any error. As extra note I have a CreateAccountCommand and that one works. Am I missing something?
Richard