Just tinkering with Scala and Scynapse and I was trying to create the aggregate using a command handling aggregate root. Obviously constructors are a little different in Scala so annotating them with @CommandHandler doesn’t work.
I have the following code;
class Player extends AbstractAnnotatedAggregateRoot[String] {
@AggregateIdentifier
private var id : String = _
@CommandHandler
def handle(cmd: CreatePlayerCommand){
print(cmd)
}
@CommandHandler
def handle(cmd: PlayerGoalScoredCommand){
print(cmd)
}
@EventSourcingHandler
def handle(evt: PlayerCreatedEvent): Unit ={
this.id = evt.getId
}
}
The CreatePlayerCommand is doing the creation and in Java would have been in the constructor args.