I’m trying to figure out how I can use the MetaDataCommandTargetResolver with Axon 3 in a Spring Auto configure setup. The only example I found in the Axon docs was to do it programatically with AggregateConfigurer.defaultConfiguration(…).configureCommandTargetResolver(…), but I was instead hoping I could either use a @Bean, or have something @Autowired that I can configure to achieve the same. Is this possible somehow?
Hi,
unfortunately, it’s not possible using annotations or basic configuration.
It’s probably possible with a workaround, though. You could inject the AxonConfiguration in a method on your @Configuration class and tune the configuration there:
@Autowired
public void configure(AxonConfiguration config) {
// obtain the modules from the configuration using config.getModules()
// check each module if it is the AggregateConfigurer for your aggregate using module.getAggregateType();
// set the commandTargetResolver on the configuration
}
I agree that it’s nicer to have these options available as annotation attributes on the @Aggregate annotation. Will put it on the backlog for future releases.
Cheers,
Allard
Thanks, that worked. I can live with that until the annotations get direct support for it
Regards,
Nils-H