I’m using Axon-Framework with Spring-Boot and I’M trying to autoregister a global CommandHandlerInterceptor for commands. My assumption was, to simply create it as a bean and it is automatically discovered by Axon Framework and added to the InterceptorChain, but it doesn’t seem so.
@Component
class MyCommandHandlerInterceptor : MessageHandlerInterceptor<CommandMessage<*>> {
override fun handle(unitOfWork: UnitOfWork<out CommandMessage<*>>, interceptorChain: InterceptorChain): Any? {
return interceptorChain.proceed()
}
}
It only works, when I register it manually:
@Configuration
class MyAxonConfiguration {
@Autowired
private lateinit var commandBus: CommandBus
@PostConstruct
fun registerCommandInterceptors() {
commandBus.registerHandlerInterceptor(MyCommandHandlerInterceptor())
}
}
Am I doing something wrong or is this simply not implemented? If the latter: Is there a specific reason or could I provide a PR?