How do you solve the following problem in the CQRS architecture:
- There is a domain object called Order.
- Order must be processed.
- Newly created Orders are unprocessed and queued for processing
- Each order should not be processed several times.
- For unprocessed orders, there are several Windows services that request (read some things).
Now, how can I guarantee that each order is processed by only one service?
I would make the service issue the command StartOrderProcessing(order) . This command will fail in the domain if another service is already starting to process this order, because the versions are different.
However, since the command is asynchronous in nature, how does the service know about the error?
Should the service poll the reading model to see if the order has changed to its status? But how now could a service change status because of its own team, and not because of a team from another service?
UL:
- Order: An order on my system is a user request to update a greeting on his / her inbox.
- Mailbox: when you call a cell phone and the call is not picked up, you are forwarded to the mailbox to leave a message
- Greeting. When you arrive in your inbox, you will be greeted with a text in which you should leave a message after a beep. This text (not your message!) Is a greeting.
- Activation: the process of setting up a new greeting in a mailbox is called activation. Greeting is activated.
- Carrier: a company that provides cell phone services, for example. T-Mobile.
Steps during order processing:
- Create a greeting from pre-recorded audio bits. It depends on who the mailbox is contacted with.
Follow the special Carrier workflow to activate the greeting in the mailbox. This workflow has the following elements:
2.1. Call inbox
2.2. Go to the mailbox menu using DTMF tones
2.3. Recognition of specific audio items sent by the mailbox (e.g. confirmation tone)
2.4. Play the greeting that was created in 1
A workflow is defined as a Windows Workflow Foundation workflow because it is different for each operator.
Success:
3.1. Saving an Activation Call Record
3.2. Notify user by email of success
On error:
4.1. Saving a failed activation call record and reason for failure
4.2. If this was your first attempt, pay a repeat order in X minutes
4.3. If this was the second attempt, notify the user by mail about the failure
source share