I updated from 4.10.3 to 4.11.0 and noticed it breaks existing configurations from cycle detection. I realize everyones customizations are different, but in general I get something like the following
The dependencies of some of the beans in the application context form a cycle:
restCommandController defined in file [repos/digital-engineering-starter-axon/digital-engineering-starter-axon-rest/build/classes/java/main/com/deng/axon/rest/commands/RestCommandController.class]
↓
restCommandBusConnector defined in class path resource [com/deng/axon/rest/config/RestAxonAutoConfig.class]
┌─────┐
| commandBus defined in class path resource [org/axonframework/springboot/autoconfig/AxonAutoConfiguration.class]
↑ ↓
| springAxonConfiguration
↑ ↓
| commandGateway defined in class path resource [org/axonframework/springboot/autoconfig/AxonAutoConfiguration.class]
↑ ↓
| distributedCommandBus defined in class path resource [com/deng/axon/distributed/config/DistributedAxonAutoConfig.class]
↑ ↓
| unifiedCommandBusConnector defined in class path resource [com/deng/axon/distributed/config/DistributedAxonAutoConfig.class]
└─────┘
The culprit seems to be InterceptorAutoConfiguration. When I excluded it, everythings works as expected.
@cneuwirt, I would like to notify you that the referred to issue by @MateuszNowak has seen a PR, approval, and has been merged.
This means that there’s a 4.11.1-SNAPSHOT release of Axon Framework that contains the aforementioned fix.
If your time allows it, would you be open to test if this snapshot version resolve the issue you’re seeing?
We have, of course, tested it against our own sample projects. But knowing a project “in the field” is resolved also gives us the added certainty to proceed towards a patch release.
We’ve validated the fix to work in several projects the last couple of days.
As such, we feel comfortable that the problem was resolved by issue #3283.
Hence, we’ve released Axon Framework 4.11.1 with that fix today.
Feel free to let us know if that release solves the problem you were seeing, @cneuwirt!
To be frank with you, Craig, I don’t know why this ConditionalOnBean approach doesn’t work. Although I don’t think it should impact, I do want to ask if you have tried a bean creation method instead of annotating the class directly?
So, if you do what’s down below if the issue persists:
@Aspect
@Bean
@ConditionalOnBean(CommandGateway.class)
public CommandHandlerAspect commandHandlerAspect(CommandGateway commandGateway) {
return new CommandHandlerAspect(commandGateway);
}
I don’t have direct experience with using the @Aspect annotation, nor does the Axon Framework project contain any tests if that annotation has an impact on the wiring process. So, I am also wondering whether removal of that annotation causes the ConditionalOnBean to work again, yes/no.
I am working on your request to move the aspects into a @Configuration class. However, I am noticing BeanValidationInterceptor is never getting applied to dispatch or handler interceptors. My configuration includes
@Bean
public LoggingInterceptor<Message<?>> loggingInterceptor() {
return new LoggingInterceptor<>();
}
@Bean
public BeanValidationInterceptor<?> validationInterceptor() {
return new BeanValidationInterceptor<>();
}
@Bean
public ResultsInterceptor<Message<?>> resultsInterceptor(
ApplicationContext applicationContext
) {
return new ResultsInterceptor<>( applicationContext );
}
but only the LoggingInterceptor and ResultsInterceptor are getting passed to
Well, that can happen. Happy you found it
To be frank, I am not sure whether your status on this issue is now done or not.
So, if there are still some lingering issues with auto-configuring dispatch- and handler-interceptors, be sure to let me know!
Oh sorry. You can definitely close any concerns I have. The only difference was the conditional aspect above and it was only in our unit tests so easy to resolve. Thanks for all your help.