Following the advice in Tackling Complexity in CQRS by Vladik Khononov suggests command handling can return information relating to its outcome.
Without violating any [CQRS] principles, a command can safely return the following data:
- Execution result: success or failure;
- Error messages or validation errors, in case of a failure;
- The aggregate’s new version number, in case of success;
This information will dramatically improve the user experience of your system, because:
- You don’t have to poll an external source for command execution result, you have it right away. It becomes trivial to validate commands, and to return error messages.
- If you want to refresh the displayed data, you can use the aggregate’s new version to determine whether the view model reflects the executed command or not. No more displaying stale data.
Daniel Whittaker advocates returning a "common result" object from a command handler containing this information.