Hi all.
I’m writing a prototype to show the capabilities of Event Sourcing and Sagas with Axon, I’m quite new with it. I searched and found this thread [1] in this forum that practically explains my problem, however the solution with [2] is not working. The error I’m having is
UnsupportedHandlerException: On method public TestService(TestStartCommand,org.springframework.web.client.RestTemplate,org.axonframework.commandhandling.gateway.CommandGateway), parameter 2 is invalid. It is not of any format supported by a providedParameterValueResolver.
It’s coming from my JavaConfig class (shameless copy of the quick guide)
@Bean public EventSourcingRepository<
TestService> eventRepository() { // we need to configure the repository EventSourcingRepository<AuditService> eventRepository = new EventSourcingRepository<TestService>(TestService.class, eventStore()); eventRepository.setEventBus(eventBus()); // Axon needs to know that our
TestService Aggregate can handle commands AggregateAnnotationCommandHandler.subscribe(
TestService.class, eventRepository, commandBus()); // <<====== ERROR // Let’s wire the Event Handler in our infrastructure. AnnotationEventListenerAdapter.subscribe(new
TestService`Handler(), eventBus());
return eventRepository;
}
`
Following the explanation in [2],
Methods annotated with @CommandHandler and @EventHandler are now inspected by
the SpringBeanParameterResolverFactory, which injects Spring beans as method
parameters. It is automatically enabled when the axon:annotation-support/
element is used. Otherwise, configure the factory is a bean to enable support.
and since I don’t have any XML config, I just added this to my JavaConfig
`
@Bean
public SpringBeanParameterResolverFactory springBeanParameterResolverFactory(){
return new SpringBeanParameterResolverFactory();
}
`
and the constructor of the aggregate is (both restTemplate
and commandGateway
are defines as beans):
`
@CommandHandler
public TestService (TestStartCommand command, RestTemplate restTemplate, CommandGateway commandGateway) {
this.restTemplate = restTemplate;
this.commandGateway = commandGateway;
this.id = command.getId();
apply(new TestStartedEvent(command.getId(), command.getData()));
}
`
So, it seems that AggregateAnnotationCommandHandler
never sees nor uses ``SpringBeanParameterResolverFactory
.
Any ideas on what am I doing wrong?
Cheers.
[1] https://groups.google.com/d/msg/axonframework/d9OeCWU2FbQ/dUaHGy5pXj8J
[2] Issues · AxonFramework/AxonFramework · GitHub