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 3627616
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:54:39+00:00 2026-05-18T23:54:39+00:00

I’m still struggling with what must be basic (and resolved) issues related to CQRS

  • 0

I’m still struggling with what must be basic (and resolved) issues related to CQRS style architecture:

How do we implement business rules that rely on a set of Aggregate Roots?

Take, as an example, a booking application. It may enable you to book tickets for a concert, seats for a movie or a table at a restaurant. In all cases, there’s only going to be a limited number of ‘items’ for sale.

Let’s imagine that the event or place is very popular. When sales open for a new event or time slot, reservations start to arrive very quickly – perhaps many per second.

On the query side we can scale massively, and reservations are put on a queue to be handled asynchronously by an autonomous component. At first, when we pull off Reservation Commands from the queue we will accept them, but at a certain time we will have to start rejecting the rest.

How do we know when we reach the limit?

For each Reservation Command we would have to query some sort of store to figure out if we can accommodate the request. This means that we will need to know how many reservations we have already received at that time.

However, if the Domain Store is a non-relational data store such as e.g. Windows Azure Table Storage, we can’t very well do a SELECT COUNT(*) FROM ...

One option would be to keep a separate Aggregate Root that simply keeps track of the current count, like this:

  • AR: Reservation (who? how many?)
  • AR: Event/Time slot/Date (aggregate count)

The second Aggregate Root would be a denormalized aggregation of the first one, but when the underlying data store doesn’t support transactions, then it’s very likely that these can get out of sync in high-volume scenarios (which is what we are trying to address in the first place).

One possible solution is to serialize handling of the Reservation Commands so that only one at a time is handled, but this goes against our goals of scalability (and redundancy).

Such scenarios remind me of standard “out of stock” scenarios, but the difference is that we can’t very well put the reservation on back order. Once an event is sold out, it’s sold out, so I can’t see what a compensating action would be.

How do we handle such scenarios?

  • 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-05-18T23:54:40+00:00Added an answer on May 18, 2026 at 11:54 pm

    After thinking about this for some time it finally dawned on me that the underlying problem is less related to CQRS than it is to the non-trasactional nature of disparate REST services.

    Really it boils down to this problem: if you need to update several resources, how do you ensure consistency if the second write operation fails?

    Let’s imagine that we want to write updates to Resource A and Resource B in sequence.

    1. Resource A is successfully updated
    2. The attempt to update Resource B fails

    The first write operation can’t easily be rolled back in the face of an exception, so what can we do? Catching and suppressing the exception to perform a compensating action against Resource A is not a viable option. First of all it’s complex to implement, but secondly it’s not safe: what happens if the first exception happened because of a failed network connection? In that scenario, we can’t write a compensating action against Resource A either.

    The key lies in explicit idempotency. While Windows Azure Queues don’t guarantee exactly once semantics, they do guarantee at least once semantics. This means that in the face of intermittent exceptions, the message will later be replayed.

    In the previous scenario, this is what happens then:

    1. Resource A is attempted updated. However, the replay is detected so the state of A isn’t affected. However, the ‘write’ operation succeeds.
    2. Resource B is successfully updated.

    When all write operations are idempotent, eventual consistency can be achieved with message replays.

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

Sidebar

Related Questions

No related questions found

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.