Axon-trader example: no implementation of unique username constraint


First, thanks for great CQRS framework.
I really admire your work.

On wiki page of Axon-trader example:
there is said that:
“When receiving a command to create a new user,
we first check against a special collection to see if the username is still available.
After validation we actually create the user.”

… but there is no such a logic in related command handler:

Maybe I missed something but I could really use a reference solution for this problem.


Hi Pawel,

I think you’re right about the check missing there. Looks like we forgot to implement that.

To apply set validation, as this type of ‘uniqueness check’ is called, you need to create a simple table of used values, in which you add a value when an aggregate is changed. This table is your uniqueness guarantee.

There is an example in the Addressbook sample. The UnitOfWorkListerner is not needed if you use a transactional datasource.