Hello everybody!
Lets assume that I have a system with a Car aggregate, and there is a rule that says that a car cannot have the same color of an existing car. That way, in my view database table, I have an unique constraint validation in the color column. The question is: when I am validating a CreateCarCommand, what is the proper way of validate if the color of the new car do not exists in the system? If I use the query gateway at the command handler to verify if there is some car in the database with that color, I imagine that I can have some “parallel” issue, when two commands to create cars with the same color are sent, one right after the other, and before que Event Handler handle that event to create the first car one in the database, the validation of the second command occurs, and do not say that the color existis, just because the first one was not created in the database yet. It do not look the proper way to solve it, I think…