[axonframework] Digest for axonframework@googlegroups.com - 3 Messages in 2 Topics

Hey guys, could I possibly a see a sample application using JSR-303 validation? Sounds useful!

Hi,

I’m not sure the example applications have a jsr303 example in them yet. I’ll check as soon as I have a proper computer at my disposal.

Configuring it is pretty simple. You’ll need a jsr303 implementation, such as Hibernate-Validator. Then, configure a validating interceptor (it’s provided by Axon) and configure it with a validator instance. If your commands are annotated with 303-annotations, you’ll see the exceptions flying by…

I’ll create a little code sample when I have the chance.

Cheers,

Allard

I added some JSR-303 “magic” to the Axon Trader sample. It’s a crude implementatoin, because the error handling is not implemented nicely.

https://github.com/AxonFramework/Axon-trader/commit/76aecce464dd443232542f3a442381f8075b2f7e

The BeanValidationInterceptor is now defined as a dispatch interceptor. This means an exception will be thrown directly by the commandBus.dispatch method, instead of invoking the callback. If you configure it as a command handling interceptor, the callback will be invoked instead.
Generally, the former is a better idea for structural validation: you don’t want to spend CPU time on an invalid command. The earlier you fail, the better.

Cheers,

Allard