I've been following along with your axon 3.0 video:
https://www.youtube.com/watch?v=s2zH7BsqtAk. I created the application, but when I get to starting the spring boot main, I get a "No handler was subscribed to command [commands.CreateAccountCommand]" exception.
Not really sure what is wrong, because the only difference seems to be that I simplified things a bit & @EnableAxonAutoConfiguration seems to have been replaced by @EnableAxon.
____________________________________________________________________________________
import commands.CreateAccountCommand;
...
import static org.axonframework.commandhandling.model.AggregateLifecycle.apply;
@Aggregate
public class Account {
@AggregateIdentifier
private String ourId;
public Account() {
}
public Account(String ourId) {
this.ourId = ourId;
}
@CommandHandler
public Account(CreateAccountCommand command) {
apply(new AccountCreatedEvent(command.getAccountId()));
}
@EventSourcingHandler
public void on(AccountCreatedEvent event) {
this.ourId = event.getId();
}
public String getOurId() {
return ourId;
}
public void setOurId(String ourId) {
this.ourId = ourId;
}
}
public class CreateAccountCommand {
private String accountId;
public CreateAccountCommand() {
}
public CreateAccountCommand(String accountId) {
this.accountId = accountId;
}
public String getAccountId() {
return accountId;
}
}
public class AccountCreatedEvent {
private String id;
public AccountCreatedEvent() {
}
public AccountCreatedEvent(String id) {
this.id = id;
}
public String getId() {
return id;
}
}
import commands.CreateAccountCommand;
...
import static org.axonframework.commandhandling.GenericCommandMessage.asCommandMessage;
@EnableAxon
@SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
ConfigurableApplicationContext run = SpringApplication.run(MyApplication.class);
CommandBus commandBus = run.getBean(CommandBus.class);
commandBus.dispatch(asCommandMessage(new CreateAccountCommand("exampleId")));
}
@Bean
public EventStorageEngine eventStorageEngine() {
return new InMemoryEventStorageEngine();
}
}
public class AccountTest {
private AggregateTestFixture<Account> accountAggregateTestFixture;
@Before
public void setup() {
accountAggregateTestFixture = new AggregateTestFixture<>(Account.class);
}
@Test
public void aTest() {
accountAggregateTestFixture.givenNoPriorActivity()
.when(new CreateAccountCommand("anId"))
.expectEvents(new AccountCreatedEvent("anId"));
}
}