When I call save method to persist an aggreate the corresponding event
handler is firing correctly. Otherwise, when I load an aggregate from
the repository and call an operation on it, nothing happens. Here is
my code.
@Component
public class MarketCommandHandler {
private Repository<Market> marketRepository;
public Repository<Market> getMarketRepository() {
return marketRepository;
}
public void setMarketRepository(Repository<Market> marketRepository)
{
this.marketRepository = marketRepository;
}
@CommandHandler
public void changeMarketName(ChangeMarketNameCommand
changeMarketNameCommand) {
Market market =
marketRepository.load(UUID.fromString((changeMarketNameCommand.getMarketId())));
market.changeMarketName( changeMarketNameCommand.getNewMarketName() );
}
}
In changeMarketName i have this:
public void changeMarketName(String newMarketName) {
apply( new MarketNameChangedEvent(newMarketName) );
}
The event handler which is defined inside the Market aggregate is
firing.
I'm wiring command and event handlers using a BeanPostProcessor
classes in the application context. I'm using
GenericEventSourcingRepository implementation and file system event
store.