'Error No handler was subscribed to command when send command
I have a Spring Boot microservice using AxonIq for Eventsourcing pattern. I have an hexagonal architecture with 3 modules :
- rest-adapter
- MyCommandController
- MyQueryController
- domain
- commands
- MyAggregate defining all CommandHandler and EventSourcingHandler
- all commands class
- CommandService implenent creat, update, delete and inject CommandGateway
- queries
- interface Projector defining all EventHandler and QueryHandler
- all Query definition
- QueryService implement all query and inject the QueryGateway
- commands
- infra
- MyMongoRepository extends MongoRepository
- MyMongoProjector implementation of Projector using @Service annotation
- MyApplicationConfig for creation of CommandService and QueryService
When I try to post a new element in the eventstore I have this error : No handler was subscribed to command. I haded breakpoint in the subscrib of SimpleCommandBus and SimpleQueryBus and in the bootstrap of the application only one breakpoint was activated the simpleQueryBus.
MyAggregate.java
package com.omb.commands;
import com.omb.events.SchedulingCreatedEvent;
import com.omb.events.SchedulingUpdatedEvent;
import org.axonframework.commandhandling.CommandHandler;
import org.axonframework.eventsourcing.EventSourcingHandler;
import org.axonframework.modelling.command.AggregateIdentifier;
import org.axonframework.spring.stereotype.Aggregate;
import static org.axonframework.modelling.command.AggregateLifecycle.apply;
@Aggregate
public class MyAggregate {
@AggregateIdentifier
private String id;
private String name;
public MyAggregate() {}
@CommandHandler
public MyAggregate(CreateMyAggregateCommand command) {
apply(new MyAggregateCreatedEvent(command.getId(), command.getName()));
}
@CommandHandler
public void handle(UpdateMyAggregateCommand command) {
apply(new MyAggregateUpdatedEvent(command.getId(), command.getName()));
}
@EventSourcingHandler
public void on(MyAggregateCreatedEvent event) {
id = event.getId();
name = event.getName();
}
@EventSourcingHandler
public void on(MyAggregateUpdatedEvent event) {
id = event.getId();
name = event.getName();
}
}
Solution 1:[1]
I solved my probleme, I made a mistake in my @ComponentScan definition.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ousmane MINTE |
