Hello together,
I’m trying to move the @CommandHandler methods outside of our aggregate root classes in order
to avoid layer dependencies from the domain layer. The problem is now, how do I create a repository
for my aggregate root in this new command handling classes.
In the axon-spring-boot-starter dependency there is the following example:
definition:
@MetaInfServices
public class SomeAggregateRoot
extends AbstractAnnotatedAggregateRoot<SomeIDType> {
@AggregateIdentifier
private SomeIDType id;
}
usage:
@Component
public final class SomeClassUsingRespository {
@Autowired
@Qualifier("someAggregateRootRepository")
private Repository<SomeAggregateRoot> repository;
}
In axon 3.2 there is no longer a class AbstractAnnotatedAggregateRoot and @MetaInfServices is not included. What is the
right way to do this now ? Why does this work if the @CommandHandler methods are inside my aggregate root ?
In the axon trader example, there is bean defined for the repository:
@Bean
public Repository<Transaction> transactionRepository() {
EventCountSnapshotTriggerDefinition triggerDefinition = new EventCountSnapshotTriggerDefinition(snapshotter, 50);
CachingEventSourcingRepository<Transaction> repository = new CachingEventSourcingRepository<>(transactionAggregateFactory(), eventStore, cache, triggerDefinition);
return repository;
}
But in this really needed ? If yes is there an example of axon 3.2 with some explanation what to do ?
Thanks in advance,
Benjamin