Command validation


We are using Axon 3.0 with Spring boot and I’m trying to apply Bean validation on our commands. I thought something like this would work:

public void configureValidation(CommandBus commandBus)

if(commandBus instanceof DistributedCommandBus)


((DistributedCommandBus) commandBus).registerDispatchInterceptor(new BeanValidationInterceptor());



But it doesn’t. For our unit tests, we were able to add validation like this though:

new AggregateTestFixture(…).registerCommandHandlerInterceptor(new BeanValidationInterceptor());

So the problem is not related to the validation framework. Any input on this?

Thanks in advance,

Did you check the interceptor is properly registered on your command bus? Hence, is the injected CommandBus an instance of DistributedCommandBus?

Other than that, I cannot see anything wrong with this configuration.



It seems that another configuration issue was the real cause of the problem. I’ve got it working now, thanks.