Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7799913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:27:46+00:00 2026-06-02T00:27:46+00:00

I read that commands in CQRS are designed to not fail and should be

  • 0

I read that commands in CQRS are designed to not fail and should be async in nature.

In my case, I have a tree (think windows explorer) where users have folders that represent locations for video content and each child is a video/media file. Multiple users can all be working on the same branch of the tree moving folders and files around (and uploading new files and creating new folders as well as deleting files/folders).

If I was ignoring the async nature of commands, I could let the first user make their change and raise an exception on the second if say a folder the user is moving a video to is no longer there. It is now the responsibility of the second user to refresh part of his tree and then reapply his changes.

How would I do this with CQRS if I need instant feed back if my change has not been allowed (i.e. I try to move a video file to another folder and another user has deleted the folder or moved it elsewhere)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:27:48+00:00Added an answer on June 2, 2026 at 12:27 am

    Your command is supposed to be valid when you send it to your domain. Therefore, before sending it, you have to validate it on your client to know if the folder is still here or not. It allows you to tell the client what is happening exactly with a clear error message

    This reduces also a lot the margin of error.The timeframe to have something that fails is reduced to the time to send the command over the network and the time to execute the command on the server.

    • If this risks is really low. We may only receive a fail command
      answer (eg:enum) from the domain. For the user, it might end up in a
      generic exception message and we could actualize its data to show him
      that things are different and taht he cannot do what he intended to.
      Such messages with a low percentage should not be a huge problem if
      they occurs only 2-3 times in the year , I expect.

    • If this risks is really high or if validation is not possible from
      the client but must occur only on the domain side, then I have no
      answer to give you at the moment. I am myself learning CQRS, and i
      cannot say more.

    hope it helped,

    [Edit]

    I assumed command handling not to be async. If So, I try catch whatever exception during execution of the command and I can return some fail notification without saying what it is exactly to the client. The projection to the various readmodel remaining async.

     public void Handle(ICommand command)
            {
                try
                {
                    CommandService.Execute(command);
    
                    Bus.Return(ErrorCodes.None);
                }
                catch (Exception e)
                {
                    Bus.Return(ErrorCodes.Fail);
                }
            }
    

    My CommandServiceDelegate the right executor to do the job :

    Public class TheGoodExecutor{
          protected void Execute(IUOW context, MyCommand command)
            {
                var myDomainObject= context.GetById<DomainObjecType>(command.Id);
    
                myDomainObject.DoStuff(Command.Data);
    
                // Accept all the work we just did.
                context.Accept();
            }
    }
    

    If the good Executor goes in error then Bus.Return(ErrorCodes.Fail);

    And this can be received by my client either synchronously or asynchronously.

    If you wish to go full async (that’s what I am trying to do, or at least I would like to explore that way), I would try on subscribing to events, the client might be interested in.
    For Validation I think, listening to events does not make a lot of sense for most of the cases. But in the second case, I was speaking of, it might. In other cases, aside validation, it might too…

    everything in Italic is some personal tryout, I have not read anything about it, nor finished anything working properly going in that sense. So take it with Big brackets.. he he!!

    [/Edit]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting into CQRS and I understand that you have commands (app layer) and events
I know that it is possible to read commands output with a pipe? But
I read that when you don't have access to the web server's headers you
I have a Window .bat file with DOS commands that involve REM, MKDIR, ECHO,
I have two (UNIX) programs A and B that read and write from stdin/stdout.
I have written a little bash script that reads commands (one per line), in
I read that the executables for the commands issued using exec() calls are supposed
I am trying to write a small Mac command line app that can read
I read that it's possible to make quicksort run at O(nlogn) the algorithm says
I read that the AppError class is now for backwards compatibility and that Exceptions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.