defining a CommandTargetResolver in springboot with AutoConfiguration

20 views
Skip to first unread message

Jorg Heymans

unread,
May 23, 2018, 3:26:01 AM5/23/18
to Axon Framework Users
Hi,

Can anyone share the magic recipe how to define a commandtargetresolver when using the spring-boot-starter with autoconfiguration ? The documentation just says we can supply a custom commandtargetresolver but doesn't say how :/ I know Axon quite well but to be honest having the declarative xml configuration in Axon2 was much easier to manage and understand than declaring random things left and right to adjust behaviour up or down (but this is more a general autoconfiguration remark, nothing to do with Axon just ranting ;)

Thanks,
Jorg

Jorg Heymans

unread,
May 23, 2018, 8:06:18 AM5/23/18
to Axon Framework Users
The magic recipe so that others don't have to go through the same experience:

  @Bean
  public AggregateConfigurer<MyAR> configure() {
    return AggregateConfigurer.defaultConfiguration(MyAR.class)
        .configureCommandTargetResolver(....);
  }

Jorg

Steven van Beelen

unread,
May 23, 2018, 8:27:36 AM5/23/18
to axonfr...@googlegroups.com
Hi Jorg,

Sorry for not coming back to you quick enough.
Great that you found it though, that currently is the approach to set a `CommandTargetResolver`.
As of Axon 3.3, this issue (which you created, thanks for that), should give you a simpler solution to setting the `CommandTargetResolver` for your Aggregates.

When in an Axon 3.3 space, you will be able to set the `commandTargetResolver` on the `@Aggregate` annotation.
Axon will then internally check if it can find a bean with the name specified in your annotation.
That will thus allow you to just create a bean creator function for your CommandTargetResolver which will be wired to that specific Aggregate.

A Default CommandTargerResolver will also be configurable, although that issue is still in progress.

Cheers,
Steven

--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jorg Heymans

unread,
May 23, 2018, 8:49:30 AM5/23/18
to Axon Framework Users
No problem Steven, appreciate the heads-up on this. 

Jorg
Reply all
Reply to author
Forward
0 new messages