Hard to set up external command handlers

Hello,

After checking the example here, I am having issues to figure out where I am expected to get this repository. At the same time this document has obvious points in the end (already able to understand it from the code), it lacks explaining from where the repository should come.

My first thought was that by moving it to the constructor, it would automatically autowire the dependency. Unfortunately, there was no bean defined for that.

Then I tried to set up a configuration/bean with:

EventSourcingRepository.builder()

but now I also have to provide an EventStore instance (available as a bean) and an AggregateProvider (which again I have no clue where to get from).

I can eventually create all that myself, but I am not sure I need or should. It feels wrong, knowing that the framework is doing precisely the same for the command handlers that are in the aggregate.

I also took a look at how that is done on AggregateConfigurer constructor but wasn’t able to replicate the setup for the repository yet…

Axon 4.0
Spring Boot 2.1.0.RELEASE

Hope that someone can give me a hint, and the documentation can be improved.

Thanks in advance,
Fabio Carneiro

So, I managed to figure out what was going on.

It was working, but IDE (IntelliJ IDEA) is not able to detect the autowiring for Repository, then I wasn’t even trying to compile.

Still, assuming there is no way to improve the IDE detection from the code, I think a few things can be improved in the documentation:

  • Saying it explicitly somewhere that Repository will be available for aurowiring
  • Describing the risk that some software is not able to recognize
  • In the example, add the @Component annotation and move the dependency to the constructor
  • Add @Suppress(“SpringJavaInjectionPointsAutowiringInspection”)

Hi Fabio,

Thanks for your suggestions on improving the Reference Guide - we highly value your (or anyone’s really!) contribution in this respect.
To add a little background, the section you’ve shared tries to explain what an External Command Handler means, mainly providing a focus on why you’d do this.

From AxonIQ’s perspective, we try to have everybody focus on their problem at hand, thus the required business functionality.
How to provide non-functional requirements, like specifics on configuration or operation, comes at a later stage in the Reference Guide.

Although this idea is nice, we are still in the process to fine-tune this ideal world into a Reference Guide explaining all these requirements.
Thus, you’re suggestion is very much valued, as pointed out.
You could go a step further in that respect, and add an issue to the Reference Guide repository.
That gives us at AxonIQ an handle to work on suggestions like this.

Cheers,
Steven