@Aggregate
public class PaymentExecutionProcedure implements Serializable {
protected PaymentExecutionProcedure() {
}
public PaymentExecutionProcedure(ProcedureRepository repository) {
}
@AggregateIdentifier
private String identifier;
@CommandHandler
public void handle(@NotNull InitiatePaymentCommand command) throws Exception {
apply(command);
}
@EventSourcingHandler
public void on(@NotNull InitiatePaymentEvent event) throws Exception {
this.identifier = event.getId();
}
}
This gives me the following exception:
'com.ISC.remittanceManagement.api.command.InitiatePaymentCommand' resulted in org.axonframework.commandhandling.CommandExecutionException(The aggregate was not found in the event store)
Now, on to the issue.
Luckily, the misser is rather straightforward.
You miss telling Axon Framework which command handler constructs your PaymentExecutionProcedure.
There are two ways you can tell the Framework which command handler instantiates an aggregate:
Use a command handling constructor.
Use a @CreationPolicy annotation.
Looking at option one, this would change your handler like so:
@CommandHandler
public PaymentExecutionProcedure(@NotNull InitiatePaymentCommand command) throws Exception {
apply(command);
}
If you prefer not to use constructors inside the aggregate, you can use the @CreationPolicy (for which you can find the documentation here), like so: